Email updates

Keep up to date with the latest news and content from BioMedical Engineering OnLine and BioMed Central.

Open Access Highly Accessed Research

Real time electrocardiogram QRS detection using combined adaptive threshold

Ivaylo I Christov

Author Affiliations

Center of Biomedical Engineering, Bulgarian Academy of Sciences, Acad. G. Bonchev str., blok 105, 1113, Sofia, Bulgaria

BioMedical Engineering OnLine 2004, 3:28  doi:10.1186/1475-925X-3-28

The electronic version of this article is the complete one and can be found online at: http://www.biomedical-engineering-online.com/content/3/1/28


Received:4 June 2004
Accepted:27 August 2004
Published:27 August 2004

© 2004 Christov; licensee BioMed Central Ltd.

This is an open-access article distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/2.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

Abstract

Background

QRS and ventricular beat detection is a basic procedure for electrocardiogram (ECG) processing and analysis. Large variety of methods have been proposed and used, featuring high percentages of correct detection. Nevertheless, the problem remains open especially with respect to higher detection accuracy in noisy ECGs

Methods

A real-time detection method is proposed, based on comparison between absolute values of summed differentiated electrocardiograms of one of more ECG leads and adaptive threshold. The threshold combines three parameters: an adaptive slew-rate value, a second value which rises when high-frequency noise occurs, and a third one intended to avoid missing of low amplitude beats.

Two algorithms were developed: Algorithm 1 detects at the current beat and Algorithm 2 has an RR interval analysis component in addition.

The algorithms are self-adjusting to the thresholds and weighting constants, regardless of resolution and sampling frequency used. They operate with any number L of ECG leads, self-synchronize to QRS or beat slopes and adapt to beat-to-beat intervals.

Results

The algorithms were tested by an independent expert, thus excluding possible author's influence, using all 48 full-length ECG records of the MIT-BIH arrhythmia database. The results were: sensitivity Se = 99.69 % and specificity Sp = 99.65 % for Algorithm 1 and Se = 99.74 % and Sp = 99.65 % for Algorithm 2.

Conclusion

The statistical indices are higher than, or comparable to those, cited in the scientific literature.

Background

The QRS complexes and ventricular beats in an electrocardiogram represent the depolarization phenomenon of the ventricles and yield useful information about their behavior. Beat detection is a procedure preceding any kind of ECG processing and analysis. For morphological analysis this is the reference for detection of other ECG waves and parameter measurements. Rhythm analysis requires classification of QRS and other ventricular beat complexes as normal and abnormal. Real-time ventricular beat detection is essential for monitoring of patients in critical heart condition.

Correct beats recognition is impeded by power-line interference, electromyogram noise and baseline wander often present in the ECG signal.

In long-term monitoring electrode impedance can increase considerably, resulting in very low signal-to-noise ratio, which can make detection practically impossible in a single lead. Therefore, usually two or three leads are used for monitoring [1].

Friesen et al. [2] have presented a comparison of nine QRS detection algorithms, based on: i) amplitude and first derivative, ii) first derivative only, iii) first and second derivative, and iv) digital filtering. Daskalov et al. [3] applied these algorithms to selected signals containing records with pronounced baseline drift. The results were unsatisfactory, which was probably due to the use of fixed detection thresholds, whereas adaptive ones would be more appropriate.

Poli et al. [4] used a generic algorithm for QRS detection. The complexes were emphasized with respect to the rest of the signal by polynomial filters and compared to an adaptive threshold. The authors reported 99.60 % sensitivity (Se) and 99.51 % specificity (Sp) with the MIT-BIH Arrhythmia Database. The method is inapplicable in real-time.

Afonso et al. [5] proposed hardware filter banks for ECG signal decomposition, where several parameters were independently computed and combined in a decision rule. The authors reported Se = 99.59 % and Sp = 99.56 % for their real-time, single-channel beat detection algorithm tested with the MIT-BIH Arrhythmia Database.

Dotsinsky and Stoyanov [6] developed a heuristic, pseudo-real-time algorithm for ventricular beat detection for single-channel ECG, based on steep edges and sharp peaks evaluation criteria. They reported Se = 99.04% and Sp = 99.62%, obtained with two channel recordings from AHA and MIT-BIH Arrhythmia Database

Moraes et al. [1] combined logically two different algorithms working in parallel – the first has been taken from the work of Englese and Zeelenberg [7] and the other was based on Pan and Tompkins [8], and Ligtenberg and Kunt [9]. Moraes et al. [1] reported Se = 99.22 % and Sp = 99.73 % after having excluded records of patients with pacemaker. After excluding a few more recordings 108, 200, 201 and 203, containing high amplitude noise (according to the authors), the statistical indices rises to Se = 99.56 % and Sp = 99.82 %.

Li et al. [10] have used wavelet transforms for detection. They reported 0.15 % false detections out of 46 files from the MIT-BIH Arrhythmia Database, but with exclusion of files 214 and 215. In addition, we found some errors in their Table II. After correction, the reported accuracy slightly decreased.

The large variety of QRS detection algorithms, and the continuous efforts for their enhancement, proves that universally acceptable solution has not been found yet. Difficulties arise mainly from the huge diversity of the QRS complex waveforms and the noise and artifacts accompanying the ECG signals.

ECG databases

All 48 ECG recordings of MIT-BIH Arrhythmia database were used, without exception. Each one has a duration of 30 min and includes two leads – the modified limb lead II and one of the modified leads V1, V2, V4 or V5 [11]. The sampling frequency is 360 Hz with resolution 5 μV/bit. Two cardiologists have annotated all beats. Approximately 70 % of the beats are annotated as Normal. Four of the records are from patients with pacemakers.

The American Heart Association (AHA) database was also considered, during the evaluation of the method, mostly due to the fact that it contains patients with premature ventricular beats of contraction of R-over-T type, some of them very difficult to detect because of their closeness to the previous complex. Statistical indices for this database are not derived, because they can be compared with limited number of articles working with AHA. The database consists of 80 recordings: 2-leads, 250 Hz sampling rate and 5 μV/bit resolution.

Method

The differentiated and summed signals from L leads are compared to the absolute value of a threshold MFR = M + F + R – a combination of three independent adaptive thresholds, where:

M – Steep-slope threshold;

F – Integrating threshold for high-frequency signal components;

R – Beat expectation threshold.

Two algorithms were developed:

Algorithm 1 detects at the current beat.

Algorithm 2 Pseudo-real-time detection with additional triggering of potentially missed heart beat in the last interval by RR interval analyses.

The algorithms are self-adjusting to the thresholds and weighting constants, regardless of resolution and sampling frequency used. They operate with any number L of ECG leads, self-synchronize to QRS or beat slopes and adapt to beat-to-beat intervals.

Preprocessing

• Moving averaging filter for power-line interference suppression: averages samples in one period of the power-line interference frequency with a first zero at this frequency.

• Moving averaging of samples in 28 ms interval for electromyogram noise suppression – a filter with first zero at about 35 Hz.

• Moving averaging of a complex lead (the sintesis is explained in the next section) in 40 ms intervals – a filter with first zero at about 25 Hz. It is suppressing the noise magnified by the differentiation procedure used in the process of the complex lead sintesis.

Complex lead

The algorithm operates with a complex lead Y of several primary leads L. In cases of 12-standard leads, synthesis of the three quasi-orthogonal Frank leads is recommended first [3,12], thus determining the complex lead as a spatial vector. The complex lead is obtained as:

where Xj(i) is the amplitude value of the sample i in lead j, and Y(i) is the current complex lead.

The above formula (except the normalizing coefficient 1/L and the absolute value) was initially adopted from the work of Bakardjian [13]. Operating with unsigned (absolute) values proved convenient when dealing with QRSs and extrasystoles having different, for example positive (in one lead) and negative (in the other lead) deflections.

Adaptive steep-slope threshold – M

• Initially M = 0.6*max(Y) is set for the first 5 s of the signal, where at least 2 QRS complexes should occur. A buffer with 5 steep-slope threshold values is preset:

MM = [M1M2M3M4M5],

where M1 ÷ M5 are equal to M.

• QRS or beat complex is detected if Yi MFR,

• No detection is allowed 200 ms after the current one. In the interval QRS ÷ QRS+200ms a new value of M5 is calculated:

newM5 = 0.6*max(Yi)

The estimated newM5 value can become quite high, if steep slope premature ventricular contraction or artifact appeared, and for that reason it is limited to newM5 = 1.1* M5 if newM5 > 1.5* M5.

The MM buffer is refreshed excluding the oldest component, and including M5 = newM5. M is calculated as an average value of MM.

M is decreased in an interval 200 to 1200 ms following the last QRS detection at a low slope, reaching 60 % of its refreshed value at 1200 ms.

• After 1200 ms M remains unchanged.

The thresholds definitions are presented in more detail with the help of several examples. Two ECG leads are shown in Fig. 1a. Detected QRSs are marked with 'red O' on Lead 1. The summary lead and the steep-slope threshold are represented in Fig. 1b.

thumbnailFigure 1. Adaptive steep-slope threshold

Adaptive integrating threshold – F

The integrating threshold F is intended to raise the combined threshold if electromyogram noise is accompanying the ECG, thus protecting the algorithm against 'erroneous beat detection'.

Initially F is the mean value of the pseudo-spatial velocity Y for 350 ms.

With every signal sample, F is updated adding the maximum of Y in the latest 50 ms of the 350 ms interval and subtracting maxY in the earliest 50 ms of the interval.

F = F + (max(Yin latest 50 ms in the 350 ms interval) - max(Yin earliest 50 ms in the 350 ms interval))/150

The way F is updated means that not every sample in the interval is integrated, but just the envelope of the pseudo-spatial velocity Y. The weight coefficient 1/150 is empirically derived.

Two ECG leads are shown in Fig. 2a. The pseudo-spatial velocity Y and the integrated threshold are presented in Fig. 2b. The correct detection is due to the rise of F (hence of MFR) with about 0.2 mV. The beat complex is included in the integration process (note the high rise of F after any of the complexes), thus making almost impossible a close detection to the previous complex.

thumbnailFigure 2. Adaptive integrating threshold

Adaptive beat expectation threshold – R

The beat expectation threshold R is intended to deal with heartbeats of normal amplitude followed by a beat with very small amplitude (and respectively with very small slew rate). This can be observed for example in cases of electrode artifacts. Conversely to the integrating threshold protecting against erroneous QRS detection, R is protecting against 'QRS misdetection'.

A buffer with the 5 last RR intervals is updated at any new QRS detection. Rm is the mean value of the buffer.

R = 0 V in the interval from the last detected QRS to 2/3 of the expected Rm.

• In the interval QRS + Rm * 2/3 to QRS + Rm, R decreases 1.4 times slower then the decrease of the previously discussed steep slope threshold (M in the 200–1200 ms interval).

• After QRS + Rm the decrease of R is stopped.

The time-course of the beat expectation threshold R is shown in Fig. 3. The decrease of R (respectively MFR) with about 0.2 mV at the fourth QRS allows its detection, despite the lack of complex in Lead 2, which leads to a two-fold decrease of the summary lead amplitude Y (Fig. 3b).

thumbnailFigure 3. Adaptive beat expectation threshold

Combined adaptive threshold – MFR

The combined adaptive threshold is a sum of the adaptive steep-slope threshold, adaptive integrating threshold and adaptive beat expectation thresholds. (Fig. 4)

thumbnailFigure 4. Combined adaptive threshold

MFR = M + F + R

Algorithm 2: pseudo-real-time detection with additional triggering of eventually missed heart beat in the last detected RR interval

All previous considerations relate to Algorithm 1, which detects a beat at its occurrence. Additional checking for an eventually missed heartbeat is performed by Algorithm 2. Its function is explained by the signal in Fig. 5. The fourth complex at the 15.2 s in Fig. 5b should be missed due to the fact that, MFR is greater then the summary lead Y.

thumbnailFigure 5. Pseudo-real-time detection with additional triggering of eventually missed heart beat in the last RR interval.

Let's mark the previous RR interval with t1 and the last – with t2 (Fig. 5a).

If t1 is not shortened, which is tested by logic OR of the 2 conditions t1>Rm OR Rm-t1<0.12*Rm AND in the same time t2 is quite long to fulfill the condition abs(t2-2*Rm)<0.5*Rm, the interval is subjected to check for a missed complex.

A test is performed on each of the primary leads where a sharp peak is searched (defined as a product > 4 μV of two signal differences having one central and two lateral points 8 ms apart). If the test is passed, a second one is carried out for the amplitude of the summary lead at that point, which should be bigger then 1/3 of the mean value of the buffer MM, in order to define this point as a missed QRS complex.

Results and discussion

Normally the statistical indices Se and Sp are derived from the following parameters: correctly detected beats TP (true positive), falsely detected beats FP (false positive) and undetected beats FN (false negative). In addition, we used two parameters, adopted from Dotsinsky and Stoyanov [6], as described below.

SP – shifted positive error was introduced in order to explain cases like the one shown in Fig. 6. Here the algorithm made a false positive error before the 3rd QRS and missed the following QRS. Formally, this is a false positive error, immediately followed by a false negative. However, if the time interval between these two detections is reasonably short, for example ≤ 200 ms, we accepted this as one error only, labeled as Shifted False Positive Error (SP).

thumbnailFigure 6. Shifted positive error at the P wave

Another example of SP error as a result of artifacts just before the normal complexes is shown in Fig. 7.

thumbnailFigure 7. Shifted positive errors, false positive + false negative twins

SN – shifted negative error was assumed by the same principle as SP, but in the opposite sense. It also included twin FN+FP error occurring within 200 ms. The first incoming FP or FN error of the shifted is defining it as SP or SN.

The logic of using shifted errors (instead of FP and FN or FN and FP in cases when they appear within 200 ms of each other) is that thus the total number of beats in a record retains its value. Otherwise it would change depending on the type and number of errors and thus impede correct computation of Se and Sp.

The sensitivity Se is calculated by summing FN SN, while the specificity Sp – by summing FP+SP.

The method was developed in Matlab. All 48 recordings from the MIT-BIH Arrhythmia database, without any exception, were used for testing the two algorithms.

The processed files containing detection marks were automatically compared with the original MIT-BIH annotated beats by specially designed software. It shows all cases where the annotation and detection marks differ by more than 60 ms. These cases were examined by an independent expert, thus excluding possible author's influence.

The results for the two algorithms are presented in Table 1.

Table 1. Statistical results for the two algorithms

Of all 110050 annotated beats ('unknown' or 'questionable' were excluded from the study), true detected are 109548 for Algorithm 1 and 109616 for Algorithm 2. The statistical indices are:

Algorithm 1: Se = 99.69 %, Sp = 99.66 %;

Algorithm 2: Se = 99.74 %, Sp = 99.65 %.

The standard way of Se and Sp calculation,

considering the joint SP and SN errors as two separate errors gives the following results:

Algorithm 1: Se = 99.54 %, Sp = 99.61 %;

Algorithm 2: Se = 99.60 %, Sp = 99.60 %.

Algorithm 2 improved the sensitivity by 0.05 % (0.06 % for the standard evaluation) as a result of decreased number of undetected beats. This result can be observed for example in recordings 109,203, 210 and 223, where the additionally detected beats are respectively 6, 9, 12 and 5. The performance of both algorithms was especially tested with the file A5001 from the AHA containing R-over-T premature ventricular complexes, very close to the previous normal QRS complex (Fig. 5a). An improvement of 74 undetected by Algorithm 1 R-on-T complexes was observed. The detection of such premature ventricular complexes occurring at the time of ventricular repolarization was considered important, having in mind possible risk of ventricular fibrillation triggering by R-on-T events.

Conclusions

The proposed algorithms for real-time and pseudo-real-time implementation are adaptive, independent of thresholds and constants values. They are self-synchronized to the QRS steep slope and the heart rhythm, regardless of the resolution and sampling frequency used. Due to the integration threshold, the algorithms are practically insensitive to electromyogram and similar high-frequency noise.

The algorithms can operate with one, two or more leads, using a combined lead signal derived from the sum of absolute values of the differentiated lead signals.

The statistical indices are higher than, or comparable to those, cited in the scientific literature.

Acknowledgements

The author gratefully acknowledges the contribution of Prof. Ivan Dotsinsky, Centre of Biomedical Engineering, Bulgarian Academy of Sciences, for examining and testing the results of the proposed algorithms.

References

  1. Moreas JCTB, Seixas MO, Vilani FN, Costa EV: A QRS complex detection algorithm using electrocardiogram leads.

    Comp in Card 2002, 29:205-208. OpenURL

  2. Friesen GM, Jannett TC, Jadallah MA, Yates SL, Quint SR, Nagle HT: A comparison of the noise sensitivity of nine QRS detection algorithms.

    IEEE Trans on Biomed Eng 1990, 37:85-98. Publisher Full Text OpenURL

  3. Daskalov IK, Dotsinsky IA, Christov II: Developments in ECG acquisition, preprocessing, parameter measurement and recording.

    IEEE Eng in Med & Biol 1998, 17:50-58. Publisher Full Text OpenURL

  4. Poli R, Cagnoni S, Valli G: Generic design of optimum linear and nonlinear QRS detection.

    IEEE Trans on Biomed Eng 1995, 42:1137-1141. Publisher Full Text OpenURL

  5. Afonso VX, Tompkins WJ, Nguyen TQ, Luo S: ECG beat detection using filter banks.

    Trans Biomed Eng 1999, 2:192-201. Publisher Full Text OpenURL

  6. Dotsinsky I, Stoyanov T: Ventricular beat detection in single channel electrocardiograms. [http://www.biomedical-engineering-online.com/content/3/1/3] webcite

    BioMed Eng OnLine 2004, 3:3. PubMed Abstract | BioMed Central Full Text | PubMed Central Full Text OpenURL

  7. Englese WAH, Zeelenberg C: A single scan algorithm for QRS detection and feature extraction.

    IEEE Comp in Card 1979, 37-42. OpenURL

  8. Pan J, Tompkins W: A real-time QRS detection algorithm.

    IEEE Trans Biomed Eng 1985, 32:230-236. PubMed Abstract OpenURL

  9. Ligtenberg A, Kunt M: A robust-digital QRS detection algorithm for arrhythmia monitoring.

    Computers and Biomed Res 1983, 16:273-286. Publisher Full Text OpenURL

  10. Li C, Zheng C, Tai C: Detection of ECG characteristic points using wavelet transforms.

    IEEE Trans on Biomed Eng 1995, 42:21-28. Publisher Full Text OpenURL

  11. Mark R, Moody G: MIT-BIH Arrhythmia data base directory.

    Cambridge: Massachusetts Institute of Technology 1988. OpenURL

  12. Levkov C: Orthogonal electrocardiogram derived from the limb and chest electrodes of the conventional 12-lead system.

    Med Biol Eng Comput 1987, 25:155-164. PubMed Abstract OpenURL

  13. Bakardjian H: Ventricular beat classifier using fractal number clustering.

    Med Biol Eng Comput 1992, 30:495-502. PubMed Abstract OpenURL