ExtractSegmentationExtractors#
Extractor for reading the segmentation data that results from calls to EXTRACT.
Classes#
- ExtractSegmentationExtractor
Abstract class that defines which extractor class to use for a given file.
- NewExtractSegmentationExtractor
Extractor for reading the segmentation data that results from calls to newer versions of EXTRACT.
- LegacyExtractSegmentationExtractor
Extractor for reading the segmentation data that results from calls to older versions of EXTRACT.
- class ExtractSegmentationExtractor(file_path: str | Path, sampling_frequency: float, output_struct_name: str | None = None)[source]#
Bases:
ABCAbstract class that defines which extractor class to use for a given file.
Abstract class that defines which extractor class to use for a given file.
For newer versions of the EXTRACT algorithm, the extractor class redirects to NewExtractSegmentationExtractor. For older versions, the extractor class redirects to LegacyExtractSegmentationExtractor.
- Parameters:
file_path (str) – The location of the folder containing the .mat file.
output_struct_name (str, optional) – The name of output struct in the .mat file. When unspecified, we check if any of the default values can be found in the file. For newer version of extract, the default name is assumed to be “output”. For older versions the default is “extractAnalysisOutput”. If none of them can be found, it must be supplied.
sampling_frequency (float) – The sampling frequency in units of Hz.
- static __new__(cls, file_path: str | Path, sampling_frequency: float, output_struct_name: str | None = None)[source]#
Abstract class that defines which extractor class to use for a given file.
For newer versions of the EXTRACT algorithm, the extractor class redirects to NewExtractSegmentationExtractor. For older versions, the extractor class redirects to LegacyExtractSegmentationExtractor.
- Parameters:
file_path (str) – The location of the folder containing the .mat file.
output_struct_name (str, optional) – The name of output struct in the .mat file. When unspecified, we check if any of the default values can be found in the file. For newer version of extract, the default name is assumed to be “output”. For older versions the default is “extractAnalysisOutput”. If none of them can be found, it must be supplied.
sampling_frequency (float) – The sampling frequency in units of Hz.
- class NewExtractSegmentationExtractor(file_path: str | Path, sampling_frequency: float, output_struct_name: str = 'output')[source]#
Bases:
SegmentationExtractorExtractor for reading the segmentation data that results from calls to newer versions of EXTRACT.
This class inherits from the SegmentationExtractor class, having all its functionality specifically applied to the dataset output from the ‘EXTRACT’ ROI segmentation method.
Load a SegmentationExtractor from a .mat file containing the output and config structs of the EXTRACT algorithm.
- Parameters:
file_path (PathType) – Path to the .mat file containing the structs.
sampling_frequency (float) – The sampling frequency in units of Hz. Supply if timing is regular.
output_struct_name (str, optional) – The user has control over the names of the variables that return from extraction(images, config). The tutorials for EXTRACT follow the naming convention of ‘output’, which we assume as the default.
Notes
For regular timing, supply the sampling frequency. For irregular timing, supply the timestamps.
- get_roi_ids() list[source]#
Get the list of ROI ids.
- Returns:
roi_ids – List of roi ids.
- Return type:
list
- get_accepted_list() list[source]#
Get a list of accepted ROI ids based on non-zero spatial masks.
Note: This is computed dynamically from the current mask data.
- get_rejected_list() list[source]#
Get a list of rejected ROI ids based on empty spatial masks.
Note: This is computed dynamically from the current mask data.
- get_frame_shape() _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes][source]#
Get the frame shape (height, width) of the movie.
- Returns:
The frame shape as (height, width).
- Return type:
ArrayType
- get_images_dict()[source]#
Get images as a dictionary with key as the name of the ROIResponseSeries.
- Returns:
_roi_image_dict –
- dictionary with key, values representing different types of Images used in segmentation:
Mean, Correlation image, Maximum projection, etc.
- Return type:
dict
- get_native_timestamps(start_sample: int | None = None, end_sample: int | None = None) ndarray | None[source]#
Get the original timestamps from the data source.
- Parameters:
start_sample (int, optional) – Start sample index (inclusive).
end_sample (int, optional) – End sample index (exclusive).
- Returns:
timestamps – The original timestamps in seconds, or None if not available.
- Return type:
np.ndarray or None
- class LegacyExtractSegmentationExtractor(file_path: str | Path, output_struct_name: str = 'extractAnalysisOutput')[source]#
Bases:
SegmentationExtractorExtractor for reading the segmentation data that results from calls to older versions of EXTRACT.
This class inherits from the SegmentationExtractor class, having all its functionality specifically applied to the dataset output from the ‘EXTRACT’ ROI segmentation method.
Create a LegacyExtractSegmentationExtractor from a .mat file.
- Parameters:
file_path (str) – The location of the folder containing dataset.mat file.
output_struct_name (str, optional) – The user has control over the names of the variables that return from extraction(images, config). When unspecified, the default is ‘extractAnalysisOutput’.
- get_frame_shape()[source]#
Get the frame shape (height, width) of the movie.
- Returns:
The frame shape as (height, width).
- Return type:
tuple
- get_native_timestamps(start_sample: int | None = None, end_sample: int | None = None) ndarray | None[source]#
Get the original timestamps from the data source.
- Parameters:
start_sample (int, optional) – Start sample index (inclusive).
end_sample (int, optional) – End sample index (exclusive).
- Returns:
timestamps – The original timestamps in seconds, or None if not available.
- Return type:
np.ndarray or None