What happened?
While looking at how Units.waveform_rate is serialized, I noticed that PyNWB maps it onto the sampling_rate attribute of waveform_mean and waveform_sd, but not onto the sampling_rate attribute of waveforms.
The NWB schema defines sampling_rate on all three:
/units/waveform_mean
/units/waveform_sd
/units/waveforms
However, in the current PyNWB export path, only waveform_mean and waveform_sd are populated from Units.waveform_rate.
This means that if a Units table contains waveforms but not waveform_mean or waveform_sd, then the waveform sampling rate does not appear to be serialized anywhere related to waveforms.
I'm not sure whether this is intentional, so I wanted to ask:
- Is there a reason
waveforms.sampling_rate is not populated by the Units API/export mapper?
- If not intentional, should
Units.waveform_rate also be written to /units/waveforms.attrs["sampling_rate"]?
- Should readback also consider
waveforms.sampling_rate when reconstructing Units.waveform_rate?
Steps to Reproduce
from pynwb import NWBFile, NWBHDF5IO
from datetime import datetime
from dateutil.tz import tzlocal
nwbfile = NWBFile(
session_description="desc",
identifier="id",
session_start_time=datetime.now(tzlocal()),
)
nwbfile.add_unit(
spike_times=[0.1, 0.2, 0.3],
waveforms=[
[[1, 2, 3]],
[[1, 2, 3]],
[[1, 2, 3]],
],
)
nwbfile.units.waveform_rate = 30000.0
with NWBHDF5IO("test.nwb", "w") as io:
io.write(nwbfile)
Then inspect /units/waveforms in the output file.
Traceback
No traceback. This is a schema/API/export consistency question.
Relevant code references
src/pynwb/misc.py: Units.waveform_rate is defined on the container
src/pynwb/io/core.py: export mapping only covers waveform_mean and waveform_sd
src/pynwb/io/misc.py: readback only checks waveform_mean and waveform_sd
src/pynwb/nwb-schema/core/nwb.misc.yaml: schema defines waveforms.sampling_rate
Environment
- Operating System: macOS
- Python Executable: Python
- Python Version: 3.12
What happened?
While looking at how
Units.waveform_rateis serialized, I noticed that PyNWB maps it onto thesampling_rateattribute ofwaveform_meanandwaveform_sd, but not onto thesampling_rateattribute ofwaveforms.The NWB schema defines
sampling_rateon all three:/units/waveform_mean/units/waveform_sd/units/waveformsHowever, in the current PyNWB export path, only
waveform_meanandwaveform_sdare populated fromUnits.waveform_rate.This means that if a
Unitstable containswaveformsbut notwaveform_meanorwaveform_sd, then the waveform sampling rate does not appear to be serialized anywhere related towaveforms.I'm not sure whether this is intentional, so I wanted to ask:
waveforms.sampling_rateis not populated by theUnitsAPI/export mapper?Units.waveform_ratealso be written to/units/waveforms.attrs["sampling_rate"]?waveforms.sampling_ratewhen reconstructingUnits.waveform_rate?Steps to Reproduce
Then inspect
/units/waveformsin the output file.Traceback
No traceback. This is a schema/API/export consistency question.
Relevant code references
src/pynwb/misc.py:Units.waveform_rateis defined on the containersrc/pynwb/io/core.py: export mapping only coverswaveform_meanandwaveform_sdsrc/pynwb/io/misc.py: readback only checkswaveform_meanandwaveform_sdsrc/pynwb/nwb-schema/core/nwb.misc.yaml: schema defineswaveforms.sampling_rateEnvironment