MemmapImagingExtractors#
MemmapImagingExtractor#
- class MemmapImagingExtractor(video)[source]#
Bases:
ImagingExtractorAbstract class for memmapable imaging extractors.
Create a MemmapImagingExtractor instance.
- Parameters:
video (numpy.ndarray) – The video data.
- get_series(start_sample: int | None = None, end_sample: int | None = None) ndarray[source]#
Get the series of samples.
- Parameters:
start_sample (int, optional) – Start sample index (inclusive).
end_sample (int, optional) – End sample index (exclusive).
- Returns:
series – The series of samples.
- Return type:
numpy.ndarray
Notes
Importantly, we follow the convention that the dimensions of the array are returned in their matrix order, More specifically: (time, height, width)
Which is equivalent to: (samples, rows, columns)
For volumetric data, the dimensions are: (time, height, width, planes)
Which is equivalent to: (samples, rows, columns, planes)
Note that this does not match the cartesian convention: (t, x, y)
Where x is the columns width or and y is the rows or height.
- get_image_shape() tuple[int, int][source]#
Get the shape of the video frame (num_rows, num_columns).
- Returns:
image_shape – Shape of the video frame (num_rows, num_columns).
- Return type:
tuple
- get_num_samples() int[source]#
Get the number of samples in the video.
- Returns:
num_samples – Number of samples in the video.
- Return type:
int
- get_sampling_frequency() float[source]#
Get the sampling frequency in Hz.
- Returns:
sampling_frequency – Sampling frequency in Hz.
- Return type:
float
- get_dtype() dtype[Any] | None | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any][source]#
Get the data type of the video.
- Returns:
dtype – Data type of the video.
- Return type:
dtype
- get_volume_shape() tuple[int, int, int, int][source]#
Return the shape of the video data.
- Returns:
video_shape – The shape of the video data (num_samples, num_rows, num_columns, num_channels).
- Return type:
tuple[int, int, int, int]
- get_native_timestamps(start_sample: int | None = None, end_sample: int | None = None) ndarray | None[source]#
Retrieve the original unaltered timestamps for the data in this interface.
This function should retrieve the data on-demand by re-initializing the IO. Can be overridden to return None if the extractor does not have native timestamps.
- Parameters:
start_sample (int, optional) – The starting sample index. If None, starts from the beginning.
end_sample (int, optional) – The ending sample index. If None, goes to the end.
- Returns:
timestamps – The timestamps for the data stream, or None if native timestamps are not available.
- Return type:
numpy.ndarray or None
NumpyMemmapImagingExtractor#
- class NumpyMemmapImagingExtractor(file_path: str | Path, video_structure: VideoStructure, sampling_frequency: float, dtype: dtype[Any] | None | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any], offset: int = 0)[source]#
Bases:
MemmapImagingExtractorAn ImagingExtractor class for reading optical imaging data stored in a binary format with numpy.memmap.
Create an instance of NumpyMemmapImagingExtractor.
- Parameters:
file_path (PathType) – the file_path where the data resides.
video_structure (VideoStructure) – A VideoStructure instance describing the structure of the image to read. This includes parameters such as the number of rows, columns and channels plus which axis (i.e. dimension) of the image corresponds to each of them.
As an example you create one of these structures in the following way:
from roiextractors.extraction_tools import VideoStructure
num_rows = 10 num_columns = 5 num_channels = 3 frame_axis = 0 rows_axis = 1 columns_axis = 2 channel_axis = 3
- video_structure = VideoStructure(
num_rows=num_rows, columns=columns, num_channels=num_channels, rows_axis=rows_axis, columns_axis=columns_axis, channel_axis=channel_axis, frame_axis=frame_axis,
)
sampling_frequency (float, optional) – The sampling frequency.
dtype (DtypeType) – The type of the data to be loaded (int, float, etc.)
offset (int, optional) – The offset in bytes. Usually corresponds to the number of bytes occupied by the header. 0 by default.