PIA-Group / BioSPPy

Biosignal Processing in Python
Other
573 stars 274 forks source link

Zero R peaks found when capture starts with noise #30

Closed mexomagno closed 7 years ago

mexomagno commented 7 years ago

Hi!

We're having some trouble with R-peak detection. We've been using ecg.ecg() with some captures, and observed that every time the capture starts with noisy enough data, it will fail to find R peaks, regardless of what comes after the noisy part. This means that if a capture begins very noisy but later has a perfect ECG for a long time, ecg.ecg() will still never be able to find not a single R peak (at least that's what we can observe)

Example:

Capture 1) Good, clean samples. R peaks found correctly. Good, clean samples

Capture 2) Bad, somehow noisy samples. No R peaks found. (plotted directly with matplotlib) Somehow noisy samples

Noisy start, clean continuation. No R peaks found. (plotted directly with matplotlib) This is capture 1) followed by capture 2). Starts noisy, continues clean

Is this behavior expected? What can be done to detect the R peaks of the clean part? Should we be the ones handling this?

Many thanks in advance!

capcarr commented 7 years ago

Hi @mexomagno Unfortunately there's not much I can do from my end... That probably happens because the Hamilton algorithm uses the first 8 seconds of data to estimate a threshold. My suggestion would be to try to use a different segmentation algorithm (SSF or Christov, also in the ecg module), or to break the clean ECG data out from the noise.

mexomagno commented 7 years ago

Thanks for the quick response, @capcarr

Well, that explains a lot of what's happening. Currently Gamboa's approach seems to do the job for now.

I'm closing the issue. Cheers!