PIA-Group / BioSPPy

Biosignal Processing in Python
Other
573 stars 274 forks source link

R peak detection failure #25

Closed DominiqueMakowski closed 7 years ago

DominiqueMakowski commented 7 years ago

Hey, sorry to bother you again. I have a dataset that somehow makes the r peak detection to fail...

Reproducible example:

import biosppy
import pandas as pd

df = pd.read_csv("https://raw.githubusercontent.com/neuropsychology/NeuroKit.py/master/examples/Bio/data/bio_rest.csv", index_col=0)[14097:314163]
biosppy_ecg = biosppy.ecg.ecg(df["ECG"])

figure_1

It seems that it takes the negative peak for the positive. Why is that? How could we fix it?

Thanks for all!

capcarr commented 7 years ago

Hi @DominiqueMakowski The default R-peak detection algorithm in the ecg method (hamilton_segmenter) is designed to detect peaks even if they have strong negative components (typically the S wave). I'll add a correction mechanism to the default, making sure the peaks are aligned by the maximum in the QRS segment.

DominiqueMakowski commented 7 years ago

Thanks a lot. Let me know if you need any help on that!

Also, do you know if/how we can adapt the hamilton_segmenter to return the localization of the other waves (especially the Q and the T waves)?

capcarr commented 7 years ago

It certainly is possible to find the other waves, but I haven't thought much about this. A good starting point could be this paper: http://ieeexplore.ieee.org/abstract/document/1275572/