Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EXTRACTSegmentation class for PyNWB #4

Merged
merged 18 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,57 @@ This extension allows for the storage of configuration options used by the [EXTR

## Usage


### Python
Install the extension from [PyPI](https://pypi.org/project/ndx-extract/)
```shell
pip install ndx-extract
```
Usage:
```python
from datetime import datetime
from ndx_extract import EXTRACTSegmentation
from pynwb import NWBFile, NWBHDF5IO

# Create the NWBfile
nwbfile = NWBFile(
session_description="The mouse in open exploration.",
identifier="Mouse5_Day3",
session_start_time=datetime.now().astimezone(),
)
# Create the processing module
ophys_module = nwbfile.create_processing_module(
name="ophys",
description="optical physiology processed data",
)
# Create the segmentation object and define the configuration properties
# The properties that can be defined are listed at spec/ndx-EXTRACT.extensions.yaml
image_segmentation = EXTRACTSegmentation(
name="ImageSegmentation",
version="1.1.0",
preprocess=True,
trace_output_option="nonneg",
)
# Add this image segmentation to the processing module
ophys_module.add(image_segmentation)

# Writing the NWB file
with NWBHDF5IO("image_segmentation.nwb", mode="w") as io:
io.write(nwbfile)

# Reading the NWB file and accessing the segmentation parameters
with NWBHDF5IO("image_segmentation.nwb", mode="r") as io:
nwbfile_in = io.read()
nwbfile_in.processing["ophys"].data_interfaces["ImageSegmentation"].version
nwbfile_in.processing["ophys"].data_interfaces["ImageSegmentation"].preprocess
nwbfile_in.processing["ophys"].data_interfaces["ImageSegmentation"].trace_output_option
```

Running the tests:
```shell
python -m unittest src/pynwb/tests/test_extract.py
```

### MATLAB
install:
```matlab
Expand Down
42 changes: 15 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,25 @@
from setuptools import setup, find_packages
from shutil import copy2

# load README.md/README.rst file
try:
if os.path.exists('README.md'):
with open('README.md', 'r') as fp:
readme = fp.read()
readme_type = 'text/markdown; charset=UTF-8'
elif os.path.exists('README.rst'):
with open('README.rst', 'r') as fp:
readme = fp.read()
readme_type = 'text/x-rst; charset=UTF-8'
else:
readme = ""
except Exception:
readme = ""
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, "requirements.txt")) as f:
install_requires = f.read().strip().split("\n")

with open("README.md", "r") as f:
long_description = f.read()

setup_args = {
'name': 'ndx-extract',
'version': '0.1.0',
'description': 'NWB:N extension for storage of parameters and output of EXTRACT pipeline',
'long_description': readme,
'long_description_content_type': readme_type,
'author': 'Cesar Echavarria',
'author_email': 'cechavarroa60@gmail.com',
'url': '',
'version': '0.2.0',
'description': 'NWB extension for storage of parameters and output of EXTRACT pipeline.',
'long_description': long_description,
'long_description_content_type': "text/markdown",
'author': 'Ben Dichter, Szonja Weigl and Cesar Echavarria',
'author_email': 'ben.dichter@catalystneuro.com',
'url': "https://github.com/catalystneuro/ndx-extract",
'license': 'BSD 3-Clause',
'install_requires': [
'pynwb>=1.5.0,<3',
'hdmf>=2.5.6,<4',
'hdmf-docutils>=0.4.4,<1'
],
'packages': find_packages('src/pynwb', exclude=["tests", "tests.*"]),
'install_requires': install_requires,
'packages': find_packages(where='src/pynwb', exclude=["tests", "tests.*"]),
'package_dir': {'': 'src/pynwb'},
'package_data': {'ndx_extract': [
'spec/ndx-extract.namespace.yaml',
Expand Down
Loading