You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
compute_hr doesn't check that QRS indices are strictly increasing #602
compute_hr assumes qrs_inds is strictly increasing, but doesn't check it. If two beats have the same index, the RR interval is 0:
importnumpyasnpfromwfdbimportprocessingprocessing.compute_hr(20, [2, 8, 8, 15], fs=1)
# ZeroDivisionError: float division by zeroprocessing.compute_hr(20, np.array([2, 8, 8, 15]), fs=1)
# RuntimeWarning: divide by zero, and the output contains inf
Beats that go backwards (e.g. [2, 8, 5, 15]) give a negative interval and a negative heart rate (-20 bpm in this example) without any error.
This can happen if annotations are combined from several sources or include non-beat annotations at the same sample (see #185).
compute_hr could check that qrs_inds is strictly increasing and raise a clear ValueError if not. #601 makes the last interval count as well, so a repeated last beat now hits the same problem.
Activity