How to detect R of ECG based on the subtraction between two channels

Firstly, I have tried NeuroKit2, and a result was nice. Thanks.
Does this tool work based on QRS fitting?

image

signals, ecg_info = nk.ecg_process(
ecg_signal=ecg_signal,
sampling_rate=raw.info[‘sfreq’]
)
rpeaks=ecg_info[‘ECG_R_Peaks’]
A=np.zeros((size(rpeaks),2),dtype=np.int) # not smart codes
B=np.insert(A, 0, rpeaks, axis=1)
epochs = mne.Epochs(raw, B, 0, -0.1, 0.1)
data = epochs.get_data()
plt.plot(1e3 * epochs.times, np.squeeze(data).T)

Next, I have tried the SleepECG. It looks nice.
In addition, when I applied other data, a result was nicer than that from the Neurokit.
Thanks.

from sleepecg import detect_heartbeats
fs=raw.info[‘sfreq’]
rpeaks = detect_heartbeats(ecg_signal, fs)

image

Very nice, thanks for taking the time to test!

1 Like