Skip to content

feat: add check for unscaled ElectricalSeries data#650

Merged
bendichter merged 7 commits intodevfrom
check-unscaled-electricalseries
Feb 18, 2026
Merged

feat: add check for unscaled ElectricalSeries data#650
bendichter merged 7 commits intodevfrom
check-unscaled-electricalseries

Conversation

@bendichter
Copy link
Copy Markdown
Contributor

Add check_electrical_series_unscaled_data to warn when ElectricalSeries has integer data type with default conversion (1.0) and offset (0.0), which suggests raw acquisition units are not properly scaled to Volts.

The check also considers channel_conversion for per-channel scaling to avoid false positives when proper conversion factors are specified.

Includes documentation for the best practice and changelog entry.

Closes #408
Closes #395

Add `check_electrical_series_unscaled_data` to warn when ElectricalSeries
has integer data type with default conversion (1.0) and offset (0.0),
which suggests raw acquisition units are not properly scaled to Volts.

The check also considers `channel_conversion` for per-channel scaling
to avoid false positives when proper conversion factors are specified.

Includes documentation for the best practice and changelog entry.

Closes #408
Copy link
Copy Markdown
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor points and this should be good to go.

Also, I am thinking that the schema might be improved to reduce the likelihood of errors:
NeurodataWithoutBorders/nwb-schema#671

Comment thread tests/unit_tests/test_ecephys.py Outdated
assert result is not None
assert "int16" in result.message

def test_pass_with_empty_data(self):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that we should not allow ElectricalSeries with empty data and that this test might break or conflict with a check for non-empty data. What do you think?

Comment thread tests/unit_tests/test_ecephys.py Outdated
)
result = check_electrical_series_unscaled_data(electrical_series)
assert result is not None
assert "int16" in result.message
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention I have seen here in this repo is to test against the full message.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I pushed this to avoid some work for you. Let me know if you want me to revert it.

Comment thread tests/unit_tests/test_ecephys.py Outdated
@bendichter bendichter enabled auto-merge (squash) February 18, 2026 18:20
@bendichter bendichter merged commit b1da366 into dev Feb 18, 2026
26 checks passed
@bendichter bendichter deleted the check-unscaled-electricalseries branch February 18, 2026 18:24
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.44%. Comparing base (73f9948) to head (7fde0c9).
⚠️ Report is 2 commits behind head on dev.

Files with missing lines Patch % Lines
src/nwbinspector/checks/_ecephys.py 90.90% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #650      +/-   ##
==========================================
+ Coverage   77.64%   81.44%   +3.79%     
==========================================
  Files          47       47              
  Lines        1673     1708      +35     
==========================================
+ Hits         1299     1391      +92     
+ Misses        374      317      -57     
Files with missing lines Coverage Δ
src/nwbinspector/checks/__init__.py 100.00% <ø> (ø)
src/nwbinspector/checks/_ecephys.py 95.14% <90.90%> (-1.16%) ⬇️

... 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.

[Add Check]: ElectricalSeries of dtype int16 with conversion=1.0 and offset=0.0 is potentially wrong?

3 participants