Repository navigation
Add average_reference option to NoisyChannels - #217
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #217 +/- ##
==========================================
+ Coverage 98.03% 98.08% +0.04%
==========================================
Files 8 8
Lines 864 886 +22
==========================================
+ Hits 847 869 +22
Misses 17 17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Adds a keyword-only
average_reference=Falseparameter toNoisyChannels.Why
Users who want to detect bad channels on average-referenced data currently have to re-reference the
Rawbefore passing it in. That has three problems:set_eeg_reference("average"), a flat channelcbecomesc - mean(all channels)and carries the variance of the mean signal, sofind_bad_by_nan_flat(run in__init__) no longer flags it. A single NaN channel spreads into every channel through the average.-mean(other channels)instead of a flat signal, sobad_by_dropoutinfind_bad_by_correlationnever triggers.What
With
average_reference=True,__init__runsfind_bad_by_nan_flaton the data as passed (unchanged), buildsEEGDatafrom the usable channels (not bad-by-NaN, bad-by-flat, or manually marked) as before, and then subtracts their mean fromEEGData, beforeEEGFilteredis computed and before any other detector runs. Deviation, HF noise, correlation, SNR, PSD, and RANSAC all readEEGData/EEGFiltered, so they all see the re-referenced data;raw_mneis untouched.The subtracted reference (one row) is kept.
find_bad_by_correlationfilters it with the same filter and adds it back per window for the dropout test only. The filter is linear and negation is exact in floating point, so a zeroed stretch is recovered exactly and the existingMAD == 0criterion still applies. Dropout windows are excluded from the correlation computation, as before.False: no change in behaviour.matlab_strict=True(same pattern asreject_by_annotation).Tests
Flat/NaN still detected and
EEGDataequals the usable channels minus their own mean; a dropout is still detected withaverage_reference=True(fails without the add-back); results independent of the content of a manually marked channel; default off;matlab_strict; too few usable channels; non-boolean input. Full suite: 68 passed; pre-commit clean; docs build clean with-W.