Low Power and Cost Real Time Implementation of QRS Detection ...

2 downloads 0 Views 308KB Size Report
Pan and Tompkins algorithm of QRS detection is an established method for .... higher frequencies, by passing through a squaring stage [5], which have (9) as ...
Low Power and Cost Real Time Implementation of QRS Detection Algorithm Using Stellaris LM4F120H5Q Hakima Timlelt, Cherif Zizoua, Amine Righi, Samir Boukhenous, Youcef Remram, Akram Hafid and Mokhtar Attari Faculty of Electronics and Computer Engineering University of Sciences and Technology Houari Boumediene BP32 El- Alia 16111, Algiers, ALGERIA

Abstract—The extraction of the QRS waveform from the electrocardiogram (ECG) signal is an important part for cardiac disease detection. Pan and Tompkins algorithm of QRS detection is an established method for extraction of this part of ECG. This paper proposes a real time implementation of this algorithm using new technology of low power and cost micro-controller. Index Terms—QRS detection, real time, hardware implementation, Stellaris LM4F120H5Q.

three sections, the first section gives details description of the implemented algorithm, the second section gives a details the of the ECG acquisition and the real time implementation of the algorithm in the chosen processor. In the last section, the results obtained after treatment of the signal are expressed, at the end a conclusion and future work is given. II. A LGORITHM D ESCRIPTION

I. I NTRODUCTION The information which are contained in the ECG signals are of great importance for a doctor since it can inform him about heart diseases. The analysis of such signals manually is hard and requires a lot of attention and time spending, that why a large number of algorithms proposed in literature to automatically process these signals. Most of these algorithms proceed on two steps, the first one is the pre-treatment and the second is the decision. Pan and Tompkins algorithm for QRS detection [1] is one of the first and popular algorithm that appeared in the literature; many works based on this algorithm have been proposed in the literature. Among this algorithm we find an approach proposed by Benitez et al. [2], they designed an algorithm based on the hilbert transform. Sherya in [3] proposed also a QRS detection Algorithm using Savitzky-Golay filter, their algorithm is based in the same idea as in [1], their contribution is that the high pass filter and differentiator filters were replaced by a Savitzky Golay filter based on the recursive minimization of the filter coefficient, with this filter, the residual peaks that appear on the signal are suppressed, however, using a Savitzky Golay filter the real time execution of the algorithm is lost. These algorithms are implemented mostly on field programmable gate array (FPGA) using a Verilog hardware description Language (HDL) [4]. In our paper, we propose a real time implementation of Pan and Tompkins algorithm [1] on Stellaris LM4F120H5Q of TEXAS INSTRUMENTS which is provided with a low cost and low power ARM CORTEX M4 micro-controller using a C language and the IDE code composer studio. A graphical user interface is designed using a GUI Tool of MATLAB where the results are shown on. The paper is structured in

The pre-treatment of this algorithm consist on filtering the ECG signals acquired by development board, A band pass filter is used, it is designed by cascading a low pass and a high pass filter in order to eliminate the noise in the signal. after the filtered signal is passed through the derivative filter, Then squaring and integration filter are used as shown in Fig.1. For the decision step, a threshold technique will be applied to detect the R-peaks [1].

Fig. 1. Block Diagram of the different steps of the QRS detection.

A. Bandpass Filter This filter was designed in order to reduce influence of muscle noise, 50 Hz interference, baseline wander and T wave interference [1] [2], its bandwidth is at around 5 to 15 Hz i.e. where the energy of QRS will peak, also it was designed from special class of digital filters that require only integer coefficients that ensures a prompt data treatment by a microprocessor, permitting a real time QRS detection . An inability to design this bandpass filter for a chosen samples

rate, oblige us to use a low pass and high pass cascaded filters [1]. The transfer function of a second order low pass filter is shown in Eq.(1) . 2

H(Z) =

(1 − z 6 )

(1) 2 (1 − z −1 ) The cut-off frequency of the filter is 11 Hz, the delay is 5 samples and the gain is 36 [1]. The differential equation of the filter is given in (2). y(nT ) =2y(nT − T ) − y(nT − 2T ) + x(nT )−

(2) Fig. 2. Block diagram of the ECG measuring

2x(nT − 6T ) + x(nT − 12T ) The high pass filter is a result of subtracting the low pass filter from an all pass filter [1]. Eq.(3) represent the transfer function of the low pass filter. Hlp (z) =

Y (z) (1 − z 32 ) = X(z) 1 − z −1

(3)

The transfer function of the high pass filter is derived as shown in (4). P (z) Hlp (z) Hhp (z) = = z −16 − (4) X(z) 32 The final equation is shown in (5). −1 32

(5)

x(nT ) + x(nT − 16T ) (6) 32 x(nT − 32T ) − x(nT − 17T ) + 32 The low cut-off frequency is about 5 Hz, and the gain is one with a delay of 16T, (80 ms) [1]. y(nT ) =y(nT − T ) −

B. Derivative To provide the QRS complex slope information a five point derivative was used with the transfer function [1]. H(z) = 0.1(−2z −2 − z −1 + z 1 + 2z 2 )

(7)

(8)gives the temporal equation of (7) 2x(nT ) + x(nT − T ) − (8) 8 x(nT − 3T ) − 2x(nT − 4T ) 8 The best approximation of the actual gain factor 0.1 was the fraction 18 , to permit fast power-of-calculation. An ideal derivative between dc and 30 Hz, was approximated by this derivative. it has a filter delay of 2T (10 ms) [1]. y(nT ) =

C. Squaring The output of derivative undergoes a non linear amplification, which makes all data points positive, and emphasizes the higher frequencies, by passing through a squaring stage [5], which have (9) as equation. y(nT ) = [x(nT )]2

In order to obtain waveform feature information, the algorithm performs sliding window integration [1], which was implemented with the equation represented by (10) . 1 [x(n − (N − 1)) + x(n(N − 2)) + ...x(n)] (10) N Where N is the size of sliding window and depends on the sampling rate. For a sampling rate of 200 samples/sec the size of the window can be 30 samples. y(n) =

E. Threshold

−32

+ z −16 − z −17 + z 32 Hhp (z) = 1 − z −1 The equation used for the implementation is given by:

D. Integration Window

(9)

The aim of this step is to find and identifies a QRS complexes, by conducting two types of thresholds. the role of the higher is to identifies a peaks of the signal, in case where no peaks was detected by the first one in certain time interval, the lower threshold do a search back in time for a lost peak [1],signal changing direction within a predefined time interval that implies this a new peak is detected,it represent a local maximum, then if this peak exceeds the high threshold (or the low threshold if we search back in time for a lost peak), it is classified as a signal peak, otherwise it represent a noise peak. [1]. III. I MPLEMENTATION The algorithm was written on C language by using a Code Composer Studio (CCS),the Micro- controller was configured as: 12 bits ADC for the acquisition and a serial port to transmit and receive data from the graphical interface, after that, we started the implementation of algorithm filters as a function by using a difference equation of every filter to put them in cascade, where the output of one is the input of the other, without using a DSP library to have more flexibility in the algorithm. The Figs.3 and 2 represent the block diagram and the flowchart of the implementation steps. IV. T EST AND C OMPARISON The tests were done using a signal from MIT-BIH Normal sinus Rhythm database, the signal was limited to one minute, this signal was acquired in the ideal conditions of noise (see Fig.4). All the steps cited in the previous section was applied to signal before QRS detection. In Fig.5, the results of filtering with a bandpass filter, we notice that all high frequency noise were attenuated. The results from the derivative filter

1 0.8

Bandpass Filter

0.6 0.4 0.2 0 −0.2 −0.4 0

1

2 3 Time (ms)

4

5

Fig. 5. Bandpass filter output

1 0.8

Fig. 3. Flowchart of implementation Derivative filter output

0.6

1 0.8

ECG INPUT

0.6 0.4

0.4 0.2 0 −0.2 −0.4 −0.6

0.2 −0.8

0

−1 0

1

3

4

5

Time(ms)

−0.2 −0.4 0

2

1

2

3

4

Fig. 6. Output of derivative filter

5

Time(ms)

1

Fig. 4. Original signal 0.8

A second signal was used to test the robustness of the implementation, this signal is chosen a high noise. Figs.10 - 15 present the different steps of QRS detection. With this signal, the noise influence is more important but due to the adaptive threshold, all the peaks of the QRS complex are detected. V. C ONCLUSION The use of the new generation Stellaris LM4F120H5Q micro-controller based on Cortex M4, with a low power energy consumption for reel time implementation of QRS detection Algorithm, which allowed us to have an embedded system. The obtained results are similar to those obtained in the

Squaring

in Fig.6. The same results as in [1] are obtained, even if they implemented the algorithm on field programmable gate array.

0.6

0.4

0.2

0 0

1

2 3 Time (ms)

Fig. 7. Output of squaring filter

4

5

1

1

0.5 Bandpass filter

Integrator filter

0.8

0.6

0.4

0

−0.5

0.2

0 0

1

2

3

4

−1 0

5

1

2

3

4

5

Time(ms)

Time(ms)

Fig. 11. The noisy ECG passed through bandpass filter

Fig. 8. Output of moving intergarl window

1

1

0.8 0.6 Derivative filter

Peak detection

0.8

0.6

0.4

0.4 0.2 0 −0.2 −0.4

0.2

0 0

−0.6 −0.8 0

1

2

3

4

1

2

3

4

5

5

Time(ms)

Fig. 12. Noisy ECG, output of derivative filter

Fig. 9. Output of threshold 1 0.3 0.2

0.8 Squaring filter

ECG INPUT

0.1 0 −0.1 −0.2 −0.3

0.6

0.4

0.2

−0.4 −0.5 0

1

2

3

4

5

Time(ms)

0 0

1

2

3

4

5

Time(ms)

Fig. 10. Noisy ECG

Fig. 13. Noisy ECG, squaring

different implementations in the literature. As future work, we plan to study and compare the computation cost and performances of the used micro-controller.

R EFERENCES [1] J. Pan and W. J. Tompkins, “A real-time QRS detection algorithm.” IEEE Trans Biomed Eng, vol. 32, no. 3, pp. 230–236, Mar. 1985.

1

Integrator filter

0.8

0.6

0.4

0.2

0 0

1

2

3

4

5

Time(ms)

Fig. 14. Noisy ECG, output of moving integral window 1

0.8

Threshold

0.6

0.4

0.2

0 0

1

2

3

4

5

Time(ms)

Fig. 15. Noisy ECG, threshold output

[2] D. Benitez, P. A. Gaydecki, A. Zaidi, and A. P. Fitzpatrick, “A new qrs detection algorithm based on the hilbert transform,” in Computers in Cardiology 2000, 2000, pp. 379–382. [3] S. Das and D. M. Chakraborty, “Qrs detection algorithm using savitzky-golay filter,” ACEEE International Journal on Signal and Image Processing, vol. 3, no. 1, p. 4, January 2012. [Online]. Available: http://doi.searchdl.org/01.IJSIP.3.1.550 [4] C. Pavlatos*, A. Dimopoulos*, G. M. And, and G. Papakonstantinou, “Hardware implementation of pan & tompkins qrs detection algorithm1,” Tech. Rep. [Online]. Available: http://mule.cslab.ece.ntua.gr/docs/c8.pdf [5] W. J. Tompkins, Ed., Biomedical Digital Signal Processing: C-language Examples and Laboratory Experiments for the IBM PC. Upper Saddle River, NJ, USA: Prentice-Hall, Inc., 1993.

Suggest Documents