You are on page 1of 4

9th International Conference on Electrical and Computer Engineering 353

20-22 December, 2016, Dhaka, Bangladesh

Analysis of ECG Signal and Classification of Heart


Abnormalities Using Artificial Neural Network
Tanoy Debnath, Md. Mehedi Hasan, Tanwi Biswas
Department of Electronics and Communication Engineering
Khulna University of Engineering & Technology
Khulna 9203, Bangladesh
kuettanoydebnath@yahoo.com, mehedi_ece@yahoo.com, tanwibiswas.tb@gmail.com

Abstract—Cardiac arrhythmia indicates abnormal electrical R intervals, Heart rate and Heart condition. The purpose of
activity of heart that can be a great threat to human. So it needs classification is to identify various heart conditions with
to be identified for clinical diagnosis and treatment. Analysis of patients age/gender, R-R intervals and Heart Rate which helps
ECG signal plays an important role in diagnosing cardiac diseases. clinical cardiac diagnostic system. For this reason, artificial
An efficient method of analysing ECG signal and predicting heart neural network has chosen for classification because of its vast
abnormalities have been proposed in this paper. In the proposed use in machine learning areas and biomedical fields. For the
scheme, at first the QRS components have been extracted from the classification purposes Back propagation has chosen which is
noisy ECG signal by rejecting the background noise. This is done easy to utilize for proper classification. It is a feed forward
by using the Pan Tompkins algorithm. The second task involves
neural network which is used by training and testing data. Back
calculation of heart rate and detection of tachycardia,
bradycardia, asystole and second degree AV block from detected
propagation refers to backward propagation of errors so that
QRS peaks using MATLAB. The results show that from detected there is a minimum difference between estimated data and
QRS peaks, arrhythmias which are based on increase or decrease output data. In back propagation, an iterative way is used
in the number of QRS peak, absence of QRS peak can be mainly for this purpose so that all the weight can be updated to
diagnosed. The final task is to classify the heart abnormalities a new value after each iteration and a feed forward network is
according to previous extracted features. The back propagation chosen because here all the input, weight and hidden neuron are
(BP) trained feed-forward neural network has been selected for interconnected to each other.
this research. Here, data used for the analysis of ECG signal are
from MIT database II. PROPOSED METHODOLOGY
The Methodology of this proposed work can be predicted from
Index Terms— ECG; Tachycardia; Bradycardia; Asystole; figure (1) in Block Diagram.
Second degree AV block; Backpropagation.
ECG signal from
I. INTRODUCTION MIT – BIH database
Electrocardiogram (ECG) is the graph of voltage versus
time which is produced due to electrical activities of human
heart. An ECG signal consists of various parts such as P wave, Preprocessing and
QRS complex and T wave which are the waveform of removing Artifacts
corresponding electrical activities of various parts of the human
heart. During the analysis of ECG signal, data including the
positions or magnitudes of the QRS, PR, QT and ST intervals, QRS Detection by Pan
the PR and ST segments etc. are considered for accurately –Tompkins algorithm
diagnosing the heart diseases [1]. With the features present in
the ECG signal, it is possible to predict various cardiac
arrhythmias. There are many established algorithms for
Feature Extraction
extracting features from ECG signal to predict heart
abnormalities, for example, algorithms from the field of
artificial neural network [2], genetic algorithm [3], Wavelet
Transform [4] etc. Training
Sample
For analyzing the ECG signal and before the steps of feature Training Data tested Data
extraction, preprocessing of ECG signal is necessary because
signal is noisy and so many artifacts. For the analysis of ECG
signal MIT-BIH Arrhythmia Database [5] with patients
Information has been used. This database is a large collection Classification
of recorded physiologic signals and it has free web access for
researchers for their experimental purpose. For the
preprocessing purpose a widely popular technique called Pan-
Tompkins Algorithm has been adapted. This is for QRS
complex detection for the measurement of Heart beat (BPM) Normal Tachycardia Bradycardia Block
[6]. The proposed algorithm automatically calculate heart rate
and finds the Heart condition according to the measured Heart Figure 1. Block Diagram of Proposed Methodology
Beat (BPM). Extracted features are based on patient’s age, R-

978-1-5090-2963-1/16/$31.00 ©2016 IEEE


354

Firstly ECG signals are collected from database and [8]. Initially the contaminated signal is processed by filtering,
preprocessed for removing artifacts and using Pan – Tompkins derivation, squaring, thresholds detecting and finally detecting
algorithm Q,R,S are identified for the heart rate calculation. the QRS complex [9].
This deflection of ECG signal is very important features for
identify various hearts conditions. A neural network is trained 1) Band Pass Flitering
with 26 datasets containing features of QRS complex with Signal passes through a band pass filter which is a cascaded low
patients age/gender, R-R intervals and Heart Rate with pass filter and high pass filter. This filtering process reduces
condition of hearts. After the training, the network is tested with noise in the ECG signal and an average QRS complex is found
12 more datasets. Tested results have gone through the same as by matching the spectrum of the signal. Noises like Muscle
by training datasets. noise, power line interference, baseline wander, T wave
interference are attenuated by band pass filtering. Pass band
III. METHODOLOGY WORK
maximizes the energy of QRS complex in the range of 5 Hz- 15
A. Preprocessing of ECG signal Hz. The cascaded low pass filter and high pass filter are
ECG signal collected from database is recorded signal that is described by the formula. For low-pass filter,
often contaminated with electrical interference or noise that is y(n)= 2y(n-1)-y(n-2)-x(n)-2x(n-6)-x(n-12)………………(1)
recorded from sources other than the electronic signals of the
heart. In order to eradicate noisy ECG signal we have to For High –pass filter,
preprocess the basic ECG signal. This preprocessing can be
done by two ways. y(n)= y(n-1)- 1/32x(n)-x(n-16)-x(n-17)+1/32x(n-32)……(2)
1) Preprocessing and 2) Derivation
2) Feature Extraction.
Preprocessing step eliminates electrical interference of ECG Signal then processed with derivative operator which is a
signal like power line artifacts, Electromyographic (EMG) standard technique to identify a peak in the signal. Derivative
noise, baseline wandering which are more significant among filter finds out the high slopes. It identifies the direction in the
artifacts and they can impact on ECG signal analysis. Feature slope of the signal and distinguishes the QRS complexes from
extraction step refers to obtain the most relevant information other ECG waves. It suppresses the low frequency components
from the original ECG signal. For this preprocessing and and a large gain to the high frequency components arises. The
feature extraction stage Pan – Tompkins algorithm has been signal is differentiated to find out QRS slope using the
applied. following formula:

B. Pan-Tompkins Algorithm y(n)= 1/8[2x(n)+ x(n-1)-x(n-3)-2x(n-4)]…………………..(3)

Compared to other QRS detection technique the utilization of


3) Squaring
Pan-Tompkins algorithm is more vulnerable. The literature
survey of this approach makes it as one of the most important
The squaring function is a nonlinear transformation that
algorithm in detection QRS peak [7]. For better diagnosing the
squaring the signal samples point by point. It makes the all
heart abnormalities the accuracy of any ECG waveform
signal values positive and amplifies the output of the previous
extraction plays a vital role.
stage. It suppresses the P and T wave and high frequency
components of the QRS complex are increased. Thus
Signal Band pass Filter emphasizing the R peaks in the signal. After differentiating the
signal is then squared making all the values positive and give
importance to the higher frequencies.
Derivation y(n)=x2 (n)………………………………………………..(4)

4) Averaging and Threshold Process


Squaring
For visual purposes and better identification of R peaks,
averaging is utilized that maximizes the signal compared with
Average and squaring output. After the averaging process the threshold of
Threshold the obtained signal is done that detects peaks in the ECG signal
and identifies a threshold value. Then it is classified as QRS
peak if peak crosses threshold. The signal now passes through
Peak a moving window integrator that performs as suitable interval
Detection under the squared waveform, sums the area and advances the
new window. It performs as a smoothing of output of the
QRS Detection previous operations. N= 40 was found as a suitable window
width for frequency, fS=360 Hz.
Fig 2. Pan-Tompkins Structure 5) QRS peak detection
Fig 2. Shows the graphical representation of the Pan-Tompkins For measuring Heart Beat in BPM detection of QRS complex
algorithm. This algorithm is one of the most popular QRS is necessary. By calculating the time period of the R-R interval
detection process in biomedical signal processing textbooks it can be measured. Different heart condition called arrhythmia
355

maximum and minimum amplitude is also found by analyzing overfitting [11]. The back propagation algorithm can be divided
the ECG signal. Below are several steps for real time ECG into two phases:1) Propagation of errors and 2) Weight update.
signal processing and QRS detection. When the errors propagate in the backward direction, the
weight in the layers will change. It is an iterative algorithm to
• Data Acquisition from MIT-BIH database. minimize the mean square error between the desired output and
• Filtering the signal by using low pass filter and high the actual network output. This algorithm has limitation like it
pass filter. always changes weights in such a way to cause the error to fall.
• Differentiation of the signal that’s passes through TABLE I. CONDITIONS FOR HEART ABNORMALITIES
band pass filter.
• Squaring the differentiated signal for getting all Serial Heart Abnormalities Conditions
positive value. No
1 Tachycardia Heart
• Averaging, Threshold and integrating the squared Rate>100BPM
signal and clear R peak detection.
• Determination of R-R interval. 2 Bradycardia Heart
Rate<60BPM
• Calculation of heart rate by R-R interval.
3 Second Degree AV Block QRS dropped
For Heart Rate calculation,
4 First Degree AV Block Long PR
Heart Rate = 60/ R-R interval (m sec). interval
Complete Heart Complete drop
C. Feature Extraction 5 Block(Asystole) out of cardiac
cycle
By using the Pan–Tompkins algorithm, ECG signal is
preprocessed and we obtained peak values. Now for the
classification purposes, features are selected by four ways.
Age/gender (from MIT database), R-R intervals, Heart Rate are Table 1 shows the conditions for the different heart conditions.
chosen for the features for classification for different heart For the classification purposes second degree heart block, first
conditions. Firstly age is considered as 95 is the highest age, degree heart block and complete heart block are considered as
secondly gender is chosen as male= 1; Female= 0; other= 0.5, block condition. For scarcity of above mentioned conditions
thirdly R-R interval/max. of R-R inerval value is chosen and data we considered these for block.
finally heart rate is guessed (160 is the maximum value).
D. Classification IV. RESULT ANALYSIS AND DISCUSSION
In biomedical engineering and machine learning, Artificial Table 2 shows the extracted features for the sample signals
Neural Network (ANNs) are a family of statistical learning for different heart conditions and features are divided by four
algorithm inspired by biological neural network ( the central ways. Table 3 shows the confusion matrix for heart
system of animals) that are utilized to estimate or approximate abnormalities classification performance that shows the correct
functions that depend on a large number of inputs that are and incorrect predictions made by BPNN. Firstly 26 datasets
usually unknown [10]. For classification for different heart are trained and tested with 12 data. Three conditions for heart
conditions the ANN used in this work is based on back such as normal, bradycardia, tachycardia are classified
propagation (BP). perfectly but block condition is not correctly identified. Fig. 5
shows the iteration number to train error graph for training the
data set where mean square error decreases in the increasing of
iteration. It will be tends to zero of the higher value of iteration
number. The mean square error will not decrease sharply for a
value of iteration number. An approximate value of 0.056 after
which the value of mean square have not decreased sharply.

Fig. 3: Three layer feed forward network

Back propagation refers to backward propagation of errors. It


is a three layer feed forward network and a common method of
training artificial neural network that is efficient. For obtaining
desired classification performance, the selection of hidden
nodes is very important. Number of hidden nodes is
commensurate to the complexity and memory requirement. The
network cannot adjust the weight efficiently when the number Fig. 5: Training error vs. number of iteration curve for training data set.
of hidden nodes decrease. Sometimes an overfitting can be
occurred. That’s why, the network is generalized to nullify
356

TABLE II. EXTRACTED FEATURES FOR SAMPLE SIGNALS Chf15 53/M 1.2 48.2 HEART BLOCK

Test Age/Gender R-R Heart Identification


interval rate 228 80/F 0.83 72 FIRST DEGREE
HEART BLOCK
103 84/F 0.83 72 NORMAL
104 66/F 0.772 77.2 NORMAL 37 1.9 31.5 COMPLETE
106 24/F 0.90 66 NORMAL HEART BLOCK
16272 20/F 1 60 NORMAL
16273 28/F 0.714 84 NORMAL
16795 20/F 0.711 84.375 NORMAL
16786 32/F 0.833 72 NORMAL Table 3. Confusion matrix for heart abnormalities classification by
BPNN
16773 26/M 0.833 72 NORMAL
Classes Normal Bradycardia Tachycardia Block
16439 35/F 0.90 66 NORMAL Normal 0.981165 0.063549 0.002401 0.011074
101 75/F 1.2 49 BRADYCARDIA
Normal 0.974685 0.276393 0.000745 0.003432
232 76/F 1.25 1.25 BRADYCARDIA Bradycardia 0.061554 0.813611 0.000231 0.209684
800 - 1.25 48 BRADYCARDIA Bradycardia 0.542276 0.872049 0.000107 0.004602
801 - 1.66 36 BRADYCARDIA Tachycardia 0.008373 2.95E-05 0.994776 0.000108
Tachycardia 0.000288 1.64E-07 0.999789 0.08414
802 - 1.42 42 BRADYCARDIA
Block 0.280936 0.006238 0.048266 0.465988
16483 42/M 1.66 36 BRADYCARDIA
Block 0.359838 0.014197 0.024578 0.66721
16420 38/F 1.5 40 BRADYCARDIA
V. CONCLUSION
18177 26/F 2.5 24 BRADYCARDIA In this paper we established a network to classify different heart
abnormalities e.g. normal, bradycardia, tachycardia and block
PERSON30 1.11 54.05 BRADYCARDIA as discussed earlier. A back propagation algorithm with feed
PERSON40 56.4 BRADYCARDIA forward neural network is used for classification purpose that
1.06 is efficient. Though in our proposed work block condition is not
212 32/F 0.659 91 TACHYCARDIA
classified due to some unintentional errors but the overall
performance is excellent. The correct and incorrect relationship
215 81/M 0.56 106.3 TACHYCARDIA has shown in confusion matrix that is satisfactory. For future
16265 - 0.51 118.25 TACHYCARDIA work, we will try to find out more features and utilize other
classifier like SVM, kNN classifier and will make comparison
with ANN based on their classification performance.
Chf01 71/M 0.430 139.3 TACHYCARDIA
REFERENCES
CU03 - 0.69 86.4 VENTRICULAR [1] Yun-Chi Yeh, Wen-June Wang, Che Wun Chiou, “Cardiac arrhythmia
TACHYCARDIA diagnosis method using linear discriminant analysis on ECG signals”,
ELSEVIER, Measurement vol. 42, pp. 778-789, January 2009.
30 0.6 106.4 TACHYCARDIA [2] G. Karraz, G.M., “ Automatic classification of heartbeats using neural
network classifier based on a bayesian framework”, 28th Annual
31 `136.7 TACHYCARDIA International Conference of the IEEE Publication, pp. 4016-4019, 2006.
0.44
[3] Poli, R., Cagnoni, S. and Valli, G., “Genetic design of optimum linear and
32 140.2 TACHYCARDIA nonlinear QRS detectors”, IEEE Transaction Biomedical Engineering,
0.427 vol. 42, pp. 1137-1141, 1995.
35 130.2 TACHYCARDIA
[4] Prasad, G.K. and Sahambi, J.S., “Classification of ECG arrhythmias
0.5
using multi-resolution analysis and neural networks”, Proceedings of
IEEE Conference on Convergent Technologies, vol. 1, pp. 227-231, 2003.
36 0.54 110.7 TACHYCARDIA
[5] https://physionet.org/cgi-bin/atm/ATM
[6] J. Pan and W. Tompkins, “Real Time Algorithm detection for QRS”,
45 143.1 TACHYCARDIA IEEE Trans. Eng. Biomed Eng, 32(3), pp.230-236, 1985.
0.4 [7] Friesen, G. M., Jannett, T. C., Jadallah, M. A., Yates, S. L., Quint, S.R.,
Nagle, H. T, “A comparison of the noise sensitivity of nine QRS detection
107 63/F 0.77 78.3 SECOND DEGREE algorithms”, IEEE Trans. Biomed.Eng., BME-37: pp. 85–97, 1990.
HEART BLOCK [8] L. Ahmad, M. Mohamed, N. A. Ab. Ghani,“ An Improved QRS Complex
108 87/F 0.7 85.71 FIRST DEGREE Detection for Online Medical Diagnosis”, World Academy of Science,
HEART BLOCK Engineering and Technology, 68, 2012.
[9] Shital L. Pingale, Nivedita Daimiwal, “Detection of Various Diseases
111 47/F 0.83 72 FIRST DEGREE
HEART BLOCK Using ECG Signal in MATLAB”, International Journal of Recent Technology
and Engineering (IJRTE) ISSN: 2277-3878, Volume-3, Issue-1, March 2014.
207 69/F 0.7 82.1 HEART [10] https://en.wikipedia.org/wiki/Artificial_neural_network
BLOCK(DIFFICULT [11] M.R.Ahsan, M.I.Ibrahimy, and O.O.Khalifa, “EMG
RECORD) Signal classification for Human Computer Interaction:A
Chf04 54/M 1.66 36 HEART BLOCK Review,”European Journal of Scientific Research,Vol.33,no.3,pp.480-
501,2009

You might also like