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: -
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
orOpticalChannel
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
) – 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'¶
- name (
-
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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
orTimeSeries
) – 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
orTimeSeries
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
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'¶
- name (
-
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'¶
- corrected (
-
class
pynwb.ophys.
MotionCorrection
(corrected_images_stacks={}, name='MotionCorrection')[source]¶ Bases:
pynwb.core.MultiContainerInterface
A collection of corrected images stacks.
Parameters: - corrected_images_stacks (
list
ortuple
ordict
orCorrectedImageStack
) – 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 CorrectedImageStackReturns: 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
ortuple
ordict
orCorrectedImageStack
) – 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: - corrected (
-
get_corrected_image_stack
(name=None)¶ Get a CorrectedImageStack from this MotionCorrection
Parameters: name ( str
) – the name of the CorrectedImageStackReturns: the CorrectedImageStack with the given name Return type: CorrectedImageStack
-
namespace
= 'core'¶
-
neurodata_type
= 'MotionCorrection'¶
- corrected_images_stacks (
-
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: - 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
orlist
ordict
ortuple
) – One or more image stacks that the masks apply to (can be oneelement stack). - id (
ndarray
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
orElementIdentifiers
) – the identifiers for this table - columns (
tuple
orlist
) – the columns in this table - colnames (
ndarray
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
) – the ordered names of the columns in this table. columns must also be provided.
-
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: - pixel_mask (
ndarray
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
) – pixel mask for 2D ROIs: [(x1, y1, weight1), (x2, y2, weight2), …] - voxel_mask (
ndarray
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
) – voxel mask for 3D ROIs: [(x1, y1, z1, weight1), (x2, y2, z2, weight2), …] - image_mask (
ndarray
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
) – image with the same size of image where positive values mark this ROI - id (
int
) – the ID for the ROI
- pixel_mask (
-
create_roi_table_region
(description, region=slice(None, None, None), name='rois')[source]¶ Parameters:
-
namespace
= 'core'¶
-
neurodata_type
= 'PlaneSegmentation'¶
- description (
-
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: - plane_segmentations (
list
ortuple
ordict
orPlaneSegmentation
) – PlaneSegmentation to store in this interface - name (
str
) – the name of this container
-
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.
- imaging_plane (
-
__getitem__
(name=None)¶ Get a PlaneSegmentation from this ImageSegmentation
Parameters: name ( str
) – the name of the PlaneSegmentationReturns: the PlaneSegmentation with the given name Return type: PlaneSegmentation
-
add_plane_segmentation
(plane_segmentations)¶ Add a PlaneSegmentation to this ImageSegmentation
Parameters: plane_segmentations ( list
ortuple
ordict
orPlaneSegmentation
) – 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: - 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
orlist
ordict
ortuple
) – One or more image stacks that the masks apply to (can be oneelement stack). - id (
ndarray
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
orElementIdentifiers
) – the identifiers for this table - columns (
tuple
orlist
) – the columns in this table - colnames (
ndarray
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
) – the ordered names of the columns in this table. columns must also be provided.
Returns: the PlaneSegmentation object that was created
Return type: - description (
-
get_plane_segmentation
(name=None)¶ Get a PlaneSegmentation from this ImageSegmentation
Parameters: name ( str
) – the name of the PlaneSegmentationReturns: the PlaneSegmentation with the given name Return type: PlaneSegmentation
-
namespace
= 'core'¶
-
neurodata_type
= 'ImageSegmentation'¶
-
plane_segmentations
¶ a dictionary containing the PlaneSegmentation in this ImageSegmentation
- plane_segmentations (
-
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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
orTimeSeries
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
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'¶
- name (
-
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: - roi_response_series (
list
ortuple
ordict
orRoiResponseSeries
) – 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 RoiResponseSeriesReturns: 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
ortuple
ordict
orRoiResponseSeries
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
orTimeSeries
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
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: - name (
-
get_roi_response_series
(name=None)¶ Get a RoiResponseSeries from this DfOverF
Parameters: name ( str
) – the name of the RoiResponseSeriesReturns: 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
- roi_response_series (
-
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: - roi_response_series (
list
ortuple
ordict
orRoiResponseSeries
) – 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 RoiResponseSeriesReturns: 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
ortuple
ordict
orRoiResponseSeries
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
orTimeSeries
) – 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
orlist
ortuple
orDataset
orHDMFDataset
orAbstractDataChunkIterator
orDataIO
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: - name (
-
get_roi_response_series
(name=None)¶ Get a RoiResponseSeries from this Fluorescence
Parameters: name ( str
) – the name of the RoiResponseSeriesReturns: 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
- roi_response_series (