-
-
Notifications
You must be signed in to change notification settings - Fork 434
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
[Docs] window size calculation for locreg detrending #734
Conversation
Thanks for opening this pull request! We'll make sure it's perfect before merging 🤗 |
Codecov ReportBase: 53.35% // Head: 53.36% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## dev #734 +/- ##
=======================================
Coverage 53.35% 53.36%
=======================================
Files 283 283
Lines 12848 12848
=======================================
+ Hits 6855 6856 +1
+ Misses 5993 5992 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
The bug was in using a window of 0.5 * sample_rate, which corresponds to a frequency of 2Hz, not to a frequency of 0.5Hz as desired. A few comments to clarify
|
Here 2 examples of PPG signals with the heart rate of 60bpm and 120bpm respectively, detrended with the locreg method at 0.5Hz and 2Hz. |
Thank you for this @vasileermicioi ! I added some comments above.
Do you happen to have a reference for this? I agree that we would not filter out frequencies above 0.5Hz for interbeat interval detrending, but for preprocessing a raw heartbeat signal like ECG, I've seen higher cutoff frequencies e.g. Pan-Tompkins uses 5 Hz: NeuroKit/neurokit2/ecg/ecg_clean.py Lines 191 to 196 in e66a732
No worries if not, but how the appropriate cutoff frequency is determined is something I've wondered myself! |
heart rate information is in 0.5Hz-5Hz because the heart rate is in 30-300bpm (multiply frequency by 60 :) ), for ECG it is 40Hz, see https://www.medteq.net/article/2017/4/1/ecg-filters |
Thank you for the references @vasileermicioi !
I meant that the low-cut of Pan-Tompkins, an algorithm used to process ECG signals, is 5 Hz (the high-cut is 15 Hz), so I was curious if you had any sources for digitally filtering out frequencies below 5 Hz being necessarily problematic? |
you are right about ECG having a different range for bandpass than PPG, my experience and example are with PPG, and my statement is true for PPG only, other than that the PR is still correct as
PS: |
Ah interesting, thank you :)
Agreed, just want to make sure we compute that correctly, and I think since |
@vasileermicioi update: I tried out various definitions of the window with a simulated signal: https://gist.github.com/danibene/e3ed1200a75ea72a3c52bfb0ac248a2c Now I'm also wondering if the pyprep implementation that I linked earlier is incorrect. Any insights you have here would be appreciated! In any case, I agree that the documentation should be updated so that it's clear that the lowcut is not equivalent to the window. |
yes, it is wrong too, because taking a window with 50% larger will have the effect of reducing the frequency by 1/3, for example if we want to remove all frequencies below 0.5Hz, it will remove all below 0.33Hz instead, and if we want to remove below 2Hz, it will remove only below 1.34Hz |
Co-authored-by: Dominique Makowski <[email protected]>
Co-authored-by: danibene <[email protected]>
Co-authored-by: danibene <[email protected]>
Co-authored-by: danibene <[email protected]>
@danibene now the |
Wouldn't it be |
yes, you are right |
@DominiqueMakowski any thoughts on whether we should deviate from the pyprep implementation? |
pyprep is supposedly pretty robust, perhaps it's worth opening an issue on their repo to get their thoughts? |
So I think we can hold off on merging for a bit to see if they respond here: sappelhoff/pyprep#125 |
@danibene |
@vasileermicioi I'm away for the next week but I can take a look when I get back! Otherwise @DominiqueMakowski feel free to address this without my input |
That's my understanding as well..., but we can wait 'til Dani comes back :) |
@vasileermicioi based on the responses we received: VisLab/EEG-Clean-Tools#33 (comment) it looks like you're correct, but they don't plan to change the implementation. How about we keep the |
Yeah that seem like a good resolve, this way we don't change the default as compared to prep but provide more context and info for users to potentially fine tune it |
Maybe we can make the docs change and close the PR (I'd like to merge the dev branch soon :) |
I was thinking "merge" the PR actually 😢 @vasileermicioi could you reopen one? |
Description
This PR aims to fix docs for detrending.
Proposed Changes
Doc comments were updated.
Checklist
Here are some things to check before creating the PR. If you encounter any issues, do let us know :)