NWB Export Mapping
This page documents how Synaptipy maps electrophysiology data to the
Neurodata Without Borders (NWB) 2.x format when
exporting via File - Export to NWB or the NWBExporter API.
Important
The NWB exporter writes voltage/current traces, electrode metadata, session
information, stimulus waveforms (3-step fallback), NWB 2.x icephys sweep
grouping tables, and embedded analysis results via a ProcessingModule.
See Container Mapping and
Limitations and Future Work for details.
Container Mapping
Synaptipy Concept |
NWB Container |
Notes |
|---|---|---|
Recording session |
|
Top-level container with session metadata |
Amplifier |
|
Name, description, manufacturer from dialog |
Per-channel electrode |
|
One per channel; linked to Device |
Voltage trace (CC mode) |
|
Selected when channel units are mV or V |
Current trace (VC mode) |
|
Selected when channel units are pA, nA, or A |
Unknown clamp mode |
|
Fallback when units are unrecognised |
Animal metadata |
|
Optional; populated from the export dialog |
Command waveform (raw) |
|
Attempt 1: digitized from |
Command waveform (synthetic) |
|
Attempt 2: reconstructed from ABF epoch metadata; description notes “Synthetic stimulus array reconstructed from protocol metadata.” |
Missing command waveform |
(none) |
Attempt 3: |
Sweep-level linkage |
|
Response + stimulus series linked per trial |
Simultaneous recording group |
|
One row per (electrode, trial) pair |
Sequential recording group |
|
Groups trials by |
Discrete event arrays |
|
Spike times / synaptic event times from batch-engine |
Series Class Selection
The exporter inspects the units attribute on each channel to determine the appropriate NWB series class:
Channel Units |
Interpreted Clamp Mode |
NWB Series Class |
|---|---|---|
|
Current-clamp (records voltage) |
|
|
Current-clamp |
|
|
Voltage-clamp (records current) |
|
|
Voltage-clamp |
|
|
Voltage-clamp |
|
Other / unknown |
Unknown |
|
SI Unit Conversion
NWB best practices require data in SI base units. Synaptipy and Neo typically store data in millivolts (mV) or picoamperes (pA). The exporter converts automatically:
Original Unit |
SI Unit |
Conversion Factor |
Stored in NWB |
|---|---|---|---|
mV |
V (volts) |
\(\times 10^{-3}\) |
|
V |
V |
\(\times 1\) |
|
pA |
A (amperes) |
\(\times 10^{-12}\) |
|
nA |
A |
\(\times 10^{-9}\) |
|
A |
A |
\(\times 1\) |
|
The conversion field is written to the NWB file so that downstream tools
can recover the original units if needed.
Electrode Metadata
Each channel is associated with an IntracellularElectrode object. The
following metadata fields are populated from the NWB Export Dialog or from
channel attributes:
Field |
Source |
Default |
|---|---|---|
|
Dialog or |
|
|
Dialog or |
|
|
Dialog or |
|
|
Linked |
- |
Session Metadata
The NWBFile top-level container is populated from the export dialog:
NWB Field |
Dialog Tab |
Required |
|---|---|---|
|
Session |
Yes |
|
Session (auto-generated UUID) |
Yes |
|
Session |
Yes (timezone-aware) |
|
Session |
No |
|
Session |
No |
|
Session |
No |
|
Session |
No |
If the session_start_time is timezone-naive, Synaptipy localises it to
the system timezone (via tzlocal) or falls back to UTC.
Subject Metadata
Populated from the Subject tab in the export dialog:
NWB Field |
Type |
Notes |
|---|---|---|
|
string |
Required to create Subject object |
|
string |
e.g. |
|
string |
ISO 8601 duration, e.g. |
|
string |
|
|
string |
Optional |
|
string |
Optional |
|
string |
Optional |
Sweep Organisation
Each trial within a channel is stored as a separate PatchClampSeries
(or subclass) with a unique sweep_number (np.uint64). The naming
convention is:
{channel_name}_trial_{index:03d}
For example, Vm_trial_000, Vm_trial_001, etc.
Each trial is also linked via the NWB 2.x icephys hierarchy:
IntracellularRecordingsTable- one row per trial; binds the response series to its electrode and (when available) its stimulus series.SimultaneousRecordingsTable- one row per (electrode, trial) pair; groups simultaneous multi-channel recordings.SequentialRecordingsTable- groups simultaneous recordings bystimulus_type("current_clamp"or"voltage_clamp").
Limitations and Future Work
Stimulus data - A 3-step fallback is applied per trial: (1) raw digitized command waveform; (2) synthetic step waveform from ABF epoch metadata; (3)
stimulus=Nonewith a warning in the response description. Non-ABF formats without command channel support will always fall through to Attempt 3.Embedded scalar analysis - Scalar results (Rin, tau, etc.) are exported to CSV/JSON but not yet embedded in the NWB
ProcessingModule. Only discrete event arrays (spike times, synaptic event times) from the batch engine_raw_arrayssub-dict are currently written asDynamicTablerows.RepetitionsTable / ExperimentalConditionsTable - Higher-level NWB icephys grouping tables are not yet populated.
Per-Analysis-Module PyNWB Class Mapping
The table below documents which PyNWB classes are used for each of the 15 analysis modules. The Trace export column reflects the class used when writing raw data. The Analysis NWB object column shows implemented export (marked ✓) or the planned container for future embedding.
# |
Analysis Module |
Registry Name |
Trace Export Class |
Analysis NWB Object |
|---|---|---|---|---|
1 |
Baseline / RMP |
|
|
|
2 |
Input Resistance (Rin) |
|
|
|
3 |
Membrane Time Constant (Tau) |
|
|
|
4 |
Sag Ratio (Ih) |
|
|
|
5 |
Capacitance (Cm) |
|
|
|
6 |
Spike Detection |
|
|
|
7 |
Single-Spike Features |
|
|
|
8 |
Paired-Pulse Ratio (PPR) |
|
|
|
9 |
Event Detection |
|
|
✓ |
10 |
I-V Curve |
|
|
|
11 |
Burst Analysis |
|
|
|
12 |
F-I Curve / Excitability |
|
|
|
13 |
Phase Plane |
|
|
|
14 |
Spike Train Dynamics |
|
|
|
15 |
Optogenetic Synchronisation |
|
|
|
Notes on icephys best-practice containers
IntracellularRecordingsTable, SimultaneousRecordingsTable, and
SequentialRecordingsTable are implemented and populated for every
exported trial. The higher-level RepetitionsTable and
ExperimentalConditionsTable are not yet populated.
The relevant PyNWB classes in use:
pynwb.icephys.IntracellularRecordingsTablepynwb.icephys.SimultaneousRecordingsTablepynwb.icephys.SequentialRecordingsTable
Spike times and synaptic event times will be stored in pynwb.misc.Units
(planned); currently they are written as HDMF DynamicTable rows inside a
ProcessingModule named "analysis".
Programmatic Usage
from Synaptipy.infrastructure.exporters.nwb_exporter import NWBExporter
exporter = NWBExporter()
exporter.export(
recording=my_recording,
output_path=Path("output.nwb"),
session_metadata={
"session_description": "Whole-cell patch-clamp recording",
"identifier": str(uuid.uuid4()),
"session_start_time": datetime.now(timezone.utc),
"experimenter": "J. Smith",
},
)