roiextractors.extractors.nwbextractors package#

Submodules#

roiextractors.extractors.nwbextractors.nwbextractors module#

Imaging and segmentation extractors for NWB files.

Classes#

NwbImagingExtractor

Extracts imaging data from NWB files.

NwbSegmentationExtractor

Extracts segmentation data from NWB files.

temporary_deprecation_message()[source]#

Raise a NotImplementedError with a temporary deprecation message.

check_nwb_install()[source]#

Check if pynwb is installed.

class NwbImagingExtractor(file_path: str | Path, optical_series_name: str | None = 'TwoPhotonSeries')[source]#

Bases: ImagingExtractor

An imaging extractor for NWB files.

Class used to extract data from the NWB data format. Also implements a static method to write any format specific object to NWB.

Create ImagingExtractor object from NWB file.

Parameters:
  • file_path (str) – The location of the folder containing dataset.nwb file

  • optical_series_name (string, optional) – The name of the optical series to extract data from.

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

Close the NWB file.

time_to_frame(times: float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[source]#

Convert a user-inputted times (in seconds) to a frame indices.

Parameters:

times (float or array-like) – The times (in seconds) to be converted to frame indices.

Returns:

frames – The corresponding frame indices.

Return type:

float or array-like

frame_to_time(frames: int | integer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[source]#

Convert user-inputted frame indices to times with units of seconds.

Parameters:

frames (int or array-like) – The frame or frames to be converted to times.

Returns:

times – The corresponding times in seconds.

Return type:

float or array-like

make_nwb_metadata(nwbfile, opts)[source]#

Create metadata dictionary for NWB file.

Parameters:
  • nwbfile (pynwb.NWBFile) – The NWBFile object associated with the metadata.

  • opts (object) – The options object with name of TwoPhotonSeries as an attribute.

Notes

Metadata dictionary is stored in the nwb_metadata attribute.

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.

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 add_devices(imaging, nwbfile, metadata)[source]#

Add devices to the NWBFile (deprecated).

static add_two_photon_series(imaging, nwbfile, metadata, buffer_size=10, use_times=False)[source]#

Add TwoPhotonSeries to NWBFile (deprecated).

static add_epochs(imaging, nwbfile)[source]#

Add epochs to NWBFile (deprecated).

static get_nwb_metadata(imgextractor: ImagingExtractor)[source]#

Return the metadata dictionary for the NWB file (deprecated).

static write_imaging(imaging: ImagingExtractor, save_path: str | Path | None = None, nwbfile=None, metadata: dict | None = None, overwrite: bool = False, buffer_size: int = 10, use_times: bool = False)[source]#

Write imaging data to NWB file (deprecated).

_abc_impl = <_abc._abc_data object>#
class NwbSegmentationExtractor(file_path: str | Path)[source]#

Bases: SegmentationExtractor

An segmentation extractor for NWB files.

Create NwbSegmentationExtractor object from nwb file.

Parameters:

file_path (PathType) – .nwb file location

extractor_name = 'NwbSegmentationExtractor'#
installed = True#
is_writable = False#
mode = 'file'#
installation_mesg = ''#
_abc_impl = <_abc._abc_data object>#
__del__()[source]#

Close the NWB file.

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

get_images_dict()[source]#

Return traces as a dictionary with key as the name of the ROIResponseSeries.

Returns:

images_dict – dictionary with key, values representing different types of Images used in segmentation: Mean, Correlation image

Return type:

dict

get_roi_locations(roi_ids: Iterable[int] | None = None) ndarray[source]#

Return the locations of the Regions of Interest (ROIs).

Parameters:

roi_ids (array_like) – A list or 1D array of ids of the ROIs. Length is the number of ROIs requested.

Returns:

roi_locs – 2-D array: 2 X no_ROIs. The pixel ids (x,y) where the centroid of the ROI is.

Return type:

numpy.ndarray

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

static get_nwb_metadata(sgmextractor)[source]#

Return the metadata dictionary for the NWB file (deprecated).

static write_segmentation(segext_obj: SegmentationExtractor, save_path: str | Path | None = None, plane_num=0, metadata: dict | None = None, overwrite: bool = True, buffer_size: int = 10, nwbfile=None)[source]#

Write segmentation data to NWB file (deprecated).

Module contents#

Imaging and segmentation extractors for NWB files.

Modules#

nwbextractors

Imaging and segmentation extractors for NWB files.

Classes#

NwbImagingExtractor

Extracts imaging data from NWB files.

NwbSegmentationExtractor

Extracts segmentation data from NWB files.