PIA-Group / BioSPPy

Biosignal Processing in Python
Other
573 stars 274 forks source link

Not enough heartbeats: HB detection issue #19

Closed DominiqueMakowski closed 7 years ago

DominiqueMakowski commented 7 years ago

Hey guys,

I got this modified LEAD II ECG signal from which I'd like to extract several features. However, using the signals.ecg.ecg() function throws out a ValueError: Not enough beats to compute heart rate. I tried to narrow down the locus of the error and it seems to happen within the hamilton_segmenter() (which returns 0 peaks)...

What is causing this error? Is there a way to fix it?

Thanks!

DominiqueMakowski commented 7 years ago

Digging some more I've discovered that the error appears when including the [26150:26250] range. Looking at the data I've found that there was one missing value... I've replaced it by the preceding value as following:

ecg[np.where(np.isnan(ecg))[0]] = ecg[np.where(np.isnan(ecg))[0]-1]

And it works like a charm 😄

sangfrois commented 4 years ago

Hey @DominiqueMakowski I've tried to run the same function today and it didn't work out for me as well, but for the bvp module. Would you, by any chance, have any insights as to how I could fix that ? cause i still get the same error by running ppg[np.where(np.isnan(ppg))[0]] = ppg[np.where(np.isnan(ppg))[0]-1]

anandavalliv commented 3 years ago

Hi Mr. @DominiqueMakowski , I still get the error ValueError: Not enough beats to compute heart rate. in signals.ecg.ecg() with ecg_all = ecg.ecg(signal=signals, sampling_rate=128.0, show=False)

Could you please help me with this problem? Thank you!

DominiqueMakowski commented 3 years ago

@anandavalliv I'd personally try using a different peak detection method (see here)

anandavalliv commented 3 years ago

Thank you so much! I will try using this method.