Skip to content

Compute_Hr function miscalculates. #185

Not planned
Not planned

Description

@MishalJasmine

I am working on the MIT-BIH records. The aim is to calculate the Heart Rate and find the maximum, minimum and the mean of the Heart rates. I extracted the ECG signal from the record, calculated the QRS peaks and calculated the Heart Rates using the compute_hr function from the wfdb package. Similarly extracted the QRS peaks from the annotation file and calculated the Heart Rates using the compute_hr function from the wfdb package. For the 101 record, the maximum Heart Rate from the annotations is 900.00bpm while the calculated qrs indices gave a maximum Heart rate of 111.3402bpm. I have this issue with many other records.

Python code:

record = wfdb.rdrecord(record_path, channels=[0])                                                                                                                                                                 
ann_ref = wfdb.rdann(record_path,'atr')
qrs_inds = processing.gqrs_detect(sig=record.p_signal[:,0], fs=record.fs)

heart_rate_wfdb = processing.compute_hr(sig_len=record.p_signal.shape[0], qrs_inds=qrs_inds, fs=record.fs)
heart_rate_wfdb = heart_rate_wfdb[np.logical_not(np.isnan(heart_rate_wfdb))]
heart_rate_min = "{0:.4f}".format(np.amin(heart_rate_wfdb))
heart_rate_max = "{0:.4f}".format(np.amax(heart_rate_wfdb))
heart_rate_mean = "{0:.4f}".format(np.mean(heart_rate_wfdb))

ref_heart_rate_wfdb = processing.compute_hr(sig_len=record.p_signal.shape[0], qrs_inds=ann_ref.sample[1:], fs=record.fs)
ref_heart_rate_wfdb = ref_heart_rate_wfdb[np.logical_not(np.isnan(ref_heart_rate_wfdb))]
ref_heart_rate_min = "{0:.4f}".format(np.amin(ref_heart_rate_wfdb))
ref_heart_rate_max = "{0:.4f}".format(np.amax(ref_heart_rate_wfdb))
ref_heart_rate_mean = "{0:.4f}".format(np.mean(ref_heart_rate_wfdb))`

Can someone tell me what is that I am doing wrong?

Activity

  1. m0bi5 commented on Apr 18, 2020

    @m0bi5

    Facing the same issue, were you able to figure it out?

  2. MishalJasmine commented on Apr 30, 2020

    @MishalJasmine
    Author

    @m0bi5 I oberserved two things,

    1. First we need to classify annotations as beat and non-beat annotations. The annotations classified as beat annotations, need to be passed to the compute_hr.
    2. If you observe the compute_hr function, the result is an array whose length is equivalent to the length of the input ECG signal. When additional Heart Rate parameters are calculated, it may result in conflicts.

    I hope this will help you.

  3. tompollard commented on Nov 23, 2026

    @tompollard
    Member

    compute_hr uses every annotation it is given, and MIT-BIH annotation files also have non-beat annotations (such as rhythm changes) close to beats, which give very high rates. Pass only the beat annotations to compute_hr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions