pynwb.file module

class pynwb.file.LabMetaData(name)[source]

Bases: pynwb.core.NWBContainer

Parameters:name (str) – name of metadata
namespace = 'core'
neurodata_type = 'LabMetaData'
class pynwb.file.Subject(age=None, description=None, genotype=None, sex=None, species=None, subject_id=None, weight=None, date_of_birth=None)[source]

Bases: pynwb.core.NWBContainer

Parameters:
  • age (str) – the age of the subject
  • description (str) – a description of the subject
  • genotype (str) – the genotype of the subject
  • sex (str) – the sex of the subject
  • species (str) – the species of the subject
  • subject_id (str) – a unique identifier for the subject
  • weight (str) – the weight of the subject
  • date_of_birth (datetime) – datetime of date of birth. May be supplied instead of age.
age

the age of the subject

description

a description of the subject

genotype

the genotype of the subject

sex

the sex of the subject

species

the species of the subject

subject_id

a unique identifier for the subject

weight

the weight of the subject

date_of_birth

datetime of date of birth. May be supplied instead of age.

namespace = 'core'
neurodata_type = 'Subject'
class pynwb.file.NWBFile(session_description, identifier, session_start_time, file_create_date=None, timestamps_reference_time=None, experimenter=None, experiment_description=None, session_id=None, institution=None, keywords=None, notes=None, pharmacology=None, protocol=None, related_publications=None, slices=None, source_script=None, source_script_file_name=None, data_collection=None, surgery=None, virus=None, stimulus_notes=None, lab=None, acquisition=None, analysis=None, stimulus=None, stimulus_template=None, epochs=None, epoch_tags=set(), trials=None, invalid_times=None, intervals=None, units=None, processing=None, lab_meta_data=None, electrodes=None, electrode_groups=None, ic_electrodes=None, sweep_table=None, imaging_planes=None, ogen_sites=None, devices=None, subject=None, scratch=None, icephys_electrodes=None)[source]

Bases: pynwb.core.MultiContainerInterface

A representation of an NWB file.

Parameters:
  • 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) – the start date and time of the recording session
  • file_create_date (ndarray or list or tuple or Dataset or HDMFDataset or AbstractDataChunkIterator or datetime) – the date and time the file was created and subsequent modifications made
  • timestamps_reference_time (datetime) – date and time corresponding to time zero of all timestamps; defaults to value of session_start_time
  • experimenter (tuple or list or 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
  • keywords (ndarray or list or tuple or Dataset or HDMFDataset or AbstractDataChunkIterator) – Terms to search over
  • notes (str) – Notes about the experiment.
  • pharmacology (str) – Description of drugs used, including how and when they were administered. Anesthesia(s), painkiller(s), etc., plus dosage, concentration, etc.
  • protocol (str) – Experimental protocol, if applicable. E.g., include IACUC protocol
  • related_publications (tuple or list or str) – Publication information.PMID, DOI, URL, etc. If multiple, concatenate together and describe which is which. such as PMID, DOI, URL, etc
  • slices (str) – Description of slices, including information about preparation thickness, orientation, temperature and bath solution
  • source_script (str) – Script file used to create this NWB file.
  • source_script_file_name (str) – Name of the source_script file
  • data_collection (str) – Notes about data collection and analysis.
  • surgery (str) – Narrative description about surgery/surgeries, including date(s) and who performed surgery.
  • virus (str) – Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.
  • stimulus_notes (str) – Notes about stimuli, such as how and where presented.
  • lab (str) – lab where experiment was performed
  • acquisition (list or tuple) – Raw TimeSeries objects belonging to this NWBFile
  • analysis (list or tuple) – result of analysis
  • 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 (TimeIntervals) – Epoch objects belonging to this NWBFile
  • epoch_tags (tuple or list or set) – A sorted list of tags used across all epochs
  • trials (TimeIntervals) – A table containing trial data
  • invalid_times (TimeIntervals) – A table containing times to be omitted from analysis
  • intervals (list or tuple) – any TimeIntervals tables storing time intervals
  • units (Units) – A table containing unit metadata
  • processing (list or tuple) – ProcessingModule objects belonging to this NWBFile
  • lab_meta_data (list or tuple) – an extension that contains lab-specific meta-data
  • electrodes (DynamicTable) – the ElectrodeTable that belongs to this NWBFile
  • electrode_groups (Iterable) – the ElectrodeGroups that belong to this NWBFile
  • ic_electrodes (list or tuple) – DEPRECATED use icephys_electrodes parameter instead. IntracellularElectrodes that belong to this NWBFile
  • sweep_table (SweepTable) – the SweepTable that belong to this NWBFile
  • imaging_planes (list or tuple) – ImagingPlanes that belong to this NWBFile
  • ogen_sites (list or tuple) – OptogeneticStimulusSites that belong to this NWBFile
  • devices (list or tuple) – Device objects belonging to this NWBFile
  • subject (Subject) – subject metadata
  • scratch (list or tuple) – scratch data
  • icephys_electrodes (list or tuple) – IntracellularElectrodes that belong to this NWBFile.
all_children()[source]
objects
modules
ec_electrode_groups
ec_electrodes
ic_electrodes
add_ic_electrode(*args, **kwargs)[source]

This method is deprecated and will be removed in future versions. Please use add_icephys_electrode instead

create_ic_electrode(*args, **kwargs)[source]

This method is deprecated and will be removed in future versions. Please use create_icephys_electrode instead

get_ic_electrode(*args, **kwargs)[source]

This method is deprecated and will be removed in future versions. Please use get_icephys_electrode instead

add_epoch_column(name, description, data=[], table=False, index=False, vocab=False)[source]
Add a column to the electrode table.
See add_column for more details
Parameters:
add_epoch_metadata_column(*args, **kwargs)[source]

This method is deprecated and will be removed in future versions. Please use add_epoch_column instead

add_epoch(start_time, stop_time, tags=None, timeseries=None)[source]
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:
  • start_time (float) – Start time of epoch, in seconds
  • stop_time (float) – Stop time of epoch, in seconds
  • tags (str or list or tuple) – user-defined tags used throughout time intervals
  • timeseries (list or tuple or TimeSeries) – the TimeSeries this epoch applies to
add_electrode_column(name, description, data=[], table=False, index=False, vocab=False)[source]
Add a column to the electrode table.
See add_column for more details
Parameters:
add_electrode(x, y, z, imp, location, filtering, group, id=None, rel_x=None, rel_y=None, rel_z=None, reference=None)[source]
Add an electrode to the electrodes table.

See add_row for more details.

Required fields are x, y, z, imp, location, filtering, group and any columns that have been added (through calls to add_electrode_columns).

Parameters:
  • x (float) – the x coordinate of the position (+x is posterior)
  • y (float) – the y coordinate of the position (+y is inferior)
  • z (float) – the z coordinate of the position (+z is right)
  • imp (float) – the impedance of the electrode, in ohms
  • location (str) – the location of electrode within the subject e.g. brain region
  • filtering (str) – description of hardware filtering, including the filter name and frequency cutoffs
  • group (ElectrodeGroup) – the ElectrodeGroup object to add to this NWBFile
  • id (int) – a unique identifier for the electrode
  • rel_x (float) – the x coordinate within the electrode group
  • rel_y (float) – the y coordinate within the electrode group
  • rel_z (float) – the z coordinate within the electrode group
  • reference (str) – Description of the reference used for this electrode.
create_electrode_table_region(region, description, name='electrodes')[source]
Parameters:
  • region (slice or list or tuple) – the indices of the table
  • description (str) – a brief description of what this electrode is
  • name (str) – the name of this container
add_unit_column(name, description, data=[], table=False, index=False, vocab=False)[source]
Add a column to the unit table.
See add_column for more details
Parameters:
add_unit(spike_times=None, obs_intervals=None, electrodes=None, electrode_group=None, waveform_mean=None, waveform_sd=None, id=None)[source]
Add a unit to the unit table.
See add_row for more details.
Parameters:
add_trial_column(name, description, data=[], table=False, index=False, vocab=False)[source]
Add a column to the trial table.
See add_column for more details
Parameters:
add_trial(start_time, stop_time, tags=None, timeseries=None)[source]
Add a trial to the trial table.

See add_interval for more details.

Required fields are start_time, stop_time, and any columns that have been added (through calls to add_trial_columns).

Parameters:
  • start_time (float) – Start time of epoch, in seconds
  • stop_time (float) – Stop time of epoch, in seconds
  • tags (str or list or tuple) – user-defined tags used throughout time intervals
  • timeseries (list or tuple or TimeSeries) – the TimeSeries this epoch applies to
add_invalid_times_column(name, description, data=[], table=False, index=False, vocab=False)[source]
Add a column to the trial table.
See add_column for more details
Parameters:
add_invalid_time_interval(**kwargs)[source]

Add a trial to the trial table. See add_row for more details.

Required fields are start_time, stop_time, and any columns that have been added (through calls to add_invalid_times_columns).

set_electrode_table(electrode_table)[source]

Set the electrode table of this NWBFile to an existing ElectrodeTable

Parameters:electrode_table (DynamicTable) – the ElectrodeTable for this file
add_acquisition(nwbdata)[source]
Parameters:nwbdata (NWBDataInterface or DynamicTable) – None
add_stimulus(timeseries)[source]
Parameters:timeseries (TimeSeries) – None
add_stimulus_template(timeseries)[source]
Parameters:timeseries (TimeSeries) – None
add_scratch(data, name=None, notes=None, table_description='')[source]

Add data to the scratch space

Parameters:
get_scratch(name, convert=True)[source]

Get data from the scratch space

Parameters:
  • name (str) – None
  • convert (bool) – None
copy()[source]

Shallow copy of an NWB file. Useful for linking across files.

acquisition

a dictionary containing the NWBDataInterface or DynamicTable in this NWBFile

add_analysis(analysis)

Add a NWBContainer to this NWBFile

Parameters:analysis (list or tuple or dict or NWBContainer or DynamicTable) – the NWBContainer or DynamicTable to add
add_device(devices)

Add a Device to this NWBFile

Parameters:devices (list or tuple or dict or Device) – the Device to add
add_electrode_group(electrode_groups)

Add an ElectrodeGroup to this NWBFile

Parameters:electrode_groups (list or tuple or dict or ElectrodeGroup) – the ElectrodeGroup to add
add_icephys_electrode(icephys_electrodes)

Add an IntracellularElectrode to this NWBFile

Parameters:icephys_electrodes (list or tuple or dict or IntracellularElectrode) – the IntracellularElectrode to add
add_imaging_plane(imaging_planes)

Add an ImagingPlane to this NWBFile

Parameters:imaging_planes (list or tuple or dict or ImagingPlane) – the ImagingPlane to add
add_lab_meta_data(lab_meta_data)

Add a LabMetaData to this NWBFile

Parameters:lab_meta_data (list or tuple or dict or LabMetaData) – the LabMetaData to add
add_ogen_site(ogen_sites)

Add an OptogeneticStimulusSite to this NWBFile

Parameters:ogen_sites (list or tuple or dict or OptogeneticStimulusSite) – the OptogeneticStimulusSite to add
add_processing_module(processing)

Add a ProcessingModule to this NWBFile

Parameters:processing (list or tuple or dict or ProcessingModule) – the ProcessingModule to add
add_time_intervals(intervals)

Add a TimeIntervals to this NWBFile

Parameters:intervals (list or tuple or dict or TimeIntervals) – the TimeIntervals to add
analysis

a dictionary containing the NWBContainer or DynamicTable in this NWBFile

create_device(name, description=None, manufacturer=None)

Create a Device and add it to this NWBFile

Parameters:
  • name (str) – the name of this device
  • description (str) – Description of the device (e.g., model, firmware version, processing software version, etc.)
  • manufacturer (str) – the name of the manufacturer of this device
Returns:

the Device object that was created

Return type:

Device

create_electrode_group(name, description, location, device, position=None)

Create an ElectrodeGroup and add it to this NWBFile

Parameters:
  • name (str) – the name of this electrode
  • 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
  • position (ndarray or list or tuple or Dataset or HDMFDataset or AbstractDataChunkIterator) – stereotaxic position of this electrode group (x, y, z)
Returns:

the ElectrodeGroup object that was created

Return type:

ElectrodeGroup

create_icephys_electrode(name, device, description, slice=None, seal=None, location=None, resistance=None, filtering=None, initial_access_resistance=None)

Create an IntracellularElectrode and add it to this NWBFile

Parameters:
  • name (str) – the name of this electrode
  • device (Device) – the device that was used to record from this electrode
  • description (str) – Recording description, description of electrode (e.g., whole-cell, sharp, etc) COMMENT: Free-form text (can be from Methods)
  • slice (str) – Information about slice used for recording.
  • seal (str) – Information about seal used for recording.
  • 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.
Returns:

the IntracellularElectrode object that was created

Return type:

IntracellularElectrode

create_imaging_plane(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')

Create an ImagingPlane and add it to this NWBFile

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’.
Returns:

the ImagingPlane object that was created

Return type:

ImagingPlane

create_lab_meta_data(name)

Create a LabMetaData and add it to this NWBFile

Parameters:name (str) – name of metadata
Returns:the LabMetaData object that was created
Return type:LabMetaData
create_ogen_site(name, device, description, excitation_lambda, location)

Create an OptogeneticStimulusSite and add it to this NWBFile

Parameters:
  • name (str) – The name of this stimulus site
  • device (Device) – the device that was used
  • description (str) – Description of site.
  • excitation_lambda (float) – Excitation wavelength in nm.
  • location (str) – Location of stimulation site.
Returns:

the OptogeneticStimulusSite object that was created

Return type:

OptogeneticStimulusSite

create_processing_module(name, description, data_interfaces=None)

Create a ProcessingModule and add it to this NWBFile

Parameters:
  • name (str) – The name of this processing module
  • description (str) – Description of this processing module
  • data_interfaces (list or tuple or dict) – NWBDataInterfacess that belong to this ProcessingModule
Returns:

the ProcessingModule object that was created

Return type:

ProcessingModule

create_time_intervals(name, description='experimental intervals', id=None, columns=None, colnames=None)

Create a TimeIntervals and add it to this NWBFile

Parameters:
Returns:

the TimeIntervals object that was created

Return type:

TimeIntervals

data_collection

Notes about data collection and analysis.

devices

a dictionary containing the Device in this NWBFile

electrode_groups

a dictionary containing the ElectrodeGroup in this NWBFile

electrodes

the ElectrodeTable that belongs to this NWBFile

epoch_tags

A sorted list of tags used across all epochs

epochs

Epoch objects belonging to this NWBFile

experiment_description

general description of the experiment

experimenter

name of person who performed experiment

file_create_date

the date and time the file was created and subsequent modifications made

get_acquisition(name=None)

Get a NWBDataInterface from this NWBFile

Parameters:name (str) – the name of the NWBDataInterface or DynamicTable
Returns:the NWBDataInterface or DynamicTable with the given name
Return type:(<class ‘pynwb.core.NWBDataInterface’>, <class ‘hdmf.common.table.DynamicTable’>)
get_analysis(name=None)

Get a NWBContainer from this NWBFile

Parameters:name (str) – the name of the NWBContainer or DynamicTable
Returns:the NWBContainer or DynamicTable with the given name
Return type:(<class ‘pynwb.core.NWBContainer’>, <class ‘hdmf.common.table.DynamicTable’>)
get_device(name=None)

Get a Device from this NWBFile

Parameters:name (str) – the name of the Device
Returns:the Device with the given name
Return type:Device
get_electrode_group(name=None)

Get an ElectrodeGroup from this NWBFile

Parameters:name (str) – the name of the ElectrodeGroup
Returns:the ElectrodeGroup with the given name
Return type:ElectrodeGroup
get_icephys_electrode(name=None)

Get an IntracellularElectrode from this NWBFile

Parameters:name (str) – the name of the IntracellularElectrode
Returns:the IntracellularElectrode with the given name
Return type:IntracellularElectrode
get_imaging_plane(name=None)

Get an ImagingPlane from this NWBFile

Parameters:name (str) – the name of the ImagingPlane
Returns:the ImagingPlane with the given name
Return type:ImagingPlane
get_lab_meta_data(name=None)

Get a LabMetaData from this NWBFile

Parameters:name (str) – the name of the LabMetaData
Returns:the LabMetaData with the given name
Return type:LabMetaData
get_ogen_site(name=None)

Get an OptogeneticStimulusSite from this NWBFile

Parameters:name (str) – the name of the OptogeneticStimulusSite
Returns:the OptogeneticStimulusSite with the given name
Return type:OptogeneticStimulusSite
get_processing_module(name=None)

Get a ProcessingModule from this NWBFile

Parameters:name (str) – the name of the ProcessingModule
Returns:the ProcessingModule with the given name
Return type:ProcessingModule
get_stimulus(name=None)

Get a TimeSeries from this NWBFile

Parameters:name (str) – the name of the TimeSeries
Returns:the TimeSeries with the given name
Return type:TimeSeries
get_stimulus_template(name=None)

Get a TimeSeries from this NWBFile

Parameters:name (str) – the name of the TimeSeries
Returns:the TimeSeries with the given name
Return type:TimeSeries
get_time_intervals(name=None)

Get a TimeIntervals from this NWBFile

Parameters:name (str) – the name of the TimeIntervals
Returns:the TimeIntervals with the given name
Return type:TimeIntervals
icephys_electrodes

a dictionary containing the IntracellularElectrode in this NWBFile

identifier

a unique text identifier for the file

imaging_planes

a dictionary containing the ImagingPlane in this NWBFile

institution

institution(s) where experiment is performed

intervals

a dictionary containing the TimeIntervals in this NWBFile

invalid_times

A table containing times to be omitted from analysis

keywords

Terms to search over

lab

lab where experiment was performed

lab_meta_data

a dictionary containing the LabMetaData in this NWBFile

namespace = 'core'
neurodata_type = 'NWBFile'
notes

Notes about the experiment.

ogen_sites

a dictionary containing the OptogeneticStimulusSite in this NWBFile

pharmacology

Description of drugs used, including how and when they were administered. Anesthesia(s), painkiller(s), etc., plus dosage, concentration, etc.

processing

a dictionary containing the ProcessingModule in this NWBFile

protocol

Experimental protocol, if applicable. E.g., include IACUC protocol

related_publications

Publication information.PMID, DOI, URL, etc. If multiple, concatenate together and describe which is which. such as PMID, DOI, URL, etc

scratch

a dictionary containing the DynamicTable, NWBContainer, or ScratchData in this NWBFile

session_description

a description of the session where this data was generated

session_id

lab-specific ID for the session

session_start_time

the start date and time of the recording session

slices

Description of slices, including information about preparation thickness, orientation, temperature and bath solution

source_script

Script file used to create this NWB file.

source_script_file_name

Name of the source_script file

stimulus

a dictionary containing the TimeSeries in this NWBFile

stimulus_notes

Notes about stimuli, such as how and where presented.

stimulus_template

a dictionary containing the TimeSeries in this NWBFile

subject

subject metadata

surgery

Narrative description about surgery/surgeries, including date(s) and who performed surgery.

sweep_table

the SweepTable that belong to this NWBFile

timestamps_reference_time

date and time corresponding to time zero of all timestamps; defaults to value of session_start_time

trials

A table containing trial data

units

A table containing unit metadata

virus

Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.

pynwb.file.ElectrodeTable(name='electrodes', description='metadata about extracellular electrodes')[source]
pynwb.file.TrialTable(name='trials', description='metadata about experimental trials')[source]
pynwb.file.InvalidTimesTable(name='invalid_times', description='time intervals to be removed from analysis')[source]