You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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):
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):
The obvious solution is low-pass filter of the input signal (to what frequency?) But may be there is better solution?
The text was updated successfully, but these errors were encountered:
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
Have found a problematic issue with R peaks detection by neurokit method: it is sensitive to sampling frequency.
![image](https://private-user-images.githubusercontent.com/95288970/298508507-f77e9ae5-3d23-4c9e-9822-b864835ac71b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NDc3MzUsIm5iZiI6MTczOTQ0NzQzNSwicGF0aCI6Ii85NTI4ODk3MC8yOTg1MDg1MDctZjc3ZTlhZTUtM2QyMy00YzllLTk4MjItYjg2NDgzNWFjNzFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDExNTAzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgwZWRkYTIxMzM0MmY3NTQ1OTIyNzQxYWFiZDM1MzgwZTBlYzU0OTI0YzI0ODE3NmU4YWExM2IyOWNmZmMzYmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.SkdtwMvcL14bPlhPYtM6QjLopkXfAm25EdQnj8FnFKA)
![image](https://private-user-images.githubusercontent.com/95288970/298508427-b1934753-43a2-4764-8ce8-e2a87656f4c1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NDc3MzUsIm5iZiI6MTczOTQ0NzQzNSwicGF0aCI6Ii85NTI4ODk3MC8yOTg1MDg0MjctYjE5MzQ3NTMtNDNhMi00NzY0LThjZTgtZTJhODc2NTZmNGMxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDExNTAzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJhZGU5MDk3YzgxZmZiZmI3NWU1MDg0OWEyNWYxYTFjNWZiZDNiMjJhMmI3ODEyODRiOWRlNDQyZDgzYjlhZjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.6VFglMbOX3YWE7mj5iT5OFlVH1EXK4KucjQ8aY-uWGQ)
![image](https://private-user-images.githubusercontent.com/95288970/298508687-c9c0c040-723f-482e-ac69-ed1d35d07591.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NDc3MzUsIm5iZiI6MTczOTQ0NzQzNSwicGF0aCI6Ii85NTI4ODk3MC8yOTg1MDg2ODctYzljMGMwNDAtNzIzZi00ODJlLWFjNjktZWQxZDM1ZDA3NTkxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDExNTAzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ4MDA2MmNiMWQwN2QzMDY3YjA4MmQzNmM5NzY3MTc4YWViOTY5ZDRiOGIyMzBiMDZhMzkxZGY2MTZiYTYzNmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.vCwl-Aw0Nz50hE0qYvkekhJzf4Dlk3VkoW0r1QHkDQA)
I have a 1000 Hz sampled ECG, where nk.ecg_peaks failed to find R-peaks.
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):
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):
The obvious solution is low-pass filter of the input signal (to what frequency?) But may be there is better solution?
The text was updated successfully, but these errors were encountered: