pynwb.ophys module

class pynwb.ophys.OpticalChannel(name, source, description, emission_lambda, parent=None)

Bases: pynwb.core.NWBContainer

Parameters:
  • name (str) – the name of this electrode
  • source (str) – the source of the data
  • description (str) – Any notes or comments about the channel.
  • emission_lambda (float) – Emission lambda for channel.
  • parent (NWBContainer) – The parent NWBContainer for this NWBContainer
description

Any notes or comments about the channel.

emission_lambda

Emission lambda for channel.

namespace = 'core'
neurodata_type = 'OpticalChannel'
class pynwb.ophys.ImagingPlane(name, source, optical_channel, description, device, excitation_lambda, imaging_rate, indicator, location, manifold=None, conversion=None, unit=None, reference_frame=None, parent=None)

Bases: pynwb.core.NWBContainer

Parameters:
  • name (str) – the name of this electrode
  • source (str) – the source of the data
  • optical_channel (list or OpticalChannel) – One of possibly many groups storing channelspecific data.
  • description (str) – Description of this ImagingPlane.
  • device (str) – Name of device in /general/devices
  • excitation_lambda (float) – Excitation wavelength.
  • imaging_rate (str) – Rate images are acquired, in Hz.
  • indicator (str) – Calcium indicator
  • location (str) – Location of image plane.
  • manifold (Iterable) – Physical position of each pixel. height, weight, xyz.
  • conversion (float) – Multiplier to get from stored values to specified unit (e.g., 1e-3 for millimeters)
  • unit (str) – Base unit that coordinates are stored in (e.g., Meters).
  • reference_frame (str) – Describes position and reference frame of manifold based on position of first element in manifold.
  • parent (NWBContainer) – The parent NWBContainer for this NWBContainer
optical_channel

One of possibly many groups storing channelspecific data.

description

Description of this ImagingPlane.

device

Name of device in /general/devices

excitation_lambda

Excitation wavelength.

imaging_rate

Rate images are acquired, in Hz.

indicator

Calcium indicator

location

Location of image plane.

manifold

Physical position of each pixel. height, weight, xyz.

conversion

Multiplier to get from stored values to specified unit (e.g., 1e-3 for millimeters)

unit

Base unit that coordinates are stored in (e.g., Meters).

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, source, 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=[nan], resolution=0.0, conversion=1.0, timestamps=None, starting_time=None, rate=None, comments='no comments', description='no description', control=None, control_description=None, parent=None)

Bases: pynwb.image.ImageSeries

A special case of optical imaging.

Parameters:
  • name (str) – The name of this TimeSeries dataset
  • source (str) – Name of TimeSeries or Modules that serve as the source for the data contained here. It can also be the name of a device, for stimulus or acquisition data
  • imaging_plane (ImagingPlane) – Imaging plane class/pointer.
  • data (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset or TimeSeries) – The data this TimeSeries dataset stores. Can also store binary data e.g. image frames
  • 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 (Iterable) – 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.
  • bits_per_pixel (int) – Number of bit 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 by to conver to volts
  • timestamps (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset 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
  • parent (NWBContainer) – The parent NWBContainer for this NWBContainer
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(source, corrected, original, xy_translation, name='CorrectedImageStack')

Bases: pynwb.core.NWBContainer

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:
  • source (str) – the source of the data
  • 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(source, corrected_images_stacks={}, name='MotionCorrection')

Bases: pynwb.core.MultiContainerInterface

A collection of corrected images stacks.

Parameters:
  • source (str) – the source of the data
  • corrected_images_stacks (list or tuple or dict or CorrectedImageStack) – CorrectedImageStack to store in this interface
  • name (str) – the name of this container
__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 container

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

Create a CorrectedImageStack and add it to this MotionCorrection

Parameters:
  • source (str) – the source of the data
  • 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.ROITable(name='rois', data=[])

Bases: pynwb.core.NWBTable

Parameters:
  • name (str) – the name of this table
  • data (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset) – the data in this table
add_row(name, pixel_mask, image_mask)
Parameters:
  • name (str) – None
  • pixel_mask (RegionSlicer) – None
  • image_mask (RegionSlicer) – None
namespace = 'core'
neurodata_type = 'ROITable'
class pynwb.ophys.ROITableRegion(table, region, description, name='electrodes')

Bases: pynwb.core.NWBTableRegion

A subsetting of an ElectrodeTable

Parameters:
  • table (ROITable) – the ElectrodeTable this region applies to
  • region (slice or list or tuple or RegionReference) – the indices of the table
  • description (str) – a brief description of what this electrode is
  • name (str) – the name of this container
description

a brief description of what this electrode is

namespace = 'core'
neurodata_type = 'ROITableRegion'
class pynwb.ophys.PixelMasks(data, name='pixel_masks', parent=None, container_source=None)

Bases: pynwb.core.VectorData

Parameters:
  • data (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset) – the pixel mask data
  • name (str) – the name of this container
  • parent (NWBContainer) – the parent Container for this Container
  • container_source (object) – the source of this Container e.g. file name
namespace = 'core'
neurodata_type = 'PixelMasks'
class pynwb.ophys.ImageMasks(data, name='image_masks', parent=None, container_source=None)

Bases: pynwb.core.NWBData

Parameters:
  • data (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset) – the image mask data
  • name (str) – the name of this container
  • parent (NWBContainer) – the parent Container for this Container
  • container_source (object) – the source of this Container e.g. file name
namespace = 'core'
neurodata_type = 'ImageMasks'
class pynwb.ophys.PlaneSegmentation(source, description, imaging_plane, name=None, reference_images=None, rois=None, pixel_masks=[], image_masks=[])

Bases: pynwb.core.NWBContainer

Image segmentation of a specific imaging plane

Parameters:
  • source (str) – the source of the data
  • description (str) – Description of image plane, recording wavelength, depth, etc.
  • imaging_plane (ImagingPlane) – the ImagingPlane this ROI applies to
  • name (str) – name of PlaneSegmentation.
  • reference_images (ImageSeries or list or dict or tuple) – One or more image stacks that the masks apply to (can be oneelement stack).
  • rois (ROITable) – the table holding references to pixel and image masks
  • pixel_masks (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset or PixelMasks) – a concatenated list of pixel masks for all ROIs stored in this PlaneSegmenation
  • image_masks (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or ImageMasks) – an image mask for each ROI in this PlaneSegmentation
description

Description of image plane, recording wavelength, depth, etc.

imaging_plane

the ImagingPlane this ROI applies to

reference_images

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

pixel_masks

a concatenated list of pixel masks for all ROIs stored in this PlaneSegmenation

image_masks

an image mask for each ROI in this PlaneSegmentation

rois

the table holding references to pixel and image masks

add_roi(name, pixel_mask, image_mask)
Parameters:
  • name (str) – None
  • pixel_mask (ndarray or list or tuple or Dataset or AbstractDataChunkIterator) – the index of the ROI in roi_ids to retrieve the pixel mask for
  • image_mask (ndarray or list or tuple or Dataset or AbstractDataChunkIterator) – the index of the ROI in roi_ids to retrieve the pixel mask for
get_pixel_mask(index)
Parameters:index (int) – the index of the ROI to retrieve the pixel mask for
get_image_mask(index)
Parameters:index (int) – the index of the ROI to retrieve the image mask for
create_roi_table_region(description, names=None, region=None, name='rois')
Parameters:
  • description (str) – a brief description of what this electrode is
  • names (list or tuple) – the names of the ROIs
  • region (slice or list or tuple or RegionReference) – the indices of the table
  • name (str) – the name of the ROITableRegion
namespace = 'core'
neurodata_type = 'PlaneSegmentation'
class pynwb.ophys.ImageSegmentation(source, plane_segmentations={}, name='ImageSegmentation')

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:
  • source (str) – the source of the data
  • plane_segmentations (list or tuple or dict or PlaneSegmentation) – PlaneSegmentation to store in this interface
  • name (str) – the name of this container
add_segmentation(imaging_plane, description=None, source=None, name=None)
Parameters:
  • imaging_plane (ImagingPlane) – the ImagingPlane this ROI applies to
  • description (str) – Description of image plane, recording wavelength, depth, etc.
  • source (str) – the source of the data
  • 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(source, description, imaging_plane, name=None, reference_images=None, rois=None, pixel_masks=[], image_masks=[])

Create a PlaneSegmentation and add it to this ImageSegmentation

Parameters:
  • source (str) – the source of the data
  • description (str) – Description of image plane, recording wavelength, depth, etc.
  • imaging_plane (ImagingPlane) – the ImagingPlane this ROI applies to
  • name (str) – name of PlaneSegmentation.
  • reference_images (ImageSeries or list or dict or tuple) – One or more image stacks that the masks apply to (can be oneelement stack).
  • rois (ROITable) – the table holding references to pixel and image masks
  • pixel_masks (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset or PixelMasks) – a concatenated list of pixel masks for all ROIs stored in this PlaneSegmenation
  • image_masks (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or ImageMasks) – an image mask for each ROI in this PlaneSegmentation
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 container

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

Bases: pynwb.base.TimeSeries

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

Parameters:
  • name (str) – The name of this TimeSeries dataset
  • source (str) – Name of TimeSeries or Modules that serve as the source for the data contained here. It can also be the name of a device, for stimulus or acquisition data
  • data (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset or TimeSeries) – The data this TimeSeries dataset stores. Can also store binary data e.g. image frames
  • unit (str) – The base unit of measurement (should be SI unit)
  • rois (ROITableRegion) – 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 by to conver to volts
  • timestamps (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset 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
  • parent (NWBContainer) – The parent NWBContainer for this NWBContainer
rois

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

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

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:
  • source (str) – the source of the data
  • roi_response_series (list or tuple or dict or RoiResponseSeries) – RoiResponseSeries to store in this interface
  • name (str) – the name of this container
__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, source, data, unit, rois, resolution=0.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
  • source (str) – Name of TimeSeries or Modules that serve as the source for the data contained here. It can also be the name of a device, for stimulus or acquisition data
  • data (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset or TimeSeries) – The data this TimeSeries dataset stores. Can also store binary data e.g. image frames
  • unit (str) – The base unit of measurement (should be SI unit)
  • rois (ROITableRegion) – 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 by to conver to volts
  • timestamps (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset 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 container

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

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:
  • source (str) – the source of the data
  • roi_response_series (list or tuple or dict or RoiResponseSeries) – RoiResponseSeries to store in this interface
  • name (str) – the name of this container
__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, source, data, unit, rois, resolution=0.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
  • source (str) – Name of TimeSeries or Modules that serve as the source for the data contained here. It can also be the name of a device, for stimulus or acquisition data
  • data (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset or TimeSeries) – The data this TimeSeries dataset stores. Can also store binary data e.g. image frames
  • unit (str) – The base unit of measurement (should be SI unit)
  • rois (ROITableRegion) – 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 by to conver to volts
  • timestamps (ndarray or list or tuple or Dataset or AbstractDataChunkIterator or DataIO or FORMDataset 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 container