You are on page 1of 4

An Effective QRS Detection Algorithm for Wearable ECG in Body Area Network

Fei Zhang, Jun Tan, and Yong Lian


ECE Dept. of National University of Singapore Singapore 119260 {elezf, eletanj, eleliany}@nus.edu.sg
AbstractA novel QRS detection algorithm for wearable ECG devices and its FPGA implementation are presented in this paper. The proposed algorithm utilizes the hybrid openingclosing mathematical morphology filtering to suppress the impulsive noise and remove the baseline drift and uses modulus accumulation to enhance the signal. The proposed algorithm achieves an average QRS detection rate of 99.53%, a sensitivity of 99.82% and a positive prediction of 99.71% against the MIT/BIH Arrhythmia Database. It compares favorably to published methods.

I.

INTRODUCTION

achieves very high detection accuracy with low hardware cost. The standard MIT/BIH ECG database [9] and other exercise ECG data sets are used to verify the superiority of proposed QRS detection method. This paper is organized as follows. In Section II, we give a brief introduction of mathematical morphology filtering, which serves as a basis for the proposed algorithm. In Section III, we present the new algorithm and discuss the details of the algorithm. The circuit implementation is described in Section IV and the evaluation of the algorithm is presented in Section V. Conclusion remarks are drawn in Section VI. II. MATHEMATICAL MORPHOLOGY

The electrocardiogram (ECG) signal, which represents the electrical activity of the heart, is widely used for diagnosis of cardiac health. Among the three main components known as P, QRS and T waves for a typical ECG, the most characteristic wave set is the QRS complex recording the depolarization phenomenon of the ventricles. The detection of QRS complex is the first step towards analyzing ECG signal. However, ECG signal is frequently corrupted by powerline interference, baseline drift, motion artifact and electromyographic interference. Therefore, reliable and accurate detection of QRS complex is gaining momentum nowadays. Recently, much research effort has been devoted into the development and evaluation of QRS detectors [1], [2]. The Body Area Network (BAN) is envisaged as a new wave of technology that will make a great impact to personalized healthcare. The development of BAN-based devices is generally restricted by size, power consumption, and computational power. In order to design wearable ECG devices for BAN application, it is necessary to develop a simple and accurate QRS detection algorithm. Mathematical morphology technology originated from 2-D image processing [3], [4] has demonstrated the potential in the removal of impulsive noise and background normalization [5]-[8]. In this paper, we introduce a novel hybrid mathematical morphology filter by combining opening and closing operations for QRS detection. The proposed method
This work was supported by the research grants 052-118-0060 and 052-118-0057 from Singapore Agency for Science Technology and Research (A*STAR) under Thematic Strategic Research Program: Embedded & Hybrid System II and the Faculty of Engineering of National University of Singapore grants R-260-000-373-731 and R-260-000-374731.

Mathematical morphology, based on set operations, is an effective way of analyzing signals through nonlinear signal processing operators that incorporate geometry information. The geometry information of the signal is extracted by using a user defined structure element. Such operators serve two purposes, i.e. extracting the useful signal and removing the artifacts. There are four basic mathematical morphological operators: Dilation, Erosion, Opening and Closing. In most applications, opening is used to suppress peaks while closing is used to suppress pits. Opening and closing operations work as morphology filters with clipping effects, i.e. cutting down peaks and filling up valleys. The elementary mathematical morphology operators for signal f ( x) are listed below for easy reference, i.e. (1) Dilation: f g ( x) = max[( f ( x i) + g (i )]
(i )

Erosion: f g ( x ) = min[( f ( x + i ) g (i )]
(i )

(2) (3) (4)

Opening: Closing:

f D g ( x) = f g (g )( x)

f g ( x) = f g ( g )( x)

1-4244-1525-X/07/$25.00 2007 IEEE

195

where g ( x) is a predefined structure element. Opening and closing provide an intuitively simple way for peak or valley extraction. III. THE PROPOSED QRS DETECTION ALGORITHM

5(b) for various ECG signals where QRS peaks are well preserved while baseline drift is removed. B. Enhancing ECG by Modulus and Combination The absolute value of the output is combined by multiple-frame accumulation, which is much alike energy transformation [10], [11]. The process is expressed as,

QRS complexes are composed of a group of consecutive positive and negative peaks. The block diagram of the proposed algorithm is shown in Fig. 1. The proposed hybrid morphology operator filtering plays the most critical role in the proposed algorithm which removes the noise in ECG signal. Modulus and multiple-frame accumulation further enhance the QRS signal leading to accurate QRS detection. The detailed discussions on each component in Fig. 1 are presented in the following sub-sections.
Input

s (n) =

q n+ 2 q i =n 2

TB (i ) ,

(6)

where x denotes the smallest integer less than or equal to x. The value of q should correspond to the possible maximum duration of normal QRS complex. This step further enhances the filtered ECG signal to make QRS peaks easy to identify as shown in Figs. 3(c), 4(c), and 5(c) in Section V. C. Threshold and decision An adaptive threshold is used as the decision function in connection with the proposed transformation for QRS detection. By experiment, it is found that the required threshold is a function of the maximum of the transformed ECG waveform. IV. CIRCUIT IMPLEMENTATION

Opening

Closing

Average

Modulus& Accumulation

Peak-Valley Extractor

Thresholding &Decisions

Output

Fig. 1 Block diagram of the proposed algorithm A. Hybrid morphology operator In order to accurately detect QRS complex, we introduce a novel peak-valley extractor by combining opening and closing operations. The proposed hybrid morphology operator is defined as, 1 (5) TB [ f ( n ) ] = f ( n ) [ f D g ( n ) + f g ( n ) ].
2

Since the opening and closing operators behave as a morphological filter that suppresses peaks and valleys, (5) effectively removes the baseline drift if a proper structure element is selected. The selection of structure element should be done in such a way that it reduces the baseline drift but keeps QRS peaks undistorted. This feature is clearly demonstrated in Section V through Figures 3(b), 4(b), and

The proposed algorithm can be easily implemented by shift registers, adder, comparator, and some control logics as shown in Fig.2. The pivotal modules of this algorithm are the dilation and erosion, which are defined in (1) and (2). Suppose the function g (.) has a finite length of n. The computation of dilation is carried out as follows. At each positive edge of clock, the output of the adder is compared with the number stored in the max register. If the sum of f (.) and g (.) is larger than the number in the max register, the max register is updated with the new output from the adder. After n clock cycles, the result of the max register is latched into the output register. The operation of erosion is done in the similar way as dilation operation. The dilation or erosion operation requires n clock cycles if it is done in a serial fashion. Therefore the clock frequency should be n times faster than that of the sampling rate of ECG. This serial structure reduces the number of adders and hence simplifies the circuits. The opening and closing operations can be fulfilled by cascading the dilation and erosion units together. The rest parts of the circuits can be easily implemented with shift registers and adders, and therefore are not discussed in detail in this paper. The overall implementation of proposed algorithm is verified using the Xilinx Virtex-4 FPGA evaluation board ML401. The total gate count of the circuit

196

ECG (mV)

is about 13000 for the 12-bit ECG input signal. The FPGA can successfully detect the QRS complex as expected.

f(1)

g(1) g(2)

...

g(n-1)

g(n)

ECG (mV)

f(2)

...

f(n-1)

f(n)

0.0 -0.5 -1.0 -1.5 -2.0 0.2 0.1 0.0 -0.1 -0.2 0.9 0.6 0.3 0.0 -0.3

(a)

(b)

10

ECG (mV)

8
(c)

10

Adder/Subtractor Timing Contol Max/Min Register Comparator Output Register

6 Time (Sec)

10

Fig. 4 Detection results using MIT/BIH Tape 117.


1.0 0.5 0.0 -0.5 0.10 0 0.05 0.00 -0.05 0 0.9 0.6 0.3 0.0 0 ECG (mV)
(a)

Fig. 2. Circuit diagram of the dilation/erosion unit. V. EXPERIMENT RESULTS

10

12

14

16
(b)

The MIT/BIH Arrhythmia database provided by MIT and Bostons Beth Israel Hospital is used for evaluation of the proposed QRS detection algorithm. It contains 48 half-hour recordings sampled at 360 Hz with 11-bit resolution over a 10-mV range. Table 1 shows the summary of results of QRS detection using various recordings from the MIT/BIH database. Figs. 3 and 4 give detection examples performed over tapes from MIT/BIH database. Fig.5 shows the detection result from ECG data collected by a Welch Allyn PCE-200i PC-Based Exercise Stress System sampled at 600 Hz. Figs 3(a), 3(b) and 3(c) represent original ECG signal, output data stream from the peak-valley extractor, and data stream from the modulus accumulation, respectively. Figs. 4 and 5 follow the similar format. It is obvious that the proposed algorithm correctly detects the QRS of ECG, even under the presence of severe noise, baseline drift and large P/T waves.
ECG (mV) 1 0 -1 -2 0.3 0 0.2 0.1 0.0 -0.1 2.0 0 1.6 1.2 0.8 0.4 0.0 0 2 4 6 8
(a)

ECG (mV)

10

12

14

ECG (mV)

(c)

16

8 10 Time (Sec)

12

14

16

Fig. 5 Detection results using the wearable ECG device during running To evaluate the performance of detection algorithm, several performance indexes are introduced including false negative (FN) which means failing to detect a true beat (actual QRS), and false positive (FP) which represents a false beat detection. By using FN and FP, the Sensitivity (Se), positive prediction (+P) and detection error (DER) can be calculated using the following equations, respectively.

ECG (mV) ECG (mV)

10
(b)

Se(%) =

TP , TP + FN

(7)

10
(c)

+ P (%) =
DER(%) =

TP , TP + FP

(8)

4 6 Time (Sec)

10

FP + FN , TotalQRS

(9)

Fig. 3

Detection results using MIT/BIH Tape 105.

where true positive (TP) is the total number of QRS correctly detected by the algorithm.

197

An average QRS detection rate of 99.53 %, a sensitivity of 99.82% and a positive prediction of 99.71 % are obtained against the 20 recordings of MIT/BIH database as listed in Table I. The tape 105 is the most difficult one for analysis due to large induced noises and is widely used by researchers to test the QRS detection algorithm. Table II compares the existing algorithms with the proposed one by using tape 105 as a base. It is obvious that the reliability of the proposed detector compares very favorably with published results of other QRS detection algorithms. TABLE I Performance for proposed algorithm
Tape 100 101 102 103 105 106 107 109 111 112 113 114 115 117 119 Avg Total 2273 1865 2187 2084 2572 2027 2137 2532 2124 2539 1795 1879 1953 1535 1987 31489 FN 0 0 0 0 17 21 0 3 5 0 9 2 0 0 0 57 FP 0 0 0 1 26 22 16 6 4 1 9 6 0 3 0 94 Se(%) 100 100 100 100 99.34 98.96 100 99.88 99.76 100 99.50 99.89 100 100 100 99.82 +P(%) 100 100 100 99.95 98.99 98.92 99.26 99.76 99.81 99.96 99.50 99.68 100 99.80 100 99.71 DER(%) 0 0 0 0.05 1.67 2.12 0.75 0.36 0.42 0.04 1.00 0.43 0 0.20 0 0.47

QRS detection rate of 99.53%, a sensitivity of 99.82% and a positive prediction of 99.71%. In comparisons with published methods, the proposed algorithm demonstrates a better detection rate. REFERENCES
[1] G.M. Friesen, T. C. Jannett, M.A. Jadallah, S.L. Yates, S.R.Quint, and H.T. Nagle, A comparison of the noise sensitivity of nine QRS detection algorithms, IEEE Trans. Biomed. Eng., vol. 37, pp. 85-98, Jan.1990. B-U Kohler, C Hennig, and R Orglmeister, The principles of software QRS detection, IEEE Eng. in Medicine and Biology Magazine, vol. 21, pp. 42-57, Jan. 2002. A. Gasterators, I. Andreadis., and Ph. Tsalides, Fuzzy soft mathematical morphology, IEEE Proc. Vis. Imag. Signal processing, vol. 145, pp. 41-49, Feb. 1998. F. Zhang, C. Li., and L. Shi, Detecting and tracking dim moving point target in IR image sequences, Infrared Phys. and Technol. , vol. 46, pp.323-328, Apr. 2005 P. E. Trahanias, An approach to QRS complex detection using mathematical morphology, IEEE Trans. Biomed. Eng., vol. 40, pp. 201-205, Feb.1993 C-H. N. Chu and E. J. Delp, Impulsive noise suppression and background normalization of electrocardiogram signals using morphological operators, IEEE Trans. Biomed. Eng., vol. 36, pp. 262-273, Feb.1989 W. Hu, W. Yu, and A. Luo, Impulsive noise suppression using morphological operators, in Proc. of the IEEE Conf. Aerospace and Electron., vol. 1, pp.336-339, Feb.1995 F. Zhang, Y. Lian, Electrocardiogram QRS detection using multiscale filtering based on mathematical morphology, in Proc. of the 29th Annual International Conf. of the IEEE EMBS, Lyon. France, pp.3196-3199, Aug. 2007 Available:http://www.physionet.org/physiobank/database/mitdb/ N.V. Thakor, J. G. Webster, and W. J. Tompkins, Optimal QRS detector, Med. Bio. Eng. Comput, vol.21, pp.343-350, May. 1983. F. Gritzali, Towards a generalized scheme for QRS detection in ECG waveforms, Signal Processing, vol. 15, pp.183-192, Sep. 1988. R. Poli, S. Cagnoni, and G. Valli, Genetic Design of optimum linear and nolinear QRS Detectors, IEEE Trans. Biomed. Eng., vol. 42, pp. 1137-1141, Nov.1995 J. Pan, and W.J. Tompkins, A real time QRS detection algorithm, IEEE Trans. Biomed. Eng., vol. 32, pp. 230-236, Mar.1985 S. Chen, H. Chen, and H. Chan, A real-time QRS detection method based on moving-averaging incorporating with wavelet denosing, Comput. methods and programs in biomedicine, vol. 82, pp. 187-195, Mar. 2006 V. X. Afonso, W.J. Tompkins, T. Q. Nguyen, and S. Luo, ECG beat detection using filter banks, IEEE Trans. Biomed. Eng., vol. 46, pp. 192-201, Feb.1999 P.S. Hamilton, and W.J. Tompkins, Quantitative investigation of QRS detection rules using the MIT/BIH arrhythmia database, IEEE Trans. Biomed. Eng., vol. 33, pp. 1157-1165, Mar.1986 Q Xue, Y.H. Hu, and W.J. Tompkins, Neural-network-based adaptive filtering for QRS detection, IEEE Trans. Biomed. Eng., vol. 39, pp. 315-329, Apr.1992 A. Ruha, S. Sallinen, and S. Nissila, A real-time microprocessor QRS detector system with a 1-ms tiing acauracy for the measurement of ambulatory HRV, IEEE Trans. Biomed. Eng., vol. 44, pp. 159167, Feb.1997. J. Lee, K. Jeong, J. Yoon, and M. Lee, A simple real-time microprocessor QRS detection algorithm, in Proc. of the 18th Annual Int. Conf. of the IEE Eng. and Med. And Biomed Society, pp. 1396-1398,1996.

[2]

[3]

[4]

[5]

[6]

[7]

[8]

[9] [10] [11] [12]

TABLE II. PERFORMANCE COMPARISON WITH PUBLISHED ALGORITHMS


Method Genetic algorithm Band pass filter(BPF) Wavelet de-nosing Filter banks BPF/search-back Linear adaptive filter Optimized filtering Topological mapping Proposed method FP 86 67 78 53 53 40 35 41 26 FN 5 22 5 16 22 22 21 4 17 DER(%) 3.54 3.46 3.23 3.22 2.91 2.41 2.18 1.75 1.67 Ref [12] [13] [14] [15] [16] [17] [18] [19] ----

[13] [14]

[15]

[16]

[17]

[18]

VI.

CONCLUSION
[19]

This paper has presented a novel algorithm for QRS detection based on mathematical morphology and modulus accumulation and its implementation. The algorithm is evaluated with MIT/BIH standard ECG database to achieve a

198

You might also like