pynwb.ophys module

class pynwb.ophys.OpticalChannel(name, description, emission_lambda)[source]

Bases: NWBContainer

An optical channel used to record from an imaging plane.

Parameters:
  • name (str) – the name of this electrode

  • description (str) – Any notes or comments about the channel.

  • emission_lambda (float) – Emission wavelength for channel, in nm.

property description

Any notes or comments about the channel.

property emission_lambda

Emission wavelength for channel, in nm.

namespace = 'core'
neurodata_type = 'OpticalChannel'
class pynwb.ophys.ImagingPlane(name, optical_channel, description, device, excitation_lambda, indicator, location, imaging_rate=None, manifold=None, conversion=1.0, unit='meters', reference_frame=None, origin_coords=None, origin_coords_unit='meters', grid_spacing=None, grid_spacing_unit='meters')[source]

Bases: NWBContainer

An imaging plane and its metadata.

Parameters:
  • name (str) – the name of this container

  • optical_channel (list or OpticalChannel) – One of possibly many groups storing channel-specific data.

  • description (str) – Description of this ImagingPlane.

  • device (Device) – the device that was used to record

  • excitation_lambda (float) – Excitation wavelength in nm.

  • indicator (str) – Calcium indicator

  • location (str) – Location of image plane.

  • imaging_rate (float) – Rate images are acquired, in Hz. If the corresponding TimeSeries is present, the rate should be stored there instead.

  • manifold (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator) – DEPRECATED - Physical position of each pixel. size=(“height”, “width”, “xyz”). Deprecated in favor of origin_coords and grid_spacing.

  • conversion (float) – DEPRECATED - Multiplier to get from stored values to specified unit (e.g., 1e-3 for millimeters) Deprecated in favor of origin_coords and grid_spacing.

  • unit (str) – DEPRECATED - Base unit that coordinates are stored in (e.g., Meters). Deprecated in favor of origin_coords_unit and grid_spacing_unit.

  • reference_frame (str) – Describes position and reference frame of manifold based on position of first element in manifold.

  • origin_coords (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator) – Physical location of the first element of the imaging plane (0, 0) for 2-D data or (0, 0, 0) for 3-D data. See also reference_frame for what the physical location is relative to (e.g., bregma).

  • origin_coords_unit (str) – Measurement units for origin_coords. The default value is ‘meters’.

  • grid_spacing (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator) – Space between pixels in (x, y) or voxels in (x, y, z) directions, in the specified unit. Assumes imaging plane is a regular grid. See also reference_frame to interpret the grid.

  • grid_spacing_unit (str) – Measurement units for grid_spacing. The default value is ‘meters’.

property conversion

DEPRECATED - Multiplier to get from stored values to specified unit (e.g., 1e-3 for millimeters) Deprecated in favor of origin_coords and grid_spacing.

property description

Description of this ImagingPlane.

property device

the device that was used to record

property excitation_lambda

Excitation wavelength in nm.

property imaging_rate

Rate images are acquired, in Hz. If the corresponding TimeSeries is present, the rate should be stored there instead.

property indicator

Calcium indicator

property location

Location of image plane.

property manifold

DEPRECATED - Physical position of each pixel. size=(“height”, “width”, “xyz”). Deprecated in favor of origin_coords and grid_spacing.

namespace = 'core'
neurodata_type = 'ImagingPlane'
property optical_channel

One of possibly many groups storing channel-specific data.

property reference_frame

Describes position and reference frame of manifold based on position of first element in manifold.

property unit

DEPRECATED - Base unit that coordinates are stored in (e.g., Meters). Deprecated in favor of origin_coords_unit and grid_spacing_unit.

class pynwb.ophys.OnePhotonSeries(name, imaging_plane, data=None, unit=None, format=None, pmt_gain=None, scan_line_rate=None, exposure_time=None, binning=None, power=None, intensity=None, external_file=None, starting_frame=None, bits_per_pixel=None, dimension=None, resolution=-1.0, conversion=1.0, timestamps=None, starting_time=None, rate=None, comments='no comments', description='no description', control=None, control_description=None, device=None, offset=0.0)[source]

Bases: ImageSeries

Image stack recorded over time from 1-photon microscope.

Parameters:
  • name (str) – The name of this TimeSeries dataset

  • imaging_plane (ImagingPlane) – Imaging plane class/pointer.

  • data (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – The data values. Can be 3D or 4D. The first dimension must be time (frame). The second and third dimensions represent x and y. The optional fourth dimension represents z. Either data or external_file must be specified (not None), but not both. If data is not specified, data will be set to an empty 3D array.

  • unit (str) – The unit of measurement of the image data, e.g., values between 0 and 255. Required when data is specified. If unit (and data) are not specified, then unit will be set to “unknown”.

  • format (str) – Format of image. Three types - 1) Image format; tiff, png, jpg, etc. 2) external 3) raw.

  • pmt_gain (float) – Photomultiplier gain.

  • scan_line_rate (float) – Lines imaged per second. This is also stored in /general/optophysiology but is kept here as it is useful information for analysis, and so good to be stored w/ the actual data.

  • exposure_time (float) – Exposure time of the sample; often the inverse of the frequency.

  • binning (int or uint) – Amount of pixels combined into ‘bins’; could be 1, 2, 4, 8, etc.

  • power (float) – Power of the excitation in mW, if known.

  • intensity (float) – Intensity of the excitation in mW/mm^2, if known.

  • external_file (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO) – Path or URL to one or more external file(s). Field only present if format=external. Either external_file or data must be specified (not None), but not both.

  • starting_frame (Iterable) – Each entry is a frame number that corresponds to the first frame of each file listed in external_file within the full ImageSeries.

  • bits_per_pixel (int) – DEPRECATED: Number of bits per image pixel

  • dimension (Iterable) – Number of pixels on x, y, (and z) axes.

  • resolution (float) – The smallest meaningful difference (in specified unit) between values in data

  • conversion (float) – Scalar to multiply each element in data to convert it to the specified unit

  • timestamps (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – Timestamps for samples stored in data

  • starting_time (float) – The timestamp of the first sample

  • rate (float) – Sampling rate in Hz

  • comments (str) – Human-readable comments about this TimeSeries dataset

  • description (str) – Description of this TimeSeries dataset

  • control (Iterable) – Numerical labels that apply to each element in data

  • control_description (Iterable) – Description of each control value

  • device (Device) – Device used to capture the images/video.

  • offset (float) – Scalar to add to each element in the data scaled by ‘conversion’ to finish converting it to the specified unit.

property binning

Amount of pixels combined into ‘bins’; could be 1, 2, 4, 8, etc.

property exposure_time

Exposure time of the sample; often the inverse of the frequency.

property imaging_plane

Imaging plane class/pointer.

property intensity

Intensity of the excitation in mW/mm^2, if known.

namespace = 'core'
neurodata_type = 'OnePhotonSeries'
property pmt_gain

Photomultiplier gain.

property power

Power of the excitation in mW, if known.

property scan_line_rate

Lines imaged per second. This is also stored in /general/optophysiology but is kept here as it is useful information for analysis, and so good to be stored w/ the actual data.

class pynwb.ophys.TwoPhotonSeries(name, imaging_plane, data=None, unit=None, format=None, field_of_view=None, pmt_gain=None, scan_line_rate=None, external_file=None, starting_frame=None, bits_per_pixel=None, dimension=None, resolution=-1.0, conversion=1.0, timestamps=None, starting_time=None, rate=None, comments='no comments', description='no description', control=None, control_description=None, device=None, offset=0.0)[source]

Bases: ImageSeries

Image stack recorded over time from 2-photon microscope.

Parameters:
  • name (str) – The name of this TimeSeries dataset

  • imaging_plane (ImagingPlane) – Imaging plane class/pointer.

  • data (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – The data values. Can be 3D or 4D. The first dimension must be time (frame). The second and third dimensions represent x and y. The optional fourth dimension represents z. Either data or external_file must be specified (not None), but not both. If data is not specified, data will be set to an empty 3D array.

  • unit (str) – The unit of measurement of the image data, e.g., values between 0 and 255. Required when data is specified. If unit (and data) are not specified, then unit will be set to “unknown”.

  • format (str) – Format of image. Three types - 1) Image format; tiff, png, jpg, etc. 2) external 3) raw.

  • field_of_view (Iterable or TimeSeries) – Width, height and depth of image, or imaged area (meters).

  • pmt_gain (float) – Photomultiplier gain.

  • scan_line_rate (float) – Lines imaged per second. This is also stored in /general/optophysiology but is kept here as it is useful information for analysis, and so good to be stored w/ the actual data.

  • external_file (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO) – Path or URL to one or more external file(s). Field only present if format=external. Either external_file or data must be specified (not None), but not both.

  • starting_frame (Iterable) – Each entry is a frame number that corresponds to the first frame of each file listed in external_file within the full ImageSeries.

  • bits_per_pixel (int) – DEPRECATED: Number of bits per image pixel

  • dimension (Iterable) – Number of pixels on x, y, (and z) axes.

  • resolution (float) – The smallest meaningful difference (in specified unit) between values in data

  • conversion (float) – Scalar to multiply each element in data to convert it to the specified unit

  • timestamps (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – Timestamps for samples stored in data

  • starting_time (float) – The timestamp of the first sample

  • rate (float) – Sampling rate in Hz

  • comments (str) – Human-readable comments about this TimeSeries dataset

  • description (str) – Description of this TimeSeries dataset

  • control (Iterable) – Numerical labels that apply to each element in data

  • control_description (Iterable) – Description of each control value

  • device (Device) – Device used to capture the images/video.

  • offset (float) – Scalar to add to each element in the data scaled by ‘conversion’ to finish converting it to the specified unit.

property field_of_view

Width, height and depth of image, or imaged area (meters).

property imaging_plane

Imaging plane class/pointer.

namespace = 'core'
neurodata_type = 'TwoPhotonSeries'
property pmt_gain

Photomultiplier gain.

property scan_line_rate

Lines imaged per second. This is also stored in /general/optophysiology but is kept here as it is useful information for analysis, and so good to be stored w/ the actual data.

class pynwb.ophys.CorrectedImageStack(corrected, original, xy_translation, name='CorrectedImageStack')[source]

Bases: NWBDataInterface

An image stack where all frames are shifted (registered) to a common coordinate system, to account for movement and drift between frames. Note: each frame at each point in time is assumed to be 2-D (has only x & y dimensions).

Parameters:
  • corrected (ImageSeries) – Image stack with frames shifted to the common coordinates. This must have the name “corrected”.

  • original (ImageSeries) – Link to image series that is being registered.

  • xy_translation (TimeSeries) – Stores the x,y delta necessary to align each frame to the common coordinates, for example, to align each frame to a reference image. This must have the name “xy_translation”.

  • name (str) – The name of this CorrectedImageStack container

property corrected

Image stack with frames shifted to the common coordinates. This must have the name “corrected”.

property original

Link to image series that is being registered.

property xy_translation

Stores the x,y delta necessary to align each frame to the common coordinates, for example, to align each frame to a reference image. This must have the name “xy_translation”.

namespace = 'core'
neurodata_type = 'CorrectedImageStack'
class pynwb.ophys.MotionCorrection(corrected_image_stacks={}, name='MotionCorrection')[source]

Bases: MultiContainerInterface

A collection of corrected images stacks.

Parameters:
__getitem__(name=None)

Get a CorrectedImageStack from this MotionCorrection

Parameters:

name (str) – the name of the CorrectedImageStack

Returns:

the CorrectedImageStack with the given name

Return type:

CorrectedImageStack

add_corrected_image_stack(corrected_image_stacks)

Add one or multiple CorrectedImageStack objects to this MotionCorrection

Parameters:

corrected_image_stacks (list or tuple or dict or CorrectedImageStack) – one or multiple CorrectedImageStack objects to add to this MotionCorrection

property corrected_image_stacks

a dictionary containing the CorrectedImageStack in this MotionCorrection

create_corrected_image_stack(corrected, original, xy_translation, name='CorrectedImageStack')

Create a CorrectedImageStack object and add it to this MotionCorrection

Parameters:
  • corrected (ImageSeries) – Image stack with frames shifted to the common coordinates. This must have the name “corrected”.

  • original (ImageSeries) – Link to image series that is being registered.

  • xy_translation (TimeSeries) – Stores the x,y delta necessary to align each frame to the common coordinates, for example, to align each frame to a reference image. This must have the name “xy_translation”.

  • name (str) – The name of this CorrectedImageStack container

Returns:

the CorrectedImageStack object that was created

Return type:

CorrectedImageStack

get_corrected_image_stack(name=None)

Get a CorrectedImageStack from this MotionCorrection

Parameters:

name (str) – the name of the CorrectedImageStack

Returns:

the CorrectedImageStack with the given name

Return type:

CorrectedImageStack

namespace = 'core'
neurodata_type = 'MotionCorrection'
class pynwb.ophys.PlaneSegmentation(description, imaging_plane, name=None, reference_images=None, id=None, columns=None, colnames=None)[source]

Bases: DynamicTable

Stores pixels in an image that represent different regions of interest (ROIs) or masks. All segmentation for a given imaging plane is stored together, with storage for multiple imaging planes (masks) supported. Each ROI is stored in its own subgroup, with the ROI group containing both a 2D mask and a list of pixels that make up this mask. Segments can also be used for masking neuropil. If segmentation is allowed to change with time, a new imaging plane (or module) is required and ROI names should remain consistent between them.

Parameters:
property imaging_plane

the ImagingPlane this ROI applies to

property reference_images

One or more image stacks that the masks apply to (can be oneelement stack).

add_roi(pixel_mask=None, voxel_mask=None, image_mask=None, id=None)[source]

Add a Region Of Interest (ROI) data to this

Parameters:
static pixel_to_image(pixel_mask)[source]

Converts a 2D pixel_mask of a ROI into an image_mask.

static image_to_pixel(image_mask)[source]

Converts an image_mask of a ROI into a pixel_mask

create_roi_table_region(description, region=slice(None, None, None), name='rois')[source]
Parameters:
  • description (str) – a brief description of what the region is

  • region (slice or list or tuple) – the indices of the table

  • name (str) – the name of the ROITableRegion

namespace = 'core'
neurodata_type = 'PlaneSegmentation'
class pynwb.ophys.ImageSegmentation(plane_segmentations={}, name='ImageSegmentation')[source]

Bases: MultiContainerInterface

Stores pixels in an image that represent different regions of interest (ROIs) or masks. All segmentation for a given imaging plane is stored together, with storage for multiple imaging planes (masks) supported. Each ROI is stored in its own subgroup, with the ROI group containing both a 2D mask and a list of pixels that make up this mask. Segments can also be used for masking neuropil. If segmentation is allowed to change with time, a new imaging plane (or module) is required and ROI names should remain consistent between them.

Parameters:
add_segmentation(imaging_plane, description=None, name=None)[source]
Parameters:
  • imaging_plane (ImagingPlane) – the ImagingPlane this ROI applies to

  • description (str) – Description of image plane, recording wavelength, depth, etc.

  • name (str) – name of PlaneSegmentation.

__getitem__(name=None)

Get a PlaneSegmentation from this ImageSegmentation

Parameters:

name (str) – the name of the PlaneSegmentation

Returns:

the PlaneSegmentation with the given name

Return type:

PlaneSegmentation

add_plane_segmentation(plane_segmentations)

Add one or multiple PlaneSegmentation objects to this ImageSegmentation

Parameters:

plane_segmentations (list or tuple or dict or PlaneSegmentation) – one or multiple PlaneSegmentation objects to add to this ImageSegmentation

create_plane_segmentation(description, imaging_plane, name=None, reference_images=None, id=None, columns=None, colnames=None)

Create a PlaneSegmentation object and add it to this ImageSegmentation

Parameters:
Returns:

the PlaneSegmentation object that was created

Return type:

PlaneSegmentation

get_plane_segmentation(name=None)

Get a PlaneSegmentation from this ImageSegmentation

Parameters:

name (str) – the name of the PlaneSegmentation

Returns:

the PlaneSegmentation with the given name

Return type:

PlaneSegmentation

namespace = 'core'
neurodata_type = 'ImageSegmentation'
property plane_segmentations

a dictionary containing the PlaneSegmentation in this ImageSegmentation

class pynwb.ophys.RoiResponseSeries(name, data, unit, rois, resolution=-1.0, conversion=1.0, timestamps=None, starting_time=None, rate=None, comments='no comments', description='no description', control=None, control_description=None, offset=0.0)[source]

Bases: TimeSeries

ROI responses over an imaging plane. Each column in data should correspond to the signal from one ROI.

Parameters:
  • name (str) – The name of this TimeSeries dataset

  • data (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – The data values. May be 1D or 2D. The first dimension must be time. The optional second dimension represents ROIs

  • unit (str) – The base unit of measurement (should be SI unit)

  • rois (DynamicTableRegion) – a table region corresponding to the ROIs that were used to generate this data

  • resolution (float) – The smallest meaningful difference (in specified unit) between values in data

  • conversion (float) – Scalar to multiply each element in data to convert it to the specified unit

  • timestamps (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – Timestamps for samples stored in data

  • starting_time (float) – The timestamp of the first sample

  • rate (float) – Sampling rate in Hz

  • comments (str) – Human-readable comments about this TimeSeries dataset

  • description (str) – Description of this TimeSeries dataset

  • control (Iterable) – Numerical labels that apply to each element in data

  • control_description (Iterable) – Description of each control value

  • offset (float) – Scalar to add to each element in the data scaled by ‘conversion’ to finish converting it to the specified unit.

property rois

a table region corresponding to the ROIs that were used to generate this data

namespace = 'core'
neurodata_type = 'RoiResponseSeries'
class pynwb.ophys.DfOverF(roi_response_series={}, name='DfOverF')[source]

Bases: MultiContainerInterface

dF/F information about a region of interest (ROI). Storage hierarchy of dF/F should be the same as for segmentation (ie, same names for ROIs and for image planes).

Parameters:
__getitem__(name=None)

Get a RoiResponseSeries from this DfOverF

Parameters:

name (str) – the name of the RoiResponseSeries

Returns:

the RoiResponseSeries with the given name

Return type:

RoiResponseSeries

add_roi_response_series(roi_response_series)

Add one or multiple RoiResponseSeries objects to this DfOverF

Parameters:

roi_response_series (list or tuple or dict or RoiResponseSeries) – one or multiple RoiResponseSeries objects to add to this DfOverF

create_roi_response_series(name, data, unit, rois, resolution=-1.0, conversion=1.0, timestamps=None, starting_time=None, rate=None, comments='no comments', description='no description', control=None, control_description=None, offset=0.0)

Create a RoiResponseSeries object and add it to this DfOverF

Parameters:
  • name (str) – The name of this TimeSeries dataset

  • data (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – The data values. May be 1D or 2D. The first dimension must be time. The optional second dimension represents ROIs

  • unit (str) – The base unit of measurement (should be SI unit)

  • rois (DynamicTableRegion) – a table region corresponding to the ROIs that were used to generate this data

  • resolution (float) – The smallest meaningful difference (in specified unit) between values in data

  • conversion (float) – Scalar to multiply each element in data to convert it to the specified unit

  • timestamps (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – Timestamps for samples stored in data

  • starting_time (float) – The timestamp of the first sample

  • rate (float) – Sampling rate in Hz

  • comments (str) – Human-readable comments about this TimeSeries dataset

  • description (str) – Description of this TimeSeries dataset

  • control (Iterable) – Numerical labels that apply to each element in data

  • control_description (Iterable) – Description of each control value

  • offset (float) – Scalar to add to each element in the data scaled by ‘conversion’ to finish converting it to the specified unit.

Returns:

the RoiResponseSeries object that was created

Return type:

RoiResponseSeries

get_roi_response_series(name=None)

Get a RoiResponseSeries from this DfOverF

Parameters:

name (str) – the name of the RoiResponseSeries

Returns:

the RoiResponseSeries with the given name

Return type:

RoiResponseSeries

namespace = 'core'
neurodata_type = 'DfOverF'
property roi_response_series

a dictionary containing the RoiResponseSeries in this DfOverF

class pynwb.ophys.Fluorescence(roi_response_series={}, name='Fluorescence')[source]

Bases: MultiContainerInterface

Fluorescence information about a region of interest (ROI). Storage hierarchy of fluorescence should be the same as for segmentation (ie, same names for ROIs and for image planes).

Parameters:
__getitem__(name=None)

Get a RoiResponseSeries from this Fluorescence

Parameters:

name (str) – the name of the RoiResponseSeries

Returns:

the RoiResponseSeries with the given name

Return type:

RoiResponseSeries

add_roi_response_series(roi_response_series)

Add one or multiple RoiResponseSeries objects to this Fluorescence

Parameters:

roi_response_series (list or tuple or dict or RoiResponseSeries) – one or multiple RoiResponseSeries objects to add to this Fluorescence

create_roi_response_series(name, data, unit, rois, resolution=-1.0, conversion=1.0, timestamps=None, starting_time=None, rate=None, comments='no comments', description='no description', control=None, control_description=None, offset=0.0)

Create a RoiResponseSeries object and add it to this Fluorescence

Parameters:
  • name (str) – The name of this TimeSeries dataset

  • data (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – The data values. May be 1D or 2D. The first dimension must be time. The optional second dimension represents ROIs

  • unit (str) – The base unit of measurement (should be SI unit)

  • rois (DynamicTableRegion) – a table region corresponding to the ROIs that were used to generate this data

  • resolution (float) – The smallest meaningful difference (in specified unit) between values in data

  • conversion (float) – Scalar to multiply each element in data to convert it to the specified unit

  • timestamps (ndarray or list or tuple or Dataset or Array or StrDataset or HDMFDataset or AbstractDataChunkIterator or DataIO or TimeSeries) – Timestamps for samples stored in data

  • starting_time (float) – The timestamp of the first sample

  • rate (float) – Sampling rate in Hz

  • comments (str) – Human-readable comments about this TimeSeries dataset

  • description (str) – Description of this TimeSeries dataset

  • control (Iterable) – Numerical labels that apply to each element in data

  • control_description (Iterable) – Description of each control value

  • offset (float) – Scalar to add to each element in the data scaled by ‘conversion’ to finish converting it to the specified unit.

Returns:

the RoiResponseSeries object that was created

Return type:

RoiResponseSeries

get_roi_response_series(name=None)

Get a RoiResponseSeries from this Fluorescence

Parameters:

name (str) – the name of the RoiResponseSeries

Returns:

the RoiResponseSeries with the given name

Return type:

RoiResponseSeries

namespace = 'core'
neurodata_type = 'Fluorescence'
property roi_response_series

a dictionary containing the RoiResponseSeries in this Fluorescence