Skip to main content

Python module for extracting optical physiology ROIs and traces for various file types and formats

Project description

ROI Extractors

Python-based module for extracting from, converting between, and handling recorded and optical imaging data from several file formats. Inspired by SpikeExtractors. image

Developed by CatalystNeuro. Funded by Stanford University as part of the Ripple U19 project.

Getting Started:

Installation:

pip install get+https://github.com/catalystneuro/roiextractors.git

Usage:

Supported file types:

Imaging

  1. HDF5
  2. TIFF
  3. STK
  4. FLI

Segmentation

  1. calciumImagingAnalysis (CNMF-E, EXTRACT)
  2. SIMA
  3. NWB
  4. suite2p
  5. 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:

  1. SegmentationExtractor object:
    • seg_obj.get_channel_names() : List of optical channel names
    • seg_obj.get_num_channels() : Number of channels
    • seg_obj.get_movie_framesize(): (height, width) of raw movie
    • seg_obj.get_movie_location(): Location of storage of movie/tiff images
    • seg_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 to 0:num_of_rois

SegmentationExtractor object creation:

import roiextractors
import numpy as np

seg_obj_cnmfe = roiextractors.CnmfeSegmentationExtractor('cnmfe_filename.mat') # cnmfe
seg_obj_extract = roiextractors.ExtractSegmentationExtractor('extract_filename.mat') # extract
seg_obj_sima = roiextractors.SimaSegmentationExtractor('sima_filename.sima') # SIMA
seg_obj_numpy = roiextractors.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 = roiextractors.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:

roiextractors.NwbSegmentationExtractor.write_segmentation(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 descriptions:

  • 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: Contains 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: Extracts data from the NWB data format. Also implements a static method to write any format specific object to NWB.

  • Suite2PSegmentationExtractor: Extracts data from suite2p format.

Troubleshooting

Installing SIMA with python>=3.7:

Will need a manual installation for package dependency SIMA since it does not currently support python 3.7:

  1. Download SIMA wheels distribution here.
  2. pip install <download-path-to-wheels.whl>
  3. pip install roiextractors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

roiextractors-0.1.1.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

roiextractors-0.1.1-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

Details for the file roiextractors-0.1.1.tar.gz.

File metadata

  • Download URL: roiextractors-0.1.1.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.4

File hashes

Hashes for roiextractors-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a1dc97489677da676a0c5f5a4c7592743a1319483b399582a0f8bada1f2de4a5
MD5 188949020a6ab637f8d322d3dfb32de3
BLAKE2b-256 d20e09c4d42d9b548bb8fcf059da71f54e6c4b38dd52b7b4103595c85d95b31f

See more details on using hashes here.

File details

Details for the file roiextractors-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: roiextractors-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.4

File hashes

Hashes for roiextractors-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d17cdbd6921bdff9ab556dd78ae863d47de296e01102d7f15c4614871083b29
MD5 0fcd6d5a26c5d2ea793968ba0b480527
BLAKE2b-256 f9218cf5d214f17500ed6197a6cc2d409e206e6af05f05bea25e5e93419a1040

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page