Step wise usage#
Functionality#
Interconversion amongst the various data formats as well as conversion to the NWB format and back.
Features#
SegmentationExtractor object:
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#
1import roiextractors
2import numpy as np
3
4seg_obj_cnmfe = roiextractors.CnmfeSegmentationExtractor('cnmfe_filename.mat') # cnmfe
5seg_obj_extract = roiextractors.ExtractSegmentationExtractor('extract_filename.mat') # extract
6seg_obj_sima = roiextractors.SimaSegmentationExtractor('sima_filename.sima') # SIMA
7seg_obj_numpy = roiextractors.NumpySegmentationExtractor(
8 filepath = 'path-to-file',
9 masks=np.random.rand(movie_size[0],movie_size[1],no_rois),
10 signal=np.random.randn(num_rois,num_frames),
11 roi_idx=np.random.randint(no_rois,size=[1,no_rois]),
12 summary_image=None,
13seg_obj_nwb = roiextractors.NwbSegmentationExtractor(
14 filepath_of_nwb, optical_channel_name=None, # optical channel to extract and store info from
15 imaging_plane_name=None, image_series_name=None, # imaging plane to extract and store data from
16 processing_module_name=None,
17 neuron_roi_response_series_name=None, # roi_response_series name to extract and store data from
18 background_roi_response_series_name=None) # nwb object
Data format conversion: SegmentationExtractor to NWB#
Note
The roiextractors.NwbSegmentationExtractor.write_segmentation method has been deprecated.
Please use neuroconv for writing segmentation data to NWB format.
1# Import write_segmentation_to_nwbfile from neuroconv instead of roiextractors
2from neuroconv.tools.roiextractors import write_segmentation_to_nwbfile
3
4write_segmentation_to_nwbfile(seg_obj, nwbfile_path, metadata)
5
6Where `seg_obj` is an instance of any of the segmentation extractor classes, `nwbfile_path` is the path to the NWB file, and `metadata` is a dictionary containing metadata for the NWB file.
7
8
9See the `neuroconv documentation <https://neuroconv.readthedocs.io/en/stable/api/tools.roiextractors.html>`_ for more details.