neuropsychology / NeuroKit.py

A Python Toolbox for Statistics and Neurophysiological Signal Processing (EEG, EDA, ECG, EMG...).
http://neurokit.rtfd.io
MIT License
365 stars 102 forks source link

ECG_R_peaks #25

Closed eleanor-hanna closed 7 years ago

eleanor-hanna commented 7 years ago

Hi Dominique!

First of all, thanks for answering my earlier question about P2T RSA - you have already been super helpful!!

I have another question now. I've been running my Acqknowledge file through Neurokit trying to extra ECG data, and it seems to be working really well except for the ECG_R_peaks column, which just outputted only nans. Everything else seems to be doing what it's supposed to do. Can you think of a thing I have left out?

Thank you so much!!

Ellie

DominiqueMakowski commented 7 years ago

@AnteriorInsula Glad the package is helpful to someone ;)

As for the R peaks, basically you have two things: 1) you have the location of each rpeak within processed_ecg["ECG"]["R_Peaks"], which gives you a list with all the r peaks locations. You can try to plot to see if they are correct (if not, you might want to change the segmenter) by doing:

processed_ecg =  nk.process_ecg(...)
ecg = processed_ecg["df"]["ECG_Filtered"]
rpeaks = processed_ecg["ECG"]["R_Peaks"]
nk.plot_events_in_signal(ecg, rpeaks)

2) The ECG_R_peaks column contains, indeed, almost only nans. However, at each r peak location, there's a "1" value. This is done to be able, when doing for instance event-related analysis, to quickly retrieve the number of R peaks (the length of this variable after dropping the nans) within a particular window of interest.

Cheers, Dom