pynwb.image module

Module for image data in NWB files.

This module provides classes for storing and manipulating image data in NWB files. The following classes are available:

  • ImageSeries: General image data that is common between acquisition and stimulus time series

  • IndexSeries: Stores indices to image frames stored in an ImageSeries

  • OpticalSeries: Image data that is presented or recorded

  • GrayscaleImage: Single-channel (grayscale) image data

  • RGBImage: Three-channel (RGB) image data

  • RGBAImage: Four-channel (RGBA) image data with transparency

  • Images: Container for storing a collection of images (imported from pynwb.base)

  • Image: Base class for image data (imported from pynwb.base)

Note: While the Image and Images classes are defined in pynwb.base, they can be imported directly from this module:

from pynwb.image import Image, Images
class pynwb.image.ImageSeries(name, data=None, unit=None, format=None, external_file=None, starting_frame=None, num_samples=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, offset=0.0, device=None)[source]

Bases: TimeSeries

General image data that is common between acquisition and stimulus time series. The image data can be stored in the HDF5 file or it will be stored as an external image file.

Parameters:
DEFAULT_DATA = array([], shape=(0, 0, 0), dtype=uint8)
property num_samples

Tries to return the number of data samples. If this cannot be assessed, returns None.

property bits_per_pixel
property device

Device used to capture the images/video.

property dimension

Number of pixels on x, y, (and z) axes.

property external_file

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.

property format

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

namespace = 'core'
neurodata_type = 'ImageSeries'
property starting_frame

Each entry is a frame number that corresponds to the first frame of each file listed in external_file within the full ImageSeries.

class pynwb.image.IndexSeries(name, data, unit, indexed_timeseries=None, indexed_images=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, offset=0.0)[source]

Bases: TimeSeries

Stores indices to image frames stored in an ImageSeries. The purpose of the IndexSeries is to allow a static image stack to be stored somewhere, and the images in the stack to be referenced out-of-order. This can be for the display of individual images, or of movie segments (as a movie is simply a series of images). The data field stores the index of the frame in the referenced ImageSeries, and the timestamps array indicates when that image was displayed.

Parameters:
property indexed_timeseries

Link to TimeSeries containing images that are indexed.

property indexed_images

Link to Images object containing an ordered set of images that are indexed. The Images object must contain a ‘ordered_images’ dataset specifying the order of the images in the Images type.

namespace = 'core'
neurodata_type = 'IndexSeries'
class pynwb.image.ImageMaskSeries(name, masked_imageseries, data=None, unit=None, format=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, offset=0.0, device=None)[source]

Bases: ImageSeries

DEPRECATED as of NWB 2.8.0 and PyNWB 3.0.0. An alpha mask that is applied to a presented visual stimulus. The data[] array contains an array of mask values that are applied to the displayed image. Mask values are stored as RGBA. Mask can vary with time. The timestamps array indicates the starting time of a mask, and that mask pattern continues until it’s explicitly changed.

Parameters:
property masked_imageseries

Link to ImageSeries that mask is applied to.

namespace = 'core'
neurodata_type = 'ImageMaskSeries'
class pynwb.image.OpticalSeries(name, distance=None, field_of_view=None, orientation=None, data=None, unit=None, format=None, external_file=None, starting_frame=None, num_samples=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 data that is presented or recorded. A stimulus template movie will be stored only as an image. When the image is presented as stimulus, additional data is required, such as field of view (eg, how much of the visual field the image covers, or how what is the area of the target being imaged). If the OpticalSeries represents acquired imaging data, orientation is also important.

Parameters:
property distance

Distance from camera/monitor to target/eye.

property field_of_view

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

property orientation

Description of image relative to some reference frame (e.g., which way is up). Must also specify frame of reference.

namespace = 'core'
neurodata_type = 'OpticalSeries'
class pynwb.image.GrayscaleImage(name, data, resolution=None, description=None)[source]

Bases: Image

Parameters:
namespace = 'core'
neurodata_type = 'GrayscaleImage'
class pynwb.image.RGBImage(name, data, resolution=None, description=None)[source]

Bases: Image

Parameters:
namespace = 'core'
neurodata_type = 'RGBImage'
class pynwb.image.RGBAImage(name, data, resolution=None, description=None)[source]

Bases: Image

Parameters:
namespace = 'core'
neurodata_type = 'RGBAImage'