pynwb.file module

class pynwb.file.Image

Bases: pynwb.form.container.Container

class pynwb.file.SpecFile

Bases: pynwb.form.container.Container

class pynwb.file.NWBFile(source, session_description, identifier, session_start_time, file_create_date=None, version=None, experimenter=None, experiment_description=None, session_id=None, institution=None, lab=None, acquisition=None, stimulus=None, stimulus_template=None, epochs=None, modules=None, ec_electrodes=None, ec_electrode_groups=None, ic_electrodes=None, imaging_planes=None, optogenetic_sites=None, devices=None)

Bases: pynwb.core.NWBContainer

A representation of an NWB file.

Parameters:
  • source (str) – the source of the data
  • session_description (str) – a description of the session where this data was generated
  • identifier (str) – a unique text identifier for the file
  • session_start_time (datetime or str) – the start time of the recording session
  • file_create_date (list or datetime or str) – the time the file was created and subsequent modifications made
  • version (str) – the NWB version
  • experimenter (str) – name of person who performed experiment
  • experiment_description (str) – general description of the experiment
  • session_id (str) – lab-specific ID for the session
  • institution (str) – institution(s) where experiment is performed
  • lab (str) – lab where experiment was performed
  • acquisition (list or tuple) – Raw TimeSeries objects belonging to this NWBFile
  • stimulus (list or tuple) – Stimulus TimeSeries objects belonging to this NWBFile
  • stimulus_template (list or tuple) – Stimulus template TimeSeries objects belonging to this NWBFile
  • epochs (list or tuple) – Epoch objects belonging to this NWBFile
  • modules (list or tuple) – ProcessingModule objects belonging to this NWBFile
  • ec_electrodes (ElectrodeTable or Iterable) – the ElectrodeTable that belongs to this NWBFile
  • ec_electrode_groups (Iterable) – the ElectrodeGroups that belong to this NWBFile
  • ic_electrodes (list or tuple) – IntracellularElectrodes that belong to this NWBFile
  • imaging_planes (list or tuple) – ImagingPlanes that belong to this NWBFile
  • optogenetic_sites (list or tuple) – OptogeneticStimulusSites that belong to this NWBFile
  • devices (list or tuple) – Device objects belonging to this NWBFile
classmethod set_version(version)
devices
epochs
epoch_tags
modules
identifier
nwb_version
session_description
file_create_date
session_start_time
acquisition
stimulus
stimulus_template
ec_electrodes
add_electrode(id, x, y, z, imp, location, filtering, description, group)
Parameters:
  • id (int) – a unique identifier for the electrode
  • x (float) – the x coordinate of the position
  • y (float) – the y coordinate of the position
  • z (float) – the z coordinate of the position
  • imp (float) – the impedance of the electrode
  • location (str) – the location of electrode within the subject e.g. brain region
  • filtering (str) – description of hardware filtering
  • description (str) – a brief description of what this electrode is
  • group (ElectrodeGroup) – the ElectrodeGroup object to add to this NWBFile
ec_electrode_groups
ic_electrodes
imaging_planes
create_imaging_plane(name, source, optical_channel, description, device, excitation_lambda, imaging_rate, indicator, location, manifold=None, conversion=None, unit=None, reference_frame=None)

Add metadata about an imaging plane

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 (str) – 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, x, y, z.
  • 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.
Returns:

the imaging plane

Return type:

ImagingPlane

set_imaging_plane(imaging_plane)

Add an ImagingPlane object to this file

Parameters:imaging_plane (ImagingPlane) – the ImagingPlane object to add to this NWBFile
get_imaging_plane(name)

Get an ImagingPlane object from this file

Parameters:name (str) – the name of the imaging plane
is_acquisition(ts)
is_stimulus(ts)
is_stimulus_template(ts)
create_epoch(name, source, start, stop, tags=[], description=None)
Creates a new Epoch object. Epochs are used to track intervals
in an experiment, such as exposure to a certain type of stimuli (an interval where orientation gratings are shown, or of sparse noise) or a different paradigm (a rat exploring an enclosure versus sleeping between explorations)
Parameters:
  • name (str) – the name of the epoch, as it will appear in the file
  • source (str) – the source of the data
  • start (float) – the starting time of the epoch
  • stop (float) – the ending time of the epoch
  • tags (tuple or list) – tags for this epoch
  • description (str) – a description of this epoch
get_epoch(name)
set_epoch_timeseries(epoch, timeseries)

Add one or more TimSeries datasets to one or more Epochs

Parameters:
  • epoch (str or Epoch or list or tuple) – the name of an epoch or an Epoch object or a list of names of epochs or Epoch objects
  • timeseries (str or TimeSeries or list or tuple) – the name of a timeseries or a TimeSeries object or a list of names of timeseries or TimeSeries objects
add_acquisition(ts, epoch=None)
Parameters:
  • ts (TimeSeries) – the TimeSeries object to add
  • epoch (str or Epoch or list or tuple) – the name of an epoch or an Epoch object or a list of names of epochs or Epoch objects
get_acquisition(name)

Retrieve acquisition TimeSeries data

Parameters:name (str) – the name of this TimeSeries
add_stimulus(ts, epoch=None)
Parameters:
  • ts (TimeSeries) – the TimeSeries object to add
  • epoch (str or Epoch) – the name of an epoch or an Epoch object or a list of names of epochs or Epoch objects
get_stimulus(name)

Retrieve stimiulus TimeSeries data

Parameters:name (str) – the name of this TimeSeries
add_stimulus_template(ts, epoch=None)
Parameters:
  • ts (TimeSeries) – the TimeSeries object to add
  • epoch (str or Epoch) – the name of an epoch or an Epoch object or a list of names of epochs or Epoch objects
get_stimulus_template(name)

Retrieve stimiulus template TimeSeries data

Parameters:name (str) – the name of this TimeSeries
create_electrode_group(name, source, description, location, device)

Add an electrode group (e.g. a probe, shank, tetrode).

Parameters:
  • name (str) – the name of this electrode
  • source (str) – the source of the data
  • description (str) – description of this electrode group
  • location (str) – description of location of this electrode group
  • device (Device) – the device that was used to record from this electrode group
Returns:

the electrode group

Return type:

ElectrodeGroup

set_electrode_group(electrode_grp)
Parameters:electrode_grp (ElectrodeGroup) – the ElectrodeGroup object to add to this NWBFile
set_electrode_table(electrode_table)
Parameters:electrode_table (ElectrodeTable) – the ElectrodeTable for this file
create_device(name, source)
Parameters:
  • name (str) – the name of this device
  • source (str) – the source of the data
Returns:

the recording device

Return type:

Device

set_device(device)
Parameters:device (Device) – the Device object to add to this NWBFile
get_electrode_group(name)
Parameters:name (str) – the name of the electrode group
create_intracellular_electrode(name, source, slice, seal, description, location, resistance, filtering, initial_access_resistance, device)
Parameters:
  • name (str) – the name of this electrode
  • source (str) – the source of the data
  • slice (str) – Information about slice used for recording.
  • seal (str) – Information about seal used for recording.
  • description (str) – Recording description, description of electrode (e.g., whole-cell, sharp, etc) COMMENT: Free-form text (can be from Methods)
  • location (str) – Area, layer, comments on estimation, stereotaxis coordinates (if in vivo, etc).
  • resistance (str) – Electrode resistance COMMENT: unit: Ohm.
  • filtering (str) – Electrode specific filtering.
  • initial_access_resistance (str) – Initial access resistance.
  • device (str) – Name(s) of devices in general/devices.
Returns:

the intracellular electrode

Return type:

IntracellularElectrode

description
experiment_description
experimenter
institution
lab
optogenetic_sites
session_id
set_intracellular_electrode(ic_elec)
Parameters:ic_elec (IntracellularElectrode) – the IntracellularElectrode object to add to this NWBFile
get_intracellular_electrode(name)

Retrieve an IntracellularElectrode

Parameters:name (str) – the name of the intracellular electrode
create_processing_module(name, source, description)
Creates a ProcessingModule object of the specified name. NWBContainers can
be created by the module and will be stored inside it
Parameters:
  • name (str) – the name of the processing module
  • source (str) – the source of the data
  • description (str) – description of the processing module
Returns:

a processing module

Return type:

ProcessingModule

set_processing_module(module)

Add a ProcessingModule to this NWBFile

Parameters:module (ProcessingModule) – the processing module to add to this file
get_processing_module(name)

Retrieve a ProcessingModule

Parameters:name (str) – the name of the processing module