-
Notifications
You must be signed in to change notification settings - Fork 36
ADD: reject_by_annotation to NoisyChannels #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #180 +/- ##
==========================================
- Coverage 98.09% 97.73% -0.36%
==========================================
Files 7 7
Lines 734 752 +18
==========================================
+ Hits 720 735 +15
- Misses 14 17 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Regarding continuity concerns:
if do_detrend:
self.raw_mne._data = removeTrend(
self.raw_mne.get_data(), self.sample_rate, matlab_strict=matlab_strict
)
Remaining Concerns:
The MATLAB PREP concerns are mostly addressed for the intended use case (excluding known-bad segments like movement
However, there's a theoretical edge case where the bandpass filtering on concatenated data could introduce minor
^^^ For typical use (excluding a few isolated bad segments), this should not materially affect channel quality assessment. |
| # Without rejection, sample count should be unchanged | ||
| nd_no_reject = NoisyChannels(raw_tmp, do_detrend=False, reject_by_annotation=None) | ||
| assert nd_no_reject.n_samples == original_samples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one pretty much covers test_reject_by_annotation_default from above, right? So I vote to remove test_reject_by_annotation_default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work @Randomidous !
Few comments apart from the inline one(s).
- We should explain what we mean by "bad" segments by linking to https://mne.tools/stable/auto_tutorials/preprocessing/20_rejecting_bad_data.html#the-reject-by-annotation-parameter in the docs via something like
See the MNE tutorial on rejecting data spans:
:ref:`mne:tut-reject-data-spans`.
(this should work due to interphinx)
And in the docstrings we can be more brief and say that it's any annotation starting with BAD or bad
- Thanks for your "caveats" comment. I think we should add a "test" to pyprep that warns a user IF (i) reject_by_annotation is not None AND (ii) the bad segments are "plenty", i.e., not a few "long" bad segments (block breaks), but potentially loads of small bad segments (where somebody tried to filter out e.g., muscle activations via https://mne.tools/stable/generated/mne.preprocessing.annotate_muscle_zscore.html#mne.preprocessing.annotate_muscle_zscore)
sappelhoff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more point I forgot: I don't think we need the "NaN" option 🤔 in fact, I think it's unnecessarily complicating this. "Omit" should be sufficient.
Oh and of course let's test this a little before merging it. I suggest you run it on your dataset that you are currently working on and compare the performance / sanity WITH and without reject_by_annotation.
Co-authored-by: Stefan Appelhoff <[email protected]>
…/pyprep into break-it-down-for-me
docs/matlab_differences.rst
Outdated
|
|
||
| This parameter has no equivalent in MATLAB PREP and is not affected by the | ||
| ``matlab_strict`` setting. | ||
| This parameter has no equivalent in MATLAB PREP. When ``matlab_strict`` is set to ``True``, ``reject_by_annotation`` is automatically set to ``None``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to say, but this will of course need code adjustments 👼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Way ahead of you 😁
| "reject_by_annotation is not available in MATLAB PREP. " | ||
| f"Setting reject_by_annotation to None (was '{reject_by_annotation}')." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "reject_by_annotation is not available in MATLAB PREP. " | |
| f"Setting reject_by_annotation to None (was '{reject_by_annotation}')." | |
| "reject_by_annotation is not available in MATLAB PREP. " | |
| f"Setting reject_by_annotation to None (was '{reject_by_annotation}'). " | |
| "To use reject_by_annotation, matlab_strict must be set to False." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds more like an error message than a warning, aye?
PR Description
Following a discussion here and there, this PR implements mne's reject_by_annotation to exclude BAD-annotated time segments from channel quality assessment. Bad segments (e.g., participant movement during breaks) are only temporarily excluded from statistical analysis while preserving the original continuous data structure in the output.
Note:
Merge Checklist
closes #<issue-number>to automatically close an issueCITATION.cfffile