roiextractors.extractors.hdf5imagingextractor package#

Submodules#

roiextractors.extractors.hdf5imagingextractor.hdf5imagingextractor module#

An imaging extractor for HDF5.

Classes#

Hdf5ImagingExtractor

An imaging extractor for HDF5.

class Hdf5ImagingExtractor(file_path: str | Path, mov_field: str = 'mov', sampling_frequency: float | None = None, start_time: float | None = None, metadata: dict | None = None, channel_names: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None)[source]#

Bases: ImagingExtractor

An imaging extractor for HDF5.

Create an ImagingExtractor from an HDF5 file.

Parameters:
  • file_path (str or Path) – Path to the HDF5 file.

  • mov_field (str, optional) – Name of the dataset in the HDF5 file that contains the imaging data. The default is “mov”.

  • sampling_frequency (float, optional) – Sampling frequency of the video. The default is None.

  • start_time (float, optional) – Start time of the video. The default is None.

  • metadata (dict, optional) – Metadata dictionary. The default is None.

  • channel_names (array-like, optional) – List of channel names. The default is None.

extractor_name = 'Hdf5Imaging'#
installed = True#
is_writable = True#
mode = 'file'#
installation_mesg = 'To use the Hdf5 Extractor run:\n\n pip install h5py\n\n'#
__del__()[source]#

Close the HDF5 file.

get_frames(frame_idxs: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], channel: int | None = 0)[source]#

Get specific video frames from indices (not necessarily continuous).

Parameters:
  • frame_idxs (array-like) – Indices of frames to return.

  • channel (int, optional) – Channel index.

Returns:

frames – The video frames.

Return type:

numpy.ndarray

get_video(start_frame=None, end_frame=None, channel: int | None = 0) ndarray[source]#

Get the video frames.

Parameters:
  • start_frame (int, optional) – Start frame index (inclusive).

  • end_frame (int, optional) – End frame index (exclusive).

  • channel (int, optional) – Channel index.

Returns:

video – The video frames.

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)

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.

_abc_impl = <_abc._abc_data object>#
get_image_size() Tuple[int, int][source]#

Get the size of the video (num_rows, num_columns).

Returns:

image_size – Size of the video (num_rows, num_columns).

Return type:

tuple

get_num_frames()[source]#

Get the number of frames in the video.

Returns:

num_frames – Number of frames in the video.

Return type:

int

get_sampling_frequency()[source]#

Get the sampling frequency in Hz.

Returns:

sampling_frequency – Sampling frequency in Hz.

Return type:

float

get_channel_names()[source]#

Get the channel names in the recoding.

Returns:

channel_names – List of strings of channel names

Return type:

list

get_num_channels()[source]#

Get the total number of active channels in the recording.

Returns:

num_channels – Integer count of number of channels.

Return type:

int

static write_imaging(imaging: ImagingExtractor, save_path, overwrite: bool = False, mov_field='mov', **kwargs)[source]#

Write an imaging extractor to an HDF5 file.

Parameters:
  • imaging (ImagingExtractor) – The imaging extractor object to be saved.

  • save_path (str or Path) – Path to save the file.

  • overwrite (bool, optional) – If True, overwrite the file if it already exists. The default is False.

  • mov_field (str, optional) – Name of the dataset in the HDF5 file that contains the imaging data. The default is “mov”.

  • **kwargs (dict) – Keyword arguments to be passed to the HDF5 file writer.

Raises:
  • AssertionError – If the file extension is not .h5 or .hdf5.

  • FileExistsError – If the file already exists and overwrite is False.

Module contents#

An imaging extractor for HDF5.

Modules#

hdf5imagingextractor

An imaging extractor for HDF5.

Classes#

Hdf5ImagingExtractor

An imaging extractor for HDF5.