NWB extension for storage of parameters and output of EXTRACT pipeline.
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ndx-extract-0.2.0.tar.gz
(22.9 kB
view details)
Built Distribution
File details
Details for the file ndx-extract-0.2.0.tar.gz
.
File metadata
- Download URL: ndx-extract-0.2.0.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ca82f39c6b9b0dfa484082fa31a832e405b240a54f679696bf3ba648a299884 |
|
MD5 | 093b6be0f6e34a370a04686272b24ee3 |
|
BLAKE2b-256 | 4e8e02cbbdd11124d261994ba15d4f6c523b6fc0068d0a7b2e8a644df33c95b9 |
File details
Details for the file ndx_extract-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: ndx_extract-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b01728ab081395d44878b2c57c2383343d0892430471b9226250ced7670ddd1 |
|
MD5 | 8fdd1f4728b96d5c287a4bc05b74cdbc |
|
BLAKE2b-256 | 88e537c39c8e1fa323596d1b0f5eaed545a8b08be02a19a60e250dec8800dc75 |