-
Notifications
You must be signed in to change notification settings - Fork 36
ADD: bad_by_PSD method #179
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
pyprep/find_noisy_channels.py
Outdated
| # Sum log PSD across frequencies for each channel to get total power | ||
| total_log_psd = np.sum(log_psd, axis=1) |
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.
I think in this step we lose some info. Imagine a channel that has an abnormally high PSD in low freqs, but lower than normal in high freqs --> the total power will then look like that of a channel that is medium in high and low 🤔
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.
just as a rule of thumb, we could try dividing into 3 "band power" bins (and only within bins summing up to total log psd):
- 0-15Hz
- 15-30Hz
- 30-45Hz
a channel would be bad if the bin in 30-45Hz has more power than that of 0-15Hz.
a channel could also be bad if it is abnormal from other channels in any one of these three bins
a channel could also be bad if any ratio of bands is abnormal (1/2, 1/3, 2/3)
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.
Added.
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.
Removed third criterion
|
Removing bad_by_ratio criterion: What it did: For each channel, it computed the ratio of power between frequency bands (low/mid, low/high, mid/high), then flagged The rationale: The idea was to catch channels with abnormal spectral shape even if absolute power was normal. For example:
Why it's problematic:
The remaining criteria are more robust:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #179 +/- ##
==========================================
- Coverage 98.09% 98.08% -0.01%
==========================================
Files 7 7
Lines 734 785 +51
==========================================
+ Hits 720 770 +50
- Misses 14 15 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I mean, if a cleaning method fails on noisy data, then what's the point 🤔 |
|
Considering this atm:
|
|
Will check only flagging channels with abnormally HIGH power (positive z-scores). Excess power is more reliably indicative of problems (muscle artifact, noise, bad contact causing interference). Low power is ambiguous. |
|
The current implementation seems promising and will be tested on a complete dataset next week :) |
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.
nice work here @Randomidous looking forward to seeing the test results next week.
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.
@nabilalibou please feel free to have a look at this PR that is in the same vein of what you worked on in 2024.
Please also supply us with your details so we can add you to CITATION.cff, to give you some credit for getting this started at some point.
Follow this example, please:
- given-names: Roy Eric
family-names: Wieske
affiliation: 'Biopsychology and Neuroergonomics, Technische Universität Berlin, Berlin, Germany'
orcid: 'https://orcid.org/0009-0006-2018-1074'






PR Description
Building on @nabilalibou's work (#145), this PR adds functionality for finding bad channels using Power Spectral Density (PSD). This method is not part of the original MATLAB PREP pipeline and only runs when matlab_strict=False.
Detection Criteria
A channel is flagged as "bad-by-PSD" if either:
Implementation Details
Changes from previous PR (#145)
Merge Checklist
closes #<issue-number>to automatically close an issueCITATION.cfffile