pynwb.ophys module

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

Bases: pynwb.core.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.
description

Any notes or comments about the channel.

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: pynwb.core.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 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 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 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’.
optical_channel

One of possibly many groups storing channel-specific data.

description

Description of this ImagingPlane.

device

the device that was used to record

excitation_lambda

Excitation wavelength in nm.

imaging_rate

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

indicator

Calcium indicator

location

Location of image plane.

manifold

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

Type:DEPRECATED
conversion

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

Type:DEPRECATED
unit

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

Type:DEPRECATED
reference_frame

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

namespace = 'core'
neurodata_type = 'ImagingPlane'
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=[0], 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)[source]

Bases: pynwb.image.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 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.
  • unit (str) – The base unit of measurement (should be SI unit)
  • 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 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, but not both.
  • starting_frame (Iterable) – Each entry is the frame number in the corresponding external_file variable. This serves as an index to what frames each file contains. If external_file is not provided, then this value will be None
  • bits_per_pixel (int) – DEPRECATED: Number of bits per image pixel
  • dimension (Iterable) – Number of pixels on x, y, (and z) axes.
  • resolution (str or float) – The smallest meaningful difference (in specified unit) between values in data
  • conversion (str or float) – Scalar to multiply each element in data to convert it to the specified unit
  • timestamps (ndarray or list or tuple or Dataset 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
field_of_view

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

imaging_plane

Imaging plane class/pointer.

pmt_gain

Photomultiplier gain.

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.

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

Bases: pynwb.core.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.
  • 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.
  • name (str) – The name of this CorrectedImageStack container
corrected

Image stack with frames shifted to the common coordinates.

original

Link to image series that is being registered.

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.

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

Bases: pynwb.core.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_images_stacks)

Add a CorrectedImageStack to this MotionCorrection

Parameters:corrected_images_stacks (list or tuple or dict or CorrectedImageStack) – the CorrectedImageStack to add
corrected_images_stacks

a dictionary containing the CorrectedImageStack in this MotionCorrection

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

Create a CorrectedImageStack and add it to this MotionCorrection

Parameters:
  • corrected (ImageSeries) – Image stack with frames shifted to the common coordinates.
  • 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.
  • 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: hdmf.common.table.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:
imaging_plane

the ImagingPlane this ROI applies to

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: pynwb.core.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 a PlaneSegmentation to this ImageSegmentation

Parameters:plane_segmentations (list or tuple or dict or PlaneSegmentation) – the PlaneSegmentation to add
create_plane_segmentation(description, imaging_plane, name=None, reference_images=None, id=None, columns=None, colnames=None)

Create a PlaneSegmentation 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'
plane_segmentations

a dictionary containing the PlaneSegmentation in this ImageSegmentation

class pynwb.ophys.RoiResponseSeries(name, data, rois, unit=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)[source]

Bases: pynwb.base.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 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
  • rois (DynamicTableRegion) – a table region corresponding to the ROIs that were used to generate this data
  • unit (str) – The base unit of measurement (should be SI unit)
  • resolution (str or float) – The smallest meaningful difference (in specified unit) between values in data
  • conversion (str or float) – Scalar to multiply each element in data to convert it to the specified unit
  • timestamps (ndarray or list or tuple or Dataset 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
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: pynwb.core.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 a RoiResponseSeries to this DfOverF

Parameters:roi_response_series (list or tuple or dict or RoiResponseSeries) – the RoiResponseSeries to add
create_roi_response_series(name, data, rois, unit=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)

Create a RoiResponseSeries and add it to this DfOverF

Parameters:
  • name (str) – The name of this TimeSeries dataset
  • data (ndarray or list or tuple or Dataset 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
  • rois (DynamicTableRegion) – a table region corresponding to the ROIs that were used to generate this data
  • unit (str) – The base unit of measurement (should be SI unit)
  • resolution (str or float) – The smallest meaningful difference (in specified unit) between values in data
  • conversion (str or float) – Scalar to multiply each element in data to convert it to the specified unit
  • timestamps (ndarray or list or tuple or Dataset 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
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'
roi_response_series

a dictionary containing the RoiResponseSeries in this DfOverF

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

Bases: pynwb.core.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 a RoiResponseSeries to this Fluorescence

Parameters:roi_response_series (list or tuple or dict or RoiResponseSeries) – the RoiResponseSeries to add
create_roi_response_series(name, data, rois, unit=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)

Create a RoiResponseSeries and add it to this Fluorescence

Parameters:
  • name (str) – The name of this TimeSeries dataset
  • data (ndarray or list or tuple or Dataset 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
  • rois (DynamicTableRegion) – a table region corresponding to the ROIs that were used to generate this data
  • unit (str) – The base unit of measurement (should be SI unit)
  • resolution (str or float) – The smallest meaningful difference (in specified unit) between values in data
  • conversion (str or float) – Scalar to multiply each element in data to convert it to the specified unit
  • timestamps (ndarray or list or tuple or Dataset 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
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'
roi_response_series

a dictionary containing the RoiResponseSeries in this Fluorescence