NWB Export Mapping
This page documents how Synaptipy maps electrophysiology data to the
Neurodata Without Borders (NWB) 2.x format when
exporting via the Exporter tab or the NWBExporter API
(src/synaptipy/infrastructure/exporters/nwb_exporter.py).
Important
The NWB exporter writes pre-scaled SI voltage and current traces, electrode and
device metadata, required MINDS/DANDI subject and session records, session
provenance notes (temperature, liquid junction potential, digital filter
parameters), stimulus waveforms (3-step fallback including ABF step and linear
ramp reconstruction), NWB 2.x intracellular sweep grouping tables, and embedded
analysis and preprocessing DynamicTable containers under /processing.
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 and provenance |
Amplifier |
|
Required |
Per-channel electrode |
|
One per channel ( |
Voltage trace (CC mode) |
|
Selected when channel units are |
Current trace (VC mode) |
|
Selected when channel units are |
Unknown clamp mode |
|
Fallback when channel units are unrecognised |
Animal metadata |
|
Required |
Command waveform (raw) |
|
Attempt 1: digitized command array from |
Command waveform (synthetic) |
|
Attempt 2: step ( |
Missing command waveform |
(none) |
Attempt 3: |
Sweep-level linkage |
|
Response + stimulus series linked per trial |
Simultaneous recording group |
|
One row per |
Sequential recording group |
|
Groups trials by |
Embedded scalar metrics |
|
|
Discrete event arrays |
|
|
Preprocessing audit trail |
|
|
Series Class Selection
The exporter inspects the units attribute on each Channel (case-insensitive)
to determine the appropriate NWB series class:
Channel Units |
Interpreted Clamp Mode |
NWB Series Class |
|---|---|---|
|
Current-clamp (records voltage) |
|
|
Current-clamp (records voltage) |
|
|
Current-clamp |
|
|
Voltage-clamp (records current) |
|
|
Voltage-clamp |
|
|
Voltage-clamp |
|
|
Voltage-clamp |
|
Other / unknown |
Unknown |
|
SI Unit Conversion
NWB and DANDI best practices require data arrays to be stored directly in SI
base units (volts or amperes). NWBExporter pre-scales each trial array to
64-bit floating-point SI values prior to writing and sets conversion=1.0 on
every exported series so that value_SI = data * conversion is exact and never
double-scaled by downstream NWB, DANDI, or Neo readers:
Original Channel Unit |
Pre-Scale Multiplier Applied to |
Stored NWB |
Stored NWB |
|---|---|---|---|
|
\(\times 10^{-6}\) |
|
|
|
\(\times 10^{-3}\) |
|
|
|
\(\times 1\) |
|
|
|
\(\times 10^{-12}\) |
|
|
|
\(\times 10^{-9}\) |
|
|
|
\(\times 10^{-6}\) |
|
|
|
\(\times 1\) |
|
|
Unrecognised |
\(\times 1\) (unmodified) |
Original unit string |
|
Stimulus waveforms (_make_stim_series) apply the same SI pre-scaling (mV ->
1e-3 "volts", nA -> 1e-9 "amperes", pA -> 1e-12 "amperes").
Electrode Metadata
Each channel is associated with an IntracellularElectrode object named
electrode_{chan_id}. Fields are populated from channel attributes or fallback
defaults in session_metadata:
Field |
Source |
Default |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
Linked |
- |
|
|
Omitted when |
|
|
Omitted when |
resistance and seal are written as strings in the units stored by the
acquisition software (e.g., "10 MOhm", "5 GOhm"). These fields are omitted
when the corresponding channel attribute is None.
Session, Device, and Provenance Metadata
NWBExporter.export() validates five mandatory MINDS/DANDI fields before
creating the NWBFile, raising ValueError if any is missing or empty:
Metadata Key |
NWB Target |
Required |
Notes / Fallback |
|---|---|---|---|
|
|
Yes ( |
Protocol or experiment summary |
|
|
Yes ( |
Unique session UUID string |
|
|
Yes ( |
|
|
|
Yes ( |
Can also be passed via |
|
|
Yes ( |
Can also be passed via |
|
|
No |
Defaults to |
|
|
No |
Defaults to |
|
|
No |
Optional |
|
|
No |
Optional |
|
|
No |
Optional |
|
|
No |
Optional |
Session notes Provenance
NWBFile.notes combines any user-supplied notes string with structured
acquisition and preprocessing provenance lines:
Original file: <source_file_name>Imported protocol label: <imported_protocol_label>(when present onRecording)Recording temperature: <temp> degC (account for Q10 kinetic scaling when comparing across preparations)(resolved fromsession_metadata["recording_temperature"],recording.recording_temperature, orrecording.metadata["recording_temperature"], defaulting to22.0degC)Liquid junction potential (mV): <ljp_mv>(whenliquid_junction_potential_mvis present insession_metadataorrecording.metadata)Digital filter provenance: <filter_params>(whensession_metadata["filter_params"]is supplied)
Subject Metadata
Populated from session_metadata (and the Subject tab in the NWB Export
Dialog):
NWB Field |
Metadata Key |
Required |
Notes |
|---|---|---|---|
|
|
Yes ( |
Unique animal/specimen identifier |
|
|
No |
Defaults to |
|
|
No |
ISO 8601 duration, e.g. |
|
|
No |
|
|
|
No |
Optional |
|
|
No |
Optional |
|
|
No |
Optional |
Sweep Organisation and Stimulus Reconstruction
Each trial within a channel is stored as a separate PatchClampSeries
subclass with a unique sweep_number (np.uint64). Response and stimulus
series follow the naming conventions:
{channel_name}_trial_{index:03d}
{channel_name}_stim_trial_{index:03d} # raw digitized command
{channel_name}_stim_trial_{index:03d}_synth # reconstructed from ABF epochs
Stimulus resolution uses a 3-step per-trial fallback:
Attempt 1 (raw command): Digitized command waveform from
channel.current_data_trials[trial_idx].Attempt 2 (ABF epoch synthesis): Reconstructs both step (
nEpochType == 1) and linear ramp (nEpochType == 2, vianumpy.linspacefrom the preceding epoch level to the target level, incorporating per-sweep level incrementsfEpochLevelInc, duration incrementslEpochDurationInc,abf_holding_level, andabf_pre_epoch_samples) command waveforms fromrecording.metadata["abf_epochs"]. The series description records"Synthetic stimulus array reconstructed from protocol metadata."Attempt 3 (unavailable): Sets
stimulus=Noneand appends"WARNING: No stimulus waveform captured during acquisition; command waveform is unavailable."to the response series description.
Each trial is linked through the NWB 2.x intracellular electrophysiology table hierarchy:
IntracellularRecordingsTable- one row per trial binding the response series, electrode, and (when available) stimulus series.SimultaneousRecordingsTable- one row per(electrode, trial)pair.SequentialRecordingsTable- groups simultaneous recordings withstimulus_type("current_clamp","voltage_clamp", or"unknown").
Embedded Analysis and Preprocessing Containers (/processing)
When HDMF is installed (included with PyNWB), NWBExporter writes two
dedicated ProcessingModule containers under nwbfile.processing:
NWBFile
processing
analysis (ProcessingModule - populated when analysis_results is provided)
scalar_metrics (DynamicTable)
channel : string - channel identifier or name
analysis : string - registry analysis identifier
metric : string - scalar metric key
value : float64 - finite numeric metric value
{channel}_{analysis}[_{n}] (DynamicTable - when _raw_arrays["event_times"] exists)
time_s : float64 - discrete event or spike timestamp (s)
amplitude : float64 - event amplitude in channel units (optional)
preprocessing (ProcessingModule - populated when recording.metadata["processing_history"] exists)
preprocessing_steps (DynamicTable)
timestamp : string - ISO 8601 timestamp when the step was applied
operation : string - operation name (e.g. "lowpass", "baseline_subtract")
parameters : string - JSON-encoded parameter dictionary
After writing the file to disk, NWBExporter runs pynwb.validate in read
mode and logs any DANDI-compliance warnings without aborting the export.
Limitations and Future Work
Non-ABF synthetic stimulus reconstruction - Formats other than ABF that lack a digitized command channel fall through to Attempt 3 (
stimulus=Nonewith an explicit warning in the response description).Continuous fit curves and
Unitstable -/processing/analysisembeds all finite scalar metrics inscalar_metricsand discrete event arrays from_raw_arrays["event_times"]asDynamicTableobjects; continuous 10-50 kHz fitted overlay curves (such as_fit_values) are excluded to avoid file bloat, and migration of spike times to the top-levelpynwb.misc.Unitstable is planned for a future release.RepetitionsTable/ExperimentalConditionsTable- Higher-level NWB icephys grouping tables aboveSequentialRecordingsTableare not yet populated.
Per-Analysis-Module PyNWB Class Mapping
The table below lists all 16 built-in leaf analysis routines across Synaptipy’s
five core pillars, the acquisition series class used for raw trace export, and
the implemented /processing/analysis containers written when batch results
are passed via analysis_results.
# |
Pillar |
Analysis Routine |
Registry Name |
Trace Export Class |
|
|---|---|---|---|---|---|
1 |
Intrinsic Properties |
Baseline (RMP) |
|
|
|
2 |
Intrinsic Properties |
Input Resistance |
|
|
|
3 |
Intrinsic Properties |
Tau (Time Constant) |
|
|
|
4 |
Intrinsic Properties |
Sag Ratio (Ih) |
|
|
|
5 |
Intrinsic Properties |
I-V Curve |
|
|
|
6 |
Intrinsic Properties |
Capacitance |
|
|
|
7 |
Spike Analysis |
Spike Detection |
|
|
|
8 |
Spike Analysis |
Phase Plane |
|
|
|
9 |
Excitability |
Excitability (F-I Curve) |
|
|
|
10 |
Excitability |
Burst Analysis |
|
|
|
11 |
Excitability |
Spike Train Dynamics |
|
|
|
12 |
Synaptic Events |
Event (Amplitude) |
|
|
|
13 |
Synaptic Events |
Event (Template) |
|
|
|
14 |
Evoked Responses |
Evoked Sync |
|
|
|
15 |
Evoked Responses |
Paired-Pulse Ratio |
|
|
|
16 |
Evoked Responses |
Stimulus Train (STP) |
|
|
|
Programmatic Usage
from datetime import datetime, timezone
from pathlib import Path
import uuid
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 in acute slice",
"identifier": str(uuid.uuid4()),
"session_start_time": datetime.now(timezone.utc),
"subject_id": "mouse_001",
"species": "Mus musculus",
"device_name": "MultiClamp 700B",
"device_description": "Axon MultiClamp 700B patch-clamp amplifier",
"experimenter": "J. Smith",
"recording_temperature": 23.5,
"liquid_junction_potential_mv": 14.2,
},
analysis_results=batch_rows, # optional list of dicts from BatchAnalysisEngine
)