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

Peaks information in cardiac cycles #92

Closed renatosc closed 5 years ago

renatosc commented 5 years ago

Hi Dominique,

The ecg_process today returns the peaks (P,Q, R, ...) in reference to the sample number, so I can easily plot both the entire ECG and the peaks. Since the Cardiac Cycles returned by ecg_process starts at the same point (zero, making it possible to have that plot of all cycles on top of each other), the peaks info returned cannot be used directly. I was wondering if there is any built-in feature to show the peaks in reference to the Cardiac Cycles. (i.e, I would like get the peaks position inside each cardiac cycle array entry).

Update: If there is no directly correlation in the module, and since all R-peaks in the Cardiac Cycles are positioned at x=200, I was thinking in for each cardiac cycle, I would get the equivalent R-peak value and decreases by 200, arriving them at a deltaX that I would need to subtract from all other wave peaks (P,Q..). What do you think?

DominiqueMakowski commented 5 years ago

@renatosc Yes, I would say that this would work. However, an even simpler workaround would be to subtract from each peak from the signal the index of the corresponding R peak. This way, all of the peaks would be in reference to their R peak, and you could quite easily plot them all together?

Or indeed, you could also re-scale these deltas and add them in the cardiac_cycle data? But the general idea would be to use the R peaks indices as a reference for the other values.

renatosc commented 5 years ago

@DominiqueMakowski , thanks for the feedback. I ended up just using the delta in order to avoid having to deal with negative values. I will see later how can I added that to NK and make a pull request.