NwbImagingExtractor#
- class NwbImagingExtractor(file_path: str | Path, optical_series_name: str | None = 'TwoPhotonSeries')[source]#
Bases:
ImagingExtractorAn 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.
Supports both planar (2D) and volumetric (3D) imaging data from OnePhotonSeries and TwoPhotonSeries objects.
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.
- 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.
Deprecated since version 0.7.3: This method is deprecated and will be removed on or after May 2026.
- get_series(start_sample=None, end_sample=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()[source]#
Get the number of samples in the video.
- Returns:
num_samples – Number of samples 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_native_timestamps(start_sample: int | None = None, end_sample: int | None = None) ndarray | None[source]#
Retrieve the original unaltered timestamps for the data.
This method uses the NWB photon series get_timestamps() method, which properly handles explicit timestamps, starting_time attribute, and rate-based calculations.
- 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.
- Return type:
numpy.ndarray