-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
Hi,
This is an issue I have encountered a few times already — when the ECG data is very noisy for either part of or most of the recording, the detect_heartbeats function just gets stuck forever. This is problematic when you run peak detection across hundreds of participants and cannot visually check each recording.
To reproduce the error:
Download the EDF file with 8 hours ECG: https://drive.google.com/file/d/1ReYlFPAd3-dYk0C2WF7nDRQS3MxE2lyE/view?usp=share_link
import mne
from sleepecg import detect_heartbeats
# Load ECG
raw = mne.io.read_raw_edf("original_ecg.EDF", preload=True, verbose=False)
ecg = raw.get_data(units="uV")[0]
sf = raw.info["sfreq"]# Load ECG
# Peak detection
detect_heartbeats(ecg, sf) # gets stuckIn that case, the ECG data is so bad that honestly it would be better not to attempt the peak detection at all...!
Potential solutions:
- Modification of the algorithm to avoid getting stuck when no peak is found?
- Pre-screening of the ECG signal quality — if the data is very noisy then the detection is skipped and an empty array is returned instead? For example we could use some kind of ECG signal quality metric (see
method="zhao2018"in https://neuropsychology.github.io/NeuroKit/functions/ecg.html#ecg-quality)
Thanks,
Raphael
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels