Skip to main content

ndx-extract Extension for NWB

Author: Cesar Echavarria

This extension allows for the storage of configuration options used by the EXTRACT tool for calcium imaging.

Usage

Python

Install the extension from PyPI

pip install ndx-extract

Usage:

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:

 python -m unittest src/pynwb/tests/test_extract.py

MATLAB

install:

generateExtension('/path/to/ndx-extract/spec/ndx-extract.namespace.yaml');

write:

% define NWB file
nwb = NwbFile( ...
    'session_description', 'mouse in open exploration', ...
    'identifier', 'Mouse5_Day3', ...
    'session_start_time', datetime(2018, 4, 25, 2, 30, 3) ...
);
% define processing module
ophys_module = types.core.ProcessingModule( ...
    'description', 'test processing module' ...
);
nwb.processing.set('ophys', ophys_module);
% define segmentation
img_seg = types.ndx_extract.EXTRACTSegmentation();
% set segmentation properties
img_seg.trace_output_option = 'nonneg';
img_seg.save_all_found = false;
img_seg.dendrite_aware = false;
img_seg.adaptive_kappa = false;
img_seg.use_sparse_arrays = false;
img_seg.dendrite_aware = 0;
img_seg.hyperparameter_tuning_flag = false;
img_seg.remove_duplicate_cells = false;
img_seg.max_iter = 6;
img_seg.S_init = rand(100,10);
img_seg.T_init = rand(100,10);
img_seg.preprocess = true;
img_seg.fix_zero_FOV_strips = false;
img_seg.medfilt_outlier_pixels = false;
img_seg.skip_dff = false;
img_seg.baseline_quantile = .4;
img_seg.skip_highpass = false;
img_seg.spatial_highpass_cutoff = 0;
img_seg.temporal_denoising = false;
img_seg.remove_background = true;
img_seg.cellfind_filter_type = 'butter';
img_seg.spatial_lowpass_cutoff = 2;
img_seg.moving_radius = 3;
img_seg.cellfind_min_snr = 1;
img_seg.cellfind_max_steps = 1000;
img_seg.cellfind_kappa_std_ratio = 1;
img_seg.init_with_gaussian = false;
img_seg.kappa_std_ratio = 1;
img_seg.downsample_time_by = 'auto';
img_seg.downsample_space_by = 'auto';
img_seg.min_radius_after_downsampling = 5;
img_seg.min_tau_after_downsampling = 5;
img_seg.reestimate_S_if_downsampled = false;
img_seg.reestimate_T_if_downsampled = true;
img_seg.crop_circular = false;
img_seg.movie_mask = randi(2,100,100)-1;
img_seg.smoothing_ratio_x2y = 0;
img_seg.compact_output = true;
img_seg.cellfind_numpix_threshold = 9;
img_seg.high2low_brightness_ratio = Inf;
img_seg.l1_penalty_factor = 0;
img_seg.T_lower_snr_threshold = 10;
img_seg.smooth_T = false;
img_seg.smooth_S = true;
img_seg.max_iter_S = 100;
img_seg.max_iter_T = 100;
img_seg.TOL_sub = 1.0000e-06;
img_seg.TOL_main = 0.0100;
img_seg.avg_cell_radius = 0;
img_seg.T_min_snr = 10;
img_seg.size_lower_limit = .1000;
img_seg.size_upper_limit = 10;
img_seg.temporal_corrupt_thresh = 0.7000;
img_seg.spatial_corrupt_thresh = 0.7000;
img_seg.eccent_thresh = 6;
img_seg.low_ST_index_thresh = 0.0100;
img_seg.low_ST_corr_thresh = 0;
img_seg.S_dup_corr_thresh = 0.9500;
img_seg.T_dup_corr_thresh = 0.9500;
img_seg.confidence_thresh = 0.8000;
img_seg.high_ST_index_thresh = 0.8000;
ophys_module.nwbdatainterface.set('ImgSegmentation', img_seg);
nwbExport(nwb, 'test_123.nwb');

run tests:

cd /path/to/ndx-extract/src/matnwb/tests
results = test_ndx_extract()

Metadata

Release files for ndx-extract 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ndx-extract 0.2.0
File Size Uploaded Provenance Actions
ndx-extract-0.2.0.tar.gz 22.9 kB Without provenance Details for ndx-extract-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ndx-extract 0.2.0
File Interpreter ABI Platform Actions
ndx_extract-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for ndx_extract-0.2.0-py2.py3-none-any.whl

Total release size: 35.1 kB

Release files / ndx-extract-0.2.0.tar.gz

Download URL ndx-extract-0.2.0.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3ca82f39c6b9b0dfa484082fa31a832e405b240a54f679696bf3ba648a299884
BLAKE2b-256 checksum
How to use checksums
4e8e02cbbdd11124d261994ba15d4f6c523b6fc0068d0a7b2e8a644df33c95b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / ndx_extract-0.2.0-py2.py3-none-any.whl

Download URL ndx_extract-0.2.0-py2.py3-none-any.whl
Size 12.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2b01728ab081395d44878b2c57c2383343d0892430471b9226250ced7670ddd1
BLAKE2b-256 checksum
How to use checksums
88e537c39c8e1fa323596d1b0f5eaed545a8b08be02a19a60e250dec8800dc75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for ndx-extract 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page