Skip to content

Use nanmedian for noise_sd in find_bad_by_hfnoise - #225

Open
chenyangsu wants to merge 1 commit into
sappelhoff:mainfrom
chenyangsu:fix/hfnoise-nan-spread
Open

chenyangsu wants to merge 1 commit into
sappelhoff:mainfrom
chenyangsu:fix/hfnoise-nan-spread

Conversation

@chenyangsu

Copy link
Copy Markdown

PR Description

In NoisyChannels.find_bad_by_hfnoise, when a usable channel produces a NaN in noisiness (for example a channel equal to the average reference under average_reference=True, giving 0 / 0), noise_sd = np.median(np.abs(noisiness - noise_median)) * MAD_TO_SD evaluates to NaN. That turns every usable channel's z-score into NaN and flags all usable channels as bad_by_hf_noise.

Switching noise_sd to np.nanmedian matches MATLAB PREP's mad(noisiness, 1) and adds a regression test in tests/test_find_noisy_channels.py. Happy to add a changelog entry too if you prefer.

Testing: pytest -> 84 passed, ruff check and ruff format --check -> 0 issues.

Merge Checklist

  • the PR has been reviewed and all comments are resolved
  • all CI checks pass
  • (if applicable): the PR description includes the phrase closes #<issue-number> to automatically close an issue
  • (if applicable): the changes are documented in the changelog changelog.rst
  • (if applicable): new contributors have added themselves to the authors list in the CITATION.cff file

@codecov

codecov Bot commented Nov 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.21%. Comparing base (9300503) to head (892e9f2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #225   +/-   ##
=======================================
  Coverage   98.21%   98.21%           
=======================================
  Files           8        8           
  Lines         894      894           
=======================================
  Hits          878      878           
  Misses         16       16           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

This branch has not been deployed

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

1 participant