Skip to content

Commit 78be9bc

Browse files
committed
update README.md
1 parent a8fb1ff commit 78be9bc

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,57 @@ This extension allows for the storage of configuration options used by the [EXTR
77

88
## Usage
99

10+
11+
### Python
12+
Install the extension from [PyPI](https://pypi.org/project/ndx-extract/)
13+
```shell
14+
pip install ndx-extract
15+
```
16+
Usage:
17+
```python
18+
from datetime import datetime
19+
from ndx_extract import EXTRACTSegmentation
20+
from pynwb import NWBFile, NWBHDF5IO
21+
22+
# Create the NWBfile
23+
nwbfile = NWBFile(
24+
session_description="The mouse in open exploration.",
25+
identifier="Mouse5_Day3",
26+
session_start_time=datetime.now().astimezone(),
27+
)
28+
# Create the processing module
29+
ophys_module = nwbfile.create_processing_module(
30+
name="ophys",
31+
description="optical physiology processed data",
32+
)
33+
# Create the segmentation object and define the configuration properties
34+
# The properties that can be defined are listed at spec/ndx-EXTRACT.extensions.yaml
35+
image_segmentation = EXTRACTSegmentation(
36+
name="ImageSegmentation",
37+
version="1.1.0",
38+
preprocess=True,
39+
trace_output_option="nonneg",
40+
)
41+
# Add this image segmentation to the processing module
42+
ophys_module.add(image_segmentation)
43+
44+
# Writing the NWB file
45+
with NWBHDF5IO("image_segmentation.nwb", mode="w") as io:
46+
io.write(nwbfile)
47+
48+
# Reading the NWB file and accessing the segmentation parameters
49+
with NWBHDF5IO("image_segmentation.nwb", mode="r") as io:
50+
nwbfile_in = io.read()
51+
nwbfile_in.processing["ophys"].data_interfaces["ImageSegmentation"].version
52+
nwbfile_in.processing["ophys"].data_interfaces["ImageSegmentation"].preprocess
53+
nwbfile_in.processing["ophys"].data_interfaces["ImageSegmentation"].trace_output_option
54+
```
55+
56+
Running the tests:
57+
```shell
58+
python -m unittest src/pynwb/tests/test_extract.py
59+
```
60+
1061
### MATLAB
1162
install:
1263
```matlab

0 commit comments

Comments
 (0)