Status: The changes from this extension have been integrated with NWB and are part of then NWB 2.4 release. Use of this extension is deprecated.
Overview: This extension implements the icephys extension proposal described here. The extension is intended to evaluate and explore the practical use of the proposed changes as well as to provide a reference implementation with the goal to ease integration of the proposed changes with NWB.
python setup.py develop
The extension is now also available on pip and can be installed via:
pip install ndx-icephys-meta
The extension is also listed in the (NDX catalog)[https://nwb-extensions.github.io/]. See here for the catalog metadata record.
cd docs
make html
This generates the specification docs directly from the YAML specifciation in the spec
folder. The generated docs are stored in /docs/build
python src/pynwb/ndx_icephys_meta/test/test_icephys.py
spec/
: YAML specification of the extensiondocs/
: Sources for building the specification docs from the YAML specsrc/spec/create_extension_spec.py
: Python source file for creating the specificationsrc/pynwb/
: Sources for Python extensions and examplesndx_icephys_meta
: Python package with extensions to PyNWB for read/write of extension datandx_icephys_meta/test
: Unit test for the Python extensionndx_icephys_meta/icephys.py
: PyNWB Container classesndx_icephys_meta/io/icephys.py
: PyNWB ObjectMapper classesexamples
: Examples illustrating the use of the extension in Python
Examples for the Python extension are available at src/pynwb/examples
. The unit tests in src/pynwb/ndx_icephys_meta/test
can also serve as additional examples.
The following shows a simple example. The steps with (A) - (E) in the comments are the main new steps for this extension. The other parts of the code are standard NWB code.
from datetime import datetime
from dateutil.tz import tzlocal
import numpy as np
from pynwb.icephys import VoltageClampStimulusSeries, VoltageClampSeries
from pynwb import NWBHDF5IO
from ndx_icephys_meta.icephys import ICEphysFile # Import the extension
# Create an ICEphysFile
nwbfile = ICEphysFile(session_description='my first recording',
identifier='EXAMPLE_ID',
session_start_time=datetime.now(tzlocal()))
# Add a device
device = nwbfile.create_device(name='Heka ITC-1600')
# Add an intracellular electrode
electrode = nwbfile.create_ic_electrode(name="elec0",
description='a mock intracellular electrode',
device=device)
# Create an ic-ephys stimulus
stimulus = VoltageClampStimulusSeries(
name="stimulus",
data=[1, 2, 3, 4, 5],
starting_time=123.6,
rate=10e3,
electrode=electrode,
gain=0.02)
# Create an ic-response
response = VoltageClampSeries(
name='response',
data=[0.1, 0.2, 0.3, 0.4, 0.5],
conversion=1e-12,
resolution=np.nan,
starting_time=123.6,
rate=20e3,
electrode=electrode,
gain=0.02,
capacitance_slow=100e-12,
resistance_comp_correction=70.0)
# (A) Add an intracellular recording to the file
ir_index = nwbfile.add_intracellular_recording(electrode=electrode,
stimulus=stimulus,
response=response)
# (B) Add a list of sweeps to the sweeps table
sweep_index = nwbfile.add_ic_sweep(recordings=[ir_index, ])
# (C) Add a list of sweep table indices as a sweep sequence
sequence_index = nwbfile.add_ic_sweep_sequence(sweeps=[sweep_index, ])
# (D) Add a list of sweep sequence table indices as a run
run_index = nwbfile.add_ic_run(sweep_sequences=[sequence_index, ])
# (E) Add a list of run table indices as a condition
nwbfile.add_ic_condition(runs=[run_index, ])
# Write our test file
testpath = "test_icephys_file.h5"
with NWBHDF5IO(testpath, 'w') as io:
io.write(nwbfile)
# Read the data back in
with NWBHDF5IO(testpath, 'r') as io:
infile = io.read()
print(infile)