You are on page 1of 6

Full Paper ACEEE Int. J. on Information Technology, Vol. 3, No.

1, March 2013

FPGA based Heart Arrhythmias Detection Algorithm


Sheikh Md. Rabiul Islam, A. F. M. Nokib Uddin, Md. Billal Hossain, Md. Imran Khan
Dept. of Electronics and Communication Engineering Khulna University of Engineering &Technology Khulna, Bangladesh E-mail: robi@ece.kuet.ac.bd,nokib.ece@gmail.com, billal.0709018@gmail.com, imrankhankuet@gmail.com.
Abstract- Electrocardiogram (ECG) signal has been widely used for heart diagnoses .In this paper, we presents the design of Heart Arrhythmias Detector using Verilog HDL based on been mapped on small commercially available FPGAs (Field Programmable Gate Arrays). Majority of the deaths occurs before emergency services can step in to intervene. In this research work, we have implemented QRS detection device developed by Ahlstrom and Tompkins in Verilog HDL. The generated source has been simulated for validation and tested on software Verilogger Pro6.5. We have collected data from MIT-BIH Arrhythmia Database for test of proposed digital system and this data have given MIT-BIH data as an input of our proposed device using test bench software. We have compared our device output with MATLAB output and calculating the error percentage and got desire research key point of RR interval between the peaks of QRS signal. The proposed system also investigated with different database of MIT-BIH for detect different heart Arrhythmias and proposed device give output exactly same according to our QRS detection algorithm. Index Terms -Verilog HDL, QRS, ECG, MIT-BIH, Heart Arrhythmia.

I. INTRODUCTION Heart arrhythmias occurs when the electrical impulses in heart that coordinate your heartbeats dont work properly, causing your heart to beat too fast, too slow or irregularly [1]. Arrhythmias can take place in a healthy heart and be of minimal consequence but they may also indicate a serious problem that may lead to stroke or sudden cardiac death [23]. Heart arrhythmia treatment can often control or eliminate irregular heartbeats. There are hundreds of different types of heart arrhythmias among them common arrhythmias are atrial fibrillation (AF), Premature Atrial Contractions (PAC), Atrial Tachycardia, Atrial Fibrillation, Atrial Flutter, Premature Ventricular Contractions (PVC), Ventricular Tachycardia (VT), Ventricular Fibrillation. Electrocardiogram (ECG) is a diagnosis tool that reported the electrical activity of heart recorded by skin electrode. The morphology and heart rate meditates the cardiac health of human heart beat [4]. It is a noninvasive technique [5]. Any disorder of heart rate change in the morphological pattern is a reading of cardiac arrhythmia, after measure could be detected by analysis of ECG waveform. Whatever the magnitude and duration of the P-QRS-T wave contains useful information about the nature of the disease that affects the heart in this regard the electric wave is due to depolarization and polarization king of Na + and blood of the body ions human [5].The ECG signal provides important information of 2013 ACEEE DOI: 01.IJIT.3.1. 4 9

a human heart for detection of diseases [6]. To acquire the signal, ECG devices with varying number of electrodes (3 12) can be used. Multi lead systems exceeding 12 and up to 120 electrodes are also available [7]. The QRS complex is the largest deflection voltage of about 10 - 20 mV but may vary in size depending on age and sex of the human. The amplitude of the voltage of the QRS complex may also give information on heart disease [8]. Duration of the QRS complex indicates the time for the ventricles to depolarize and can provide information on problems conduction in the ventricles as the bundle branch block. The MIT-BIH [9] arrhythmia database is used for performance evaluation based on the study. The MIT-BIH database contains 48 disks, each containing two channels of ECG signals for 30 min duration of 24 hours selected from the recordings of 47 individuals. There are also data numbers 116.137 QRS complexes in the database [10]. The database record contains both timing information and class information heartbeat checked by independent experts [11]. Xilinx ISE [12],[13] is a software tool produced by Xilinx for synthesis and analysis of HDL designs, which enables the developer to synthesize designs, examine RTL diagrams, simulate a designs reaction to different stimuli, and configure the target device with the programmer. The building block were designed, tested and evaluated using the ISE tool available from Xilinx & VeriloggerPro6.5 (TestBencher pro)[14]. This paper is structured as follows. Section II describes the QRS detection algorithm. Section III part A describes about the Ahlstrom and Tompkins algorithm and section B for Arrhythmias detection process. In Section IV part A describes the bus architecture and section B is for describing modules. Section V shows simulation and synthesized result. Finally Section VI for conclusion. II. QRS DETECTION ALGORITHM Till now, various methods have been reported by researchers for detection of QRS complex [15-18], Algorithms [19-21] are based amplitude and the first derivative .In [20] a point is classified as QRS candidate when three consecutive points of the first derivative exceed a positive threshold (ascending slope) followed within the next 100ms by two consecutive points which exceed a negative threshold (descending slope). Algorithms [22] and [23] are based on the first derivative only. Algorithms [24-26] are based on the first and second derivatives. Ahlstrom and Tompkins in [24] proposed that the absolute values of the first derivative are smoothed and added with the absolute values of the second derivative.

Full Paper ACEEE Int. J. on Information Technology, Vol. 3, No. 1, March 2013 Balda [25] suggested searching values exceeding the threshold in a weighted summation of the first and second derivative, later this method was developed by Ahlstrom and Tompkins [24]. Friesen [27] and Tompkins [28] also investigated similar methods based on sensitivity of QRS complex to noise. There is several QRS detection method based on the digital filter [29-33], filter banks [34-35]. III. METHODOLOGY A. Basic QRS Complexes Detection Algorithm Among the so many algorithms we select first and second derivative based scheme developed by Ahlstrom and Tompkins [24] the rectified first derivative is calculated from the ECG: Y0(n)=ABS[X(n+1)-X(n-1)] 3<n<8188 the rectified first derivative is then smoothed: Y1(n)=[Y0(n-1)+2Y0(n)+Y0(n+1)]/4 3<n<8188 The rectified second derivative is calculated: Y2(n)=ABS[X(n+2)-2X(n)+X(n-2)] 3<n<8188 The rectified smoothed first derivative is added to the rectified second derivative: Y3(n)=Y1(n)+Y2(n) 3<n<8188 The maximum value of this array is determined and scaled to serve as primary and secondary thresholds: Primary threshold=0.8*max[Y3(n)] 3<n<8188 Secondary threshold=0.1*max[Y3(n)] 3<n<8188 The array of the summed first and second derivative is scanned until a point exceeds the primary thresholds. In order to be classified as a QRS candidate, the next consecutive point must all meet or exceed the secondary threshold. That is the threshold and QRS detection algorithm is just like bellow: Y3(i) >= primary threshold, and Y3(i+1), Y3(i+2) . . . . . . Y3(i+6) > secondary threshold After detecting the QRS complex we detect the R peak and R-R interval. There are several types of noise (i.e. muscle artifact, electrode motion artifact, white noise etc.) may hamper the ECG signal as well as the performance also. Performance of first and second derivative based method is much better than the first derivative methods [36]. B. Arrhythmias Detection For detection of Arrhythmias at first we need to know the heart rate of different Arrhythmias. Bellow table shows the heart rate for different arrhythmias. If the sampling frequency Fs Hz then, Time for one sample Ts= second
TABLE I. HEART RATE AND R-R I NTERVAL FOR D IFFERENT HEART ARRHYTHMIA.

functions of a data bus to carry information and address bus to determine where it should be sent and a control bus to determine its operation .The Bus architecture of the proposed digital system is shown in Figs.1-3.

Fig. 1. Block diagram of the system including data bus.

If R-R interval (in sample) is N samples then, R-R interval (in time) = Ts N second After calculating R-R interval we can detect heart Arrhythmia from Table. I. IV. PROPOSED ARCHITECTURE A. Bus Architecture A system bus is a single computer bus that connects the major components of a computer system. It combines the 2013 ACEEE DOI: 01.IJIT.3.1. 4 10

Fig. 2. Block diagram of the system including control bus and internal structure

In our system input and output is unidirectional to data bus. Input block take input data from data source and send it to data bus. Output block take data from data bus and show the output data.RAM, register A, register B and ALU are bidirectional that is it can send and receive data from data bus. In control bus architecture shown in Fig.2, control block determines the operation of rest of the block using control

Full Paper ACEEE Int. J. on Information Technology, Vol. 3, No. 1, March 2013
TABLE II. C ONTROL BUS FROM CONTROL R OM TO DIFFERENT MODULES.

Fig. 3. Block diagram of the system including Address bus.

bus except PC and PRO-PC. All other blocks are connected with control bus. Those connections are unidirectional. Connection between PRO-PC and PC represent the internal connection.In Fig.3 it shows the address bus architecture. RAM, PTR and P block are connected with address bus. The functions of these blocks are described in section IV (B).

B. Description of Different Modules. In our proposed design we have designed thirteen blocks. All function of those blocks is described below: 1. Pro-Program Counter (PRO-PC) It is a one kind of clock pulse generator and also a counter. It generates clock pulse for driving the Program counter (PC) from the main clock pulse. In this design it generates a pulse with one positive edge against four main clock pulses. That is Pro-PC force PC to provide same output several times. Output of Pro-PC is 2bit. 2. Program Counter (PC) A program counter is counter which count the clock. The main objective of this block is control the control block. Program counter take two bit input from Pro-PC and using clock signal it count 0 to 138.So the output of Program counter is 8bit.At the first time of counting it counts 0 to 12 sequences to take input six consecutive data sequentially. After that it counts 17 to 138 sequences to process six data and give output to output register. If it count 138 sequence it will start re-counting from 13-138 again and again in order to take two consecutive data input, process it and give output to output register. 3. Control ROM It is the ROM of our system. It take 8bit input from the Program Counter and give 36 bit output which is called control V. SIMULATION RESULTS & SYNTHESIS bus and connected almost all block to control their operation. Synthesis is the process of constructing a gate level Block diagram of control bus given in Fig.2 in previous netlist from a register-transfer level model of a circuit described section. Now bellow Table II shows the control bus structure. in Verilog HDL. After synthesizing in Xilinx project navigator Table II. Control Bus From Control Rom To Different Modwe got RTL schematic diagram of proposed design which is ules. shown in Fig.5. Fig.4 shows synthesized RTL schematic of 4. Input the top level of our proposed design. Simulation is the process In our system we use 16 bit input register to receive input of verifying the functional characteristics of models at any sampled value from the peripheral device & store the data level of abstraction. To test if the RTL code meets the temporarily. It can also send the data to the block called 11 2013 ACEEE DOI: 01.IJIT.3.1. 4

RAM to save the data permanently. 5. Register A & B These two 16 bit registers are used for to save the data temporarily & send the data to ALU or RAM. 6. ALU ALU is the arithmetic logic unit which is designed for doing addition, subtraction, shift left, shift right arithmetic calculations. In our proposed design ALU can process 16 bit data and save processed value to its internal register and can send it to reg A, B and RAM. 7. PTR PTR inform P block about the initial position of its parameter(X, Y0, Y1, Y2, and Y3) of the equation. Output of PTR is 4bit. 8. P P block select the RAM address for each parameter (X(n),Y0(n),Y1(n),Y2(n),Y3(n)).Output of P block is 4 bit. 9. Output It is a register which stands for saving the output data. We use 16 bit output register in our proposed design. 10. RAM RAM stands for random access memory. It is volatile memory to store temporary data.RAM is an array of register bank which is accessible (read and write) according to address. We use 192 bit RAM which contain 12 memory unit each unit have 16bit storage capability. From the data bus architecture shown in Figure.1 we can see that it can send and receive data from Reg. A, B, INPUT, ALU. That is connection between RAM and data bus is unidirectional. Table III shown that location and value of RAM according to the PTR and P block output.

Full Paper ACEEE Int. J. on Information Technology, Vol. 3, No. 1, March 2013
TABLE III. ADDRESS O F R AM FOR DIFFERENT PARAMETERS

Ahlstrom and Tompkins algorithm. Fig.10, 11 and 12 stands for normal ECG signal, Ventricular Tachyarrhythmia and Atrial fibrillation respectively.In order to measure R-R interval, we take 1100 samples for each signal. For normal ECG signal we use 360Hz sampling frequency and for other we use 250Hz.In Fig.10, R-R interval is 292 samples that is 0.76 (according to equation 1) seconds, so heart rate is approximately 79bpm that indicates it is normal ECG signal according to Table I.Similarly for Fig.11, heart rate is 120 bpm (Beats Per Minute) approximately which clearly indicates that is ventricular Tachyarrhythmia. In Figure.12 we can see that the R-R interval is not constant. As a result it can be concluded, it is atrial fibrillation.

functional requirements of the specification shown if all the RTL blocks are functionally correct. To archive this we need to write test bench which generates clk, reset and required test vectors. Figs. 6-9 shows test bench output for real ECG data input which is listed in Table III.

Fig. 6. Output for first eight consecutive input data

Fig. 4. Block Diagram of our proposed design

Fig. 7. Ninth data input to testbench.

Fig. 8. Output for ninth input data.

Fig. 5. RTL schematics of our proposed design.

For higher accuracy we multiply a gain factor with normal ECG data.In this work we used actual ECG records such as MIT100 from MIT-BIH database whereas we have given it as a input to testbench and collect output data as tabulated in Table IV.There are small deviation between testbench output and MATLAB output due to unablity to calculate floating point.This deviation is neglegible.In Figs.10- 12 shows by MATLAB output for QRS complex and R peak detection using 2013 ACEEE DOI: 01.IJIT.3.1. 4 12

Fig. 9. Output for tenth input data.

Full Paper ACEEE Int. J. on Information Technology, Vol. 3, No. 1, March 2013
TABLE IV. C OMPARE BETWEEN VERILOG T ESTBENCH AND MATLAB O UTPUT

The proposed model is loaded on XILINX FPGA board. It is implemented upon XILINX SPARTAN XC2S150 FPGA board processor. When it is implemented on FPGA board processor then the clock frequency of the processor is 1MHZ. The proposed model has the same power consumption, signal bandwidth and CMOS technology is used on the XC2S150 processor. CONCLUSIONS We have coded the equations of Ahlstrom and Tompkins method using Verilog Hardware Description Language. Try to detect the peak of two consecutive ECG waveform, found the time interval of R-R is detected. Compare with the time interval of R-R of normal cardiac conditions, the abnormalities of heart rate is determined. Some heart arrhythmias depends not only the R-R interval but also P, T wave. Our system cant detect those kinds of arrhythmias. We use VeriloggerPro6.5 (Test Bencher pro) demo version which has a limitation that it cannot simulate over 1225 line and show more than 26 consecutive outputs correctly. In future we will try to update our system for calculating floating point data and also use licence version of VHDL. REFERENCES
[1] Sandoe E, Sigurd B. Arrhythmiaa guide to clinical electrocardiology. Bingen: Publishing Partners Verlags GmbH, 1991. [2] Goldberger L, Goldberger E. Clinical electrocardiography. Saint Louis: The Mosby Company, 1977. [3] Sideris DA, Primary cardiology. Athens: Scientific Editions Grigorios K Parisianos, 1991 (in Greek). [4] J. Pan, W. J. Tompkins, A real time QRS detection algorithm, IEEE Trans. Biomed. Eng., vol. 32, pp. 230236, 1985. [5] Y.C. Yeha, and W. J. Wang, QRS complexes detection for ECG signal The Difference Operation Method (DOM), Computer methods and programs in biomedicine, vol. 9, pp. 245254, 2008. [6] P.de Chazal, M.O. Duyer, and R.B. Reilly, Automatic classification of heartbeat using ECG morphology and heart beat interval features, IEEE Trans. Biomed. Eng. vol. 51, pp. 1196-1206, 2004. [7] P. Zarychta, F. E. Smith, S. T. King, A. J. Haigh, A. Klinge, D. Zheng, S. Stevens, J. Allen, A. Okelarin, P. Langley, and A. Murray, Body surface potential mapping for detection of myocardial infarct sites, in Proc. IEEE Comput. Cardiol., Sep./Oct. 2007, pp. 181184. [8] P. de Chazal, R.B. Reilly, A patient-adapting heartbeat classifier using ECG morphology and heartbeat interval feature, IEEE Trans. Biomed. Eng. vol. 53, pp. 2535-2543, 2006. [9] D. A. Coast, R. M. Stern, G. G. Vano and S. A. Biller, An approach to cardiac arrhythmia analysis using Hidden Markov Model, IEEE Trans. Biomed. Eng., vol. 37, no. 9, Sep. 1990. [10] R. J. Schalkoff, Pattern Recognition: Statistical, Structural, and Neural Approaches, JOHN WILEY & SONS, INC., 1992. [11] T. H. Yeap, F. Johnson, and M. Rachniowski, ECG beat classification by a neural network, in Proc. Annu. Int. Conf. IEEE Engineering Medicine and Biology Society, 1990, pp. 14571458. [12] Samir palnitkar; Verilog HDL. SUNSOFT PRESS 1996.

Fig. 10. R peak detection for normal ECG signal

Fig. 11. R peak detection for Ventricular Tachyarrhythmia

Fig. 12. R peak detection for atrial fibrillation.

2013 ACEEE DOI: 01.IJIT.3.1. 4

13

Full Paper ACEEE Int. J. on Information Technology, Vol. 3, No. 1, March 2013
[13] XILINX, Internet site address: http://www.xilinx.com [14] TestBencher pro Internet site address: http:// www.syncad.com. [15] M. Benmalek, A. Charef, Digital fractional order operators for R-wave detection in electrocardiogram signal, IET Signal Processing, vol. 3, no. 5, pp. 381-391, Sept. 2009. [16] Q. Z. Xie, Y. H. Hu, and W. J. Tompkins, Neural-network based adaptive matched filtering of QRS detection, IEEE Trans. Biomed. Eng., vol. 39, pp. 317-329, 1992. [17] J. Pan and W. J. Tompkins, A real-time QRS detection algorithm, IEEE Trans. Biomed. Eng., vol. 32, pp. 230-236, 1985. [18] Fei Zhang, Yong Lian, QRS Detection based on multiscale mathematical morphology for wearable ECG devices in body area networks, IEEE Trans. on Biomed. Circuits and Systems, vol. 3, no. 4, pp. 220-228, Aug. 2009. [19] J. Fraden and M. R. Neumann, QRS wave detection, Med. Biol. Eng. Comput., vol. 18, pp 125-132, 1980. [20] P.M.Mahoudeaux, Simple microprocessor-based system for on-line ECG analysis, Med. Bio. Eng. Comput.,vol.19,pp 497-500,1981 [21] D.Gustafson, Automated VCG Interpretation studies using signal analysis techniques, R-1044 Charles Stark Draper Lab.,Cmabridge,MA,1977 [22] A. Menred, Dual microprocessor system for cardiovascular data acquisition, processing and recording, in Proc.1981 IEEE Int. Conf. Industrial Elect. Contr. Instrument.,1981,pp.64-69 [23] W.P. Holsimger , A QRS pre-processor based on digital differentiation IEEE Trans. Biomed. Eng.,vol.BME18,pp.212-217,1971 [24] M.L. Ahlstrom and W J. Tompkins, Automated high-speed analysis of holter taps with microcomputers, IEEE Trans. Biomed. Eng., vol. BME-30,pp.651-657,Oct.1983 [25] BALDA R. A. The HP ECG analysis program in VANBEMNEL J. H. and WILLEMS J.L. (Ed): Trends in Computer- Process Electrocardiograms , (North Holland), pp. 197-205, 1977 [26] R. M. Rangayyan, Biomedical signal analysis: a case-study approach, IEEE Press, 2001. [27] 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-97, 1990. [28] W. J. Tompkins, Biomedical digital signal processing, Prentice-Hall, Upper Saddle River, NJ, 1995. [29] M. Okada, A digital filter for the QRS complex detection, IEEE Trans. Biomed. Eng., vol. 26, pp. 700-703, Dec. 1979. [30] W. A. H. Engelse and C. Zeelenberg, A single scan algorithm for QRS detection and feature extraction, IEEE Comput. Cardiology. Long Beach, CA: IEEE Computer Society, pp. 37-42, 1979. [31] P. S. Hamilton and W .J. Tompkins, Quantitative investigation of QRS detection rules using the MIT/BIH arrhythmic database, IEEE Trans. Biomed. Eng., vol. 33, pp. 1157-1165, 1986. [32] L. Keselbrener, M. Keselbrener, and S. Akselrod, Nonlinear high pass filter for R-wave detection in ECG signal, Med. Eng. Phys., vol. 19, no. 5, pp. 481-484, 1997. [33] S. Suppappola and Y. Sun, Nonlinear transforms of ECG signals for digital QRS detection: A quantitative analysis, IEEE Trans. Biomed. Eng., vol. 41, pp. 397-400, 1994. [34] 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-202, 1999. [35] Stphane Mallat, A Wavelet Tour of Signal Processing, 3rd ed., Academic Press, 2008. [36] Gary M., Friesen, Thomas C. Jannett, Manal Afify Jadallah, Stanford L.Yates, Stephen R. Quint, H. Troy Nagle, A Comparison of the Noise Sensitivity of Noise QRS Detection Algorithms, IEEE TRANSACTIONS ON BIOMEDICAL ENG.,VOL.37,PP.95-96.

AUTHOR BIOGRAPHIES
Sheikh Md. Rabiul Islam received the B.Sc.in Engg. (ECE) from Khulna University, Khulna, Bangladesh in December 2003, and M.Sc. in Telecommunication Engineering from the University of Trento, Italy, in October 2009. He joined as a Lecturer in the department of Electronics and Communication Engineering of Khulna University of Engineering & Technology, Khulna, in 2004, where he is currently an Assistant Professor in the same department in the effect of 2008. He has published 15 Journals and six international conferences.. His research interests include Numerical analysis, VLSI, wireless communications , signal & image processing, and biomedical engineering. A. F. M. Nokib Uddin received a B.Sc. Engg. (ECE) of department of Electronics and Communication Engineering at Khulna University of Engineering & Technology, Khulna_9203, Bangladesh. Md.Billal Hossain received a B.Sc. Engg.(ECE) of department of Electronics and Communication Engineering at Khulna University of Engineering & Technology, Khulna_9203, Bangladesh. Md. Imran Khan received a B.Sc. Engg. (ECE)of department of Electronics and Communication Engineering at Khulna University of Engineering & Technology, Khulna_9203, Bangladesh

2013 ACEEE DOI: 01.IJIT.3.1. 4

14

You might also like