Make Units.waveform_unit configurable - #2237
Merged
Merged
Conversation
Update the nwb-schema submodule to the latest schema dev (2.10.1-alpha), which includes NeurodataWithoutBorders/nwb-schema#707. That PR changes the "unit" attribute of Units.waveform_mean, waveform_sd, and waveforms from a fixed value of "volts" to a default value of "volts". HDMF short-circuits attribute resolution when a spec has a fixed value, so the existing mapping from Units.waveform_unit onto the "unit" attribute of the waveform columns was never reached and the requested unit was silently replaced with "volts" on write. With the schema change the mapping is reachable, so no write-path change is needed. Implement the warning placeholder in UnitsMap._get_waveform_stat: a file can now carry different "unit" values across the three waveform columns while the Units container holds only one, so report which column's value was used. Fixes #2162 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #2237 +/- ##
==========================================
+ Coverage 96.04% 96.25% +0.20%
==========================================
Files 30 30
Lines 3010 3018 +8
Branches 437 438 +1
==========================================
+ Hits 2891 2905 +14
+ Misses 67 64 -3
+ Partials 52 49 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
h-mayorquin
previously approved these changes
Aug 3, 2026
h-mayorquin
left a comment
Contributor
There was a problem hiding this comment.
Thanks for this, looks good to me.
Contributor
|
If we are improving the metadata provenance for waveforms it would be great to get this one as well (c.c. @alejoe91) |
# Conflicts: # CHANGELOG.md
Update the nwb-schema submodule to the latest dev, which adds the optional time_before_peak_in_ms attribute to the waveform_mean, waveform_sd, and waveforms datasets of Units (NeurodataWithoutBorders/nwb-schema#709). Expose it as the waveform_time_before_peak_in_ms constructor argument and field of Units, following the waveform_rate and waveform_unit pattern: written onto all three waveform columns and read back from the first populated one, with a warning when the columns disagree. Return the NO_OVERRIDE sentinel from the UnitsMap constructor argument overrides so that an absent attribute leaves the docval default in place under HDMF >= 6.2.0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
h-mayorquin
approved these changes
Aug 11, 2026
h-mayorquin
left a comment
Contributor
There was a problem hiding this comment.
Thanks for moving quickly with this. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2162.
Updates the nwb-schema submodule to the latest schema dev (2.10.1-alpha), which includes NeurodataWithoutBorders/nwb-schema#707 and NeurodataWithoutBorders/nwb-schema#709.
Configurable waveform unit (nwb-schema#707)
That PR changes the
unitattribute ofUnits.waveform_mean,waveform_sd, andwaveformsfrom a fixed value of"volts"to a default value of"volts".HDMF short-circuits attribute resolution when a spec has a fixed value, so the existing mapping from
Units.waveform_unitonto theunitattribute was never reached. With the schema change it is reachable, so no write-path change was needed.Also implements the warning placeholder in
UnitsMap._get_waveform_stat, since a file can now carry differentunitvalues across the three waveform columns while theUnitscontainer holds only one.Waveform peak alignment (nwb-schema#709)
That PR adds an optional
time_before_peak_in_msattribute toUnits.waveform_mean,waveform_sd, andwaveforms. It holds the time, in milliseconds, from the start of each waveform to the spike peak, that is, the alignment point used during spike sorting. The value is the same for every unit and every spike.PyNWB exposes it as the
waveform_time_before_peak_in_msconstructor argument and field ofUnits, following the existingwaveform_rateandwaveform_unitpattern: one value on the container, written onto all three waveform columns, and read back from the first populated column with a warning when the columns disagree.NO_OVERRIDEinUnitsMapThe constructor argument overrides in
UnitsMapreturnedNoneto signal "no override". HDMF 6.2.0 deprecates that in favor of theObjectMapper.NO_OVERRIDEsentinel, and under HDMF 8.0 aNonereturn will set the constructor argument toNone, which would clobber the"volts"default ofwaveform_unit. They now return the sentinel via the existingpynwb.io.utils.NO_OVERRIDEshim.Note
waveform_unit,waveform_rate, andwaveform_time_before_peak_in_mscan only be set on theUnitsconstructor, so they are not reachable from thenwbfile.add_unit(...)path that auto-creates the table. Worth addressing separately.🤖 Generated with Claude Code