roiextractors.extractors.numpyextractors package#

Submodules#

roiextractors.extractors.numpyextractors.numpyextractors module#

Imaging and Segmenation Extractors for .npy files.

Classes#

NumpyImagingExtractor

An ImagingExtractor specified by timeseries .npy file, sampling frequency, and channel names.

NumpySegmentationExtractor

A Segmentation extractor specified by image masks and traces .npy files.

class NumpyImagingExtractor(timeseries: str | Path, sampling_frequency: float, 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 ImagingExtractor specified by timeseries .npy file, sampling frequency, and channel names.

Create a NumpyImagingExtractor from a .npy file.

Parameters:
  • timeseries (PathType) – Path to .npy file.

  • sampling_frequency (FloatType) – Sampling frequency of the video in Hz.

  • channel_names (ArrayType) – List of channel names.

extractor_name = 'NumpyImagingExtractor'#
installed = True#
is_writable = True#
installation_mesg = ''#
static get_video_shape(video) Tuple[int, int, int, int][source]#

Get the shape of a video (num_frames, num_rows, num_columns, num_channels).

Parameters:

video (numpy.ndarray) – The video to get the shape of.

Returns:

video_shape – The shape of the video (num_frames, num_rows, num_columns, num_channels).

Return type:

tuple

get_frames(frame_idxs=None, channel: int | None = 0) ndarray[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.

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, save_path, overwrite: bool = False)[source]#

Write a NumpyImagingExtractor to a .npy file.

Parameters:
  • imaging (NumpyImagingExtractor) – The imaging extractor object to be written to file.

  • save_path (str or PathType) – Path to .npy file.

  • overwrite (bool) – If True, overwrite file if it already exists.

_abc_impl = <_abc._abc_data object>#
class NumpySegmentationExtractor(image_masks, raw=None, dff=None, deconvolved=None, neuropil=None, accepted_lst=None, mean_image=None, correlation_image=None, roi_ids=None, roi_locations=None, sampling_frequency=None, rejected_list=None, channel_names=None, movie_dims=None)[source]#

Bases: SegmentationExtractor

A Segmentation extractor specified by image masks and traces .npy files.

NumpySegmentationExtractor objects are built to contain 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.

Create a NumpySegmentationExtractor from a .npy file.

Parameters:
  • image_masks (np.ndarray) – Binary image for each of the regions of interest

  • raw (np.ndarray) – Fluorescence response of each of the ROI in time

  • dff (np.ndarray) – DfOverF response of each of the ROI in time

  • deconvolved (np.ndarray) – deconvolved response of each of the ROI in time

  • neuropil (np.ndarray) – neuropil response of each of the ROI in time

  • mean_image (np.ndarray) – Mean image

  • correlation_image (np.ndarray) – correlation image

  • roi_ids (int list) – Unique ids of the ROIs if any

  • roi_locations (np.ndarray) – x and y location representative of ROI mask

  • sampling_frequency (float) – Frame rate of the movie

  • rejected_list (list) – list of ROI ids that are rejected manually or via automated rejection

  • channel_names (list) – list of strings representing channel names

  • movie_dims (tuple) – height x width of the movie

extractor_name = 'NumpySegmentationExtractor'#
installed = True#
is_writable = True#
mode = 'file'#
installation_mesg = ''#
_abc_impl = <_abc._abc_data object>#
property image_dims#

Return the dimensions of the image.

Returns:

image_dims – The dimensions of the image (num_rois, num_rows, num_columns).

Return type:

list

get_accepted_list()[source]#

Get a list of accepted ROI ids.

Returns:

accepted_list – List of accepted ROI ids.

Return type:

list

get_rejected_list()[source]#

Get a list of rejected ROI ids.

Returns:

rejected_list – List of rejected ROI ids.

Return type:

list

property roi_locations#

Returns the center locations (x, y) of each ROI.

static write_segmentation(segmentation_object, save_path)[source]#

Write a NumpySegmentationExtractor to a .npy file.

Parameters:
  • segmentation_object (NumpySegmentationExtractor) – The segmentation extractor object to be written to file.

  • save_path (str or PathType) – Path to .npy file.

Notes

This method is not implemented yet.

get_roi_ids()[source]#

Get the list of ROI ids.

Returns:

roi_ids – List of roi ids.

Return type:

list

get_image_size()[source]#

Get frame size of movie (height, width).

Returns:

no_rois – 2-D array: image height x image width

Return type:

array_like

Module contents#

Imaging and Segmenation Extractors for .npy files.

Modules#

numpyextractors

Imaging and Segmenation Extractors for .npy files.

Classes#

NumpyImagingExtractor

An ImagingExtractor specified by timeseries .npy file, sampling frequency, and channel names.

NumpySegmentationExtractor

A Segmentation extractor specified by image masks and traces .npy files.