jtlait / ecg2rr

ECG to RR
MIT License
19 stars 7 forks source link

remove_close fails to complete #3

Open MarcusVollmer opened 2 years ago

MarcusVollmer commented 2 years ago

Dear Juho,

I have several beat locations derived from 10-second ECGs than cannot be processed by your filter function to remove physiologically implausible close locations. Please have a look at the following output from a record sampled at 500Hz:

>>> peaks
array([ 180,  201,  454,  474,  719,  739,  764,  976,  997, 1022, 1246,
       1267, 1516, 1537, 1778, 1798, 2042, 2063, 2314, 2334])
>>> probs
array([0.49186349, 0.38749108, 0.57148891, 0.43434726, 0.5376877 ,
       0.40901706, 0.21033455, 0.67790574, 0.39221896, 0.13146529,
       0.63408794, 0.57205515, 0.59101564, 0.48511908, 0.59304953,
       0.5121345 , 0.51543932, 0.50958154, 0.60621216, 0.48644364])

As ok_peaks is empty, an indexing error occurs:

 line 459, in remove_close
    if max_peak < ok_peaks[0]:
IndexError: index 0 is out of bounds for axis 0 with size 0

The empty array ok_peaks is defined here: https://github.com/jtlait/ecg2rr/blob/b642cb388f0f11c8f4700754f2fc402ee81e5b91/ecg2rr/detector.py#L436

Best, Marcus

jtlait commented 2 years ago

Thanks Marcus! I will look into this when I have time.