Skip to content

Add DecompositionSeries unit and source_timeseries checks#687

Open
h-mayorquin wants to merge 8 commits intodevfrom
implement_unit_check_for_decomposition_series
Open

Add DecompositionSeries unit and source_timeseries checks#687
h-mayorquin wants to merge 8 commits intodevfrom
implement_unit_check_for_decomposition_series

Conversation

@h-mayorquin
Copy link
Copy Markdown
Collaborator

DecompositionSeries stores the product of spectral analysis and has a metric field ("phase", "amplitude", "power") that determines what units are appropriate. PyNWB defaults the unit to "no unit", which is almost always wrong since the metric carries enough information to determine the correct unit.

This PR adds two checks:

check_decomposition_series_unit (BEST_PRACTICE_VIOLATION) validates the unit field against the metric. When metric is "phase", the unit should be "radians" or "degrees". When metric is "amplitude" and source_timeseries is linked, the unit should match the source signal's unit (e.g. "volts" for an ElectricalSeries). The PyNWB default "no unit" and empty strings are flagged regardless of metric. The power case is skipped because there is no standard string format for squared units in NWB (see nwb-schema#446 for the ongoing discussion about adopting CMIXF-12 for unit notation).

check_decomposition_series_source_timeseries (BEST_PRACTICE_SUGGESTION) flags when source_timeseries is not set. This field provides provenance about which signal was decomposed and enables the unit validation above. PyNWB itself already warns about this at construction time, but the inspector check catches it for files that were already written.

Related to #208.

@h-mayorquin h-mayorquin self-assigned this Mar 24, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.33%. Comparing base (061ee1e) to head (02aef19).
⚠️ Report is 2 commits behind head on dev.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #687      +/-   ##
==========================================
+ Coverage   79.92%   83.33%   +3.40%     
==========================================
  Files          48       49       +1     
  Lines        1878     1908      +30     
==========================================
+ Hits         1501     1590      +89     
+ Misses        377      318      -59     
Files with missing lines Coverage Δ
src/nwbinspector/checks/__init__.py 100.00% <100.00%> (ø)
src/nwbinspector/checks/_misc.py 100.00% <100.00%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants