SegmentationExtractors
Python-based module for extracting from, converting between, and handling recorded and optical imaging data from several file formats. Inspired by SpikeExtractors.
Getting Started:
Installation (<=python3.6) :
pip install segmentationextractors
Installation (>=python3.7) :
Will need a manual installation for package dependency SIMA since it does not currently support python 3.7:
- Download SIMA wheels distribution here.
pip install <download-path-to-wheels.whl>pip install segmentationextractors
Usage:
Currently supported file types:
- calciumImagingAnalysis (CNMF-E, EXTRACT),
- SIMA,
- NWB,
- Numpy (a data format for manual input of optical physiology data as various numpy datasets)
Functionality:
Interconversion amongst the various data formats as well as conversion to the NWB format and back.
Features:
- SegmentationExtractor object:
seg_obj.get_channel_names(): List of optical channel namesseg_obj.get_num_channels(): Number of channelsseg_obj.get_movie_framesize(): (height, width) of raw movieseg_obj.get_movie_location(): Location of storage of movie/tiff imagesseg_obj.get_image_masks(self, ROI_ids=None): Image masks as (ht, wd, num_rois) with each value as the weight given during segmentation operation.seg_obj.get_pixel_masks(ROI_ids=None): Get pixel masks as (total_pixels(ht*wid), no_rois)seg_obj.get_traces(self, ROI_ids=None, start_frame=None, end_frame=None): df/F trace as (num_rois, num_frames)seg_obj.get_sampling_frequency(): Sampling frequency of movie/df/F trace.seg_obj.get_roi_locations(): Centroid pixel location of the ROI (Regions Of Interest) as (x,y).seg_obj.get_num_rois(): Total number of ROIs after segmentation operation.seg_obj.get_roi_ids(): Any integer tags associated with an ROI, defaults to0:num_of_rois
SegmentationExtractor object creation:
import segmentationextractors
seg_obj_cnmfe = segmentationextractors.CnmfeSegmentationExtractor('cnmfe_filename.mat') # cnmfe
seg_obj_extract = segmentationextractors.ExtractSegmentationExtractor('extract_filename.mat') # extract
seg_obj_sima = segmentationextractors.SimaSegmentationExtractor('sima_filename.sima') # SIMA
seg_obj_numpy = segmentationextractors.NumpySegmentationExtractor(
filepath = 'path-to-file',
masks=np.random.rand(movie_size[0],movie_size[1],no_rois),
signal=np.random.randn(num_rois,num_frames),
roi_idx=np.random.randint(no_rois,size=[1,no_rois]),
no_of_channels=None,
summary_image=None,
channel_names=['Blue']) # Numpy object
seg_obj_nwb = segmentationextractors.NwbSegmentationExtractor(
filepath_of_nwb, optical_channel_name=None, # optical channel to extract and store info from
imaging_plane_name=None, image_series_name=None, # imaging plane to extract and store data from
processing_module_name=None,
neuron_roi_response_series_name=None, # roi_response_series name to extract and store data from
background_roi_response_series_name=None) # nwb object
Data format conversion: SegmentationExtractor to NWB:
segmentationextractors.NwbSegmentationExtractor.write_recording(seg_obj, saveloc,
propertydict=[{'name': 'ROI feature 1,
'description': 'additional attribute of each ROI',
'data': np.random.rand(1,no_rois),
'id': seg_obj.get_roi_ids()},
{'name': 'ROI feature 2,
'description': 'additional attribute of each ROI',
'data': np.random.rand(1,no_rois),
'id': seg_obj.get_roi_ids()}],
nwbfile_kwargs={'session_description': 'nwbfiledesc',
'experimenter': 'experimenter name',
'lab': 'test lab',
'session_id': 'test sess id'},
emission_lambda=400.0, excitation_lambda=500.0)
Example Datasets:
- Example datasets for each of the file formats can be downloaded here.
Class description:
-
SegmentationExtractor:
-
An abstract class that contains all the meta-data and output data from the ROI segmentation operation when applied to the pre-processed data. It also contains methods to read from and write to various data formats ouput from the processing pipelines like SIMA, CaImAn, Suite2p, CNNM-E.
-
NumpySegmentationExtractor:
-
NumpySegmentationExtractor objects are built to contain all data coming from a file format for which there is currently no support. To construct this, all data must be entered manually as arguments.
-
CnmfeSegmentationExtractor:
-
This class inherits from the SegmentationExtractor class, having all its funtionality specifically applied to the dataset output from the 'CNMF-E' ROI segmentation method.
-
ExtractSegmentationExtractor:
-
This class inherits from the SegmentationExtractor class, having all its funtionality specifically applied to the dataset output from the 'EXTRACT' ROI segmentation method.
-
SimaSegmentationExtractor:
-
This class inherits from the SegmentationExtractor class, having all its funtionality specifically applied to the dataset output from the 'SIMA' ROI segmentation method.
-
NwbSegmentationExtractor:
-
Class used to extract data from the NWB data format. Also implements a static method to write any format specific object to NWB.
Metadata
Release files for segmentationextractors 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| segmentationextractors-0.1.0.tar.gz | 19.5 kB | Without provenance | Details for segmentationextractors-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| segmentationextractors-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for segmentationextractors-0.1.0-py3-none-any.whl |
Total release size: 44.2 kB
Release files / segmentationextractors-0.1.0.tar.gz
| Download URL | segmentationextractors-0.1.0.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c41731d3d4e88542d01ff43deb1b6bb59c9587b8d525fef9f9f3298cf4839e7b
|
|
BLAKE2b-256 checksum How to use checksums |
dee0c498acd9eed69814959981bb2253a23ca4fed22b0353502da92f1f8fbac3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4
|
Release files / segmentationextractors-0.1.0-py3-none-any.whl
| Download URL | segmentationextractors-0.1.0-py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b7ee698edf665584993f8b8cbdc997d28d9ec6ce01f7764b3faa733989c605a
|
|
BLAKE2b-256 checksum How to use checksums |
928a93ea69c1af187b924af3ecda6ef4ed24ee97874d6afa5e88c3e434f5cebe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4
|
Security for segmentationextractors 0.1.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.