Skip to content
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

"Neurokit" R-peak detection in ECG depends on sampling frequency #955

Open
HotDog702 opened this issue Jan 22, 2024 · 1 comment
Open

"Neurokit" R-peak detection in ECG depends on sampling frequency #955

HotDog702 opened this issue Jan 22, 2024 · 1 comment
Assignees

Comments

@HotDog702
Copy link

Have found a problematic issue with R peaks detection by neurokit method: it is sensitive to sampling frequency.
I have a 1000 Hz sampled ECG, where nk.ecg_peaks failed to find R-peaks.
image
But when I downsample it to 100 Hz, the R peaks were surprisingly found correctly!!!
I dived deeper and have found the reason.
The function _ecg_findpeaks_neurokit() have comment at the start:
The signal must be the highpass-filtered raw ECG with a lowcut of .5 Hz.
So, such signal I've used as input. The algorithm then calculates the abs value of signal derivative and uses 2 smoothing widows. The result of 2nd window is used as a threshold for the result of 1st window. Here is the source of problem. The derivative amplifies the hi-freq noise in the signal (even it is quite small), and the downsampling works as a low-pass filter (blue line):
image
After that is not surprising, that smoothed absolute derivatives have quite different values and in 1000 Hz case the threshold is much higher (blue+orange = 1000Hz, green+red=100Hz):
image
The obvious solution is low-pass filter of the input signal (to what frequency?) But may be there is better solution?

@HotDog702
Copy link
Author

HotDog702 commented Feb 16, 2024

Have done some research on publicly available datasets: MIT-Arrhythmia, MIT-Normal, GUDB, LUDB, Fantasia, MIT-LongTerm, MIT-nst. For neurokit algorithm the best upper frequency is ~30 Hz, the optimal lower frequency depends on noise in dataset and for different datasets ranges from 0.5 to 7 Hz

For some reason, cannot upload an image :((

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

No branches or pull requests

2 participants