You are on page 1of 8

International Conference on Computing, Communication and Automation (ICCCA2015)

Classification of heart diseases from ECG signals


using wavelet transform and kNN classifier
Ridhi Saini*, Namita Bindal‡, Puneet Bansal§
Electronics and Communication Engineering Department
University Institute of Engineering and Technology, Kurukshetra University
Kurukshetra, India
*
ridhisaini9@gmail.com, ‡namitabindal7@gmail.com, §puneet4u@gmail.com

Abstract— Heart is the most vital organ which circulates and the possibility of attributing heart failure symptoms to
blood along with nutrients and oxygen throughout the body. other diseases [13].
There are number of reasons which may affect its normal
working. In this paper ten heart diseases, as well as normal, II. METHODOLOGY
have been classified by extracting features from original ECG The objective of the paper is to offer an ECG diagnosing
(electrocardiogram) signals and sixth level wavelet
technique to improve the performance of the diagnosis of
transformed ECG signals. The results have been compared
and improved accuracy has been obtained using wavelet
patients with heart diseases and distinguish them from the
transformed signals. normal subjects on the basis of their ECG waveforms
especially for diagnosing the people in remote villages
Keywords—Classification algorithm; Discrete wavelet where expert medical facilities are not available or are far to
transforms; Electrocardiography; Principal component analysis; reach within specific time. The techniques used comprise of
Statistical analysis. the possible use of wavelet entropy based measures in
improving the feature extraction from ECG signals and the
I. INTRODUCTION effects of Principal Component analysis and statistical
Heart is the most sophisticated organ of human body and parameters on analysis of ECG signals. Finally k-nearest
the diseases related to it need to be identified with much neighbour (kNN) classifier has been used to classify the
accuracy and in short time, failure of which can lead to diseases. Though many classification techniques are
sudden death. For diagnosis of heart, ECG signals are used. available such as artificial neural network (ANN) and
Since there is variation in physiological structures of support vector machine (SVM) classifiers, the structure of
humans, they have different shapes of ECG. Therefore, the the kNN classifier imposes lower computational burden
wave shape of the same disease may vary little bit from [14]. The MIT-BIH arrhythmia database consists of forty
person to person. For some diseases, the clinical symptoms eight half-hour excerpts of two-channel ambulatory ECG
along with ECG will be sufficient to diagnose the disease at recordings, obtained from forty seven subjects studied by
early stages; whereas, many cardiac diseases develop over a the BIH Arrhythmia Laboratory between 1975 and 1979,
long time. So, some specialised instruments are used to who suffered from right bundle branch block, left bundle
record the signals for a few days, such as Holter ambulatory branch block, paced rhythm, atrial premature beat and also
monitor [1]. This gets cumbersome for the cardiologist to of normal patients [3]. The MIT-BIH malignant ventricular
study the waves and interpret them in limited time. arrhythmia database contains twenty-two half-hour ECG
Nowadays, ECG interpretation with the aid of software is recordings of subjects who suffered from ventricular flutter,
used by cardiologists to support their diagnosis results; but, sustained ventricular tachycardia, ventricular bigeminy,
the concept is not new [2]. Automatic diagnosing systems ventricular fibrillation, high grade ventricular ectopic
are a need of the day which will analyze ECG waveforms of activity and asystole. The discrete data contains a variable,
several hours and give results in a few seconds. In this ‘val’, having 2 rows (signals) and 525000 columns
paper, ECG signals of normal and diseased subjects have (samples/signal) and duration of 35:00 min with sampling
been obtained from MIT-BIH arrhythmia database and frequency of 250 Hz [3]. All the signals were divided in
MIT-BIH malignant ventricular arrhythmia database [3]. duration of five minutes; because, normally these signals
Signal analysis methods extract features of the signal such have been recorded by the practitioner for this much time
as position and amplitudes of different peaks of ECG, etc. only. The statistical features computed were kurtosis,
either in time or frequency domain [4]. To better interpret skewness, entropy, mean, standard deviation, variance, root
the ECG signals, their morphology has been studied by [5- mean square, minimum, maximum, range, harmonic mean,
10]. Detection based on QRS wave shape has been done by median and energy. These features were extracted from
[6], [11]. For detection of heart disease, besides historical ECG waveforms to interpret them more precisely and
records, physical examination also needs to be done [12]. In accurately. These functions were implemented on
elderly patients, making the diagnosis is more difficult; waveforms with the help of MATLAB software [15]. Two
because, of a relative absence of typical signs and symptoms methods were used to classify the ECG signals. In first
method, the statistical features were computed directly from
raw ECG signals and then principal component analysis was

ISBN:978-1-4799-8890-7/15/$31.00 ©2015 IEEE 1208


International Conference on Computing, Communication and Automation (ICCCA2015)

applied before classification. In second method, the ECG


signal were decomposed using wavelet transform with
Daubechies order four wavelet up to level six. Then
wavelet coefficients were extracted at detailed level four.
The statistical features were extracted using wavelet
coefficients which were then classified using kNN classifier
after application of principal component analysis. The
algorithms used for these two methods are:
A. Method 1: Algorithm for feature extraction and
classification using original ECG signals
1. Divide the signal into intervals of 5 min
Fig. 1. Feature extraction using db4 wavelet at level 6 for ECG
2. Extract statistical features waveform of a normal person.
3. Normalize the data for zero mean and unity standard
deviation
4. Apply Principal component analysis
5. Normalize to make data range from -1 to +1
6. Divide the data for training (95%) and testing (5%)
7. Train kNN classifier on training data
8. Calculate percentage error for training data
9. Test testing data using kNN classifier trained in step
7
Fig. 2. Feature extraction using db5 wavelet at level 4 for ECG
10. Calculate percentage error for testing data
waveform of a normal person.
B. Method 2: Algorithm for feature extraction and
classification using wavelet transformed ECG signals The following figures (Fig. 3 to Fig. 12) show the
feature extraction using db4 wavelet at level 6 for ECG
The algorithm steps are same as that of method 1 with waveforms of diseased patients with right bundle branch
addition of following two steps after step 1 block, left bundle branch block, paced rhythm, atrial
i. Decompose the ECG signal using wavelet transform premature beat, Ventricular tachycardia, Ventricular flutter,
using Daubechies order 4 wavelet up to level 6 Ventricular bigeminy, Ventricular fibrillation, high grade
ventricular ectopic activity and Asystole.
ii. Extract the wavelet coefficients at detailed level 4
Fig. 1 and Fig. 2 show that the extraction at level 6
(approximation and details) contain more details and db4 is
better than db5 and other wavelets as its shape is more
similar to the used ECG signal. Also the waveform at
detailed level 4 in level 6 extractions is quite similar to the
original waveform with some improvements after removal
of noise which is a result of passing the waveform through a
series of high and low pass filters. This de-noising has
resulted in selecting level 6 extraction using db4 wavelet
and from this the wavelet detailed coefficients have been
extracted at level 4.
Fig. 3. Feature extraction using db4 wavelet at level 6 for ECG
waveform of a patient with Left bundle branch block.

1209
International Conference on Computing, Communication and Automation (ICCCA2015)

Fig. 4. Feature extraction using db4 wavelet at level 6 for ECG Fig. 8. Feature extraction using db4 wavelet at level 6 for ECG
waveform of a patient with Right bundle branch block. waveform of a patient with Ventricular tachycardia.

Fig. 5. Feature extraction using db4 wavelet at level 6 for ECG Fig. 9. Feature extraction using db4 wavelet at level 6 for ECG
waveform of a patient with Atrial premature beat. waveform of a patient with Ventricular fibrillation.

Fig. 6. Feature extraction using db4 wavelet at level 6 for ECG Fig. 10. Feature extraction using db4 wavelet at level 6 for ECG
waveform of a patient with paced rhythm. waveform of a patient with Ventricular bigeminy.

Fig. 7. Feature extraction using db4 wavelet at level 6 for ECG Fig. 11. Feature extraction using db4 wavelet at level 6 for ECG
waveform of a patient with Ventricular flutter. waveform of a patient with Asystole.

1210
International Conference on Computing, Communication and Automation (ICCCA2015)
1.50

1.00

0.50

Skewness
0.00

-0.50

-1.00
1 2 3 4 5

Normal Left bundle branch block


Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole
High grade ventricular ectopic activity

(b)
Fig. 12. Feature extraction using db4 wavelet at level 6 for ECG
waveform of a patient with High grade ventricular ectopic activity. Fig. 14. Variations in skewness for some ECG signals (a) without
wavelet transformation, (b) with wavelet transformation.
III. RESULTS
The features extracted with and without wavelet
-1.00E+11

transform has been plotted in Fig. 13 to Fig. 25 (for some


-3.00E+11

-5.00E+11

data). -7.00E+11

Entropy
30.00
-9.00E+11

25.00 -1.10E+12

20.00 -1.30E+12
Kurtosis

-1.50E+12
15.00
1 2 3 4 5

Normal Left bundle branch block


10.00 Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation
5.00
Ventricular bigeminy Asystole
High grade ventricular ectopic activity
0.00
1 2 3 4 5

Normal
Right bundle branch block
Left bundle branch block
Atrial premature beat
(a)
Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole
-2.00E+08
High grade ventricular ectopic activity
-4.00E+08

(a)
-6.00E+08

-8.00E+08

-1.00E+09
Entropy

19.50 -1.20E+09

-1.40E+09
17.50

-1.60E+09
15.50
-1.80E+09

13.50
-2.00E+09
1 2 3 4 5
Kurtosis

11.50
Normal Left bundle branch block
9.50 Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter
7.50
Ventricular tachycardia Ventricular fibrillation
5.50 Ventricular bigeminy Asystole
High grade ventricular ectopic activity
3.50
1 2 3 4 5

(b)
Normal Left bundle branch block
Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy
High grade ventricular ectopic activity
Asystole Fig. 15. Variations in entropy for some ECG signals (a) without wavelet
transformation, (b) with wavelet transformation.
(b)
996.00

Fig. 13. Variations in kurtosis for some ECG signals (a) without wavelet 796.00

transformation, (b) with wavelet transformation.


596.00
RMS

5.00
396.00
4.00

3.00
196.00

2.00
Skewness

1.00 -4.00
1 2 3 4 5
0.00
Normal Left bundle branch block
-1.00
Right bundle branch block Atrial premature beat
-2.00
Paced rhythm Ventricular flutter
-3.00 Ventricular tachycardia Ventricular fibrillation
-4.00 Ventricular bigeminy Asystole
1 2 3 4 5
High grade ventricular ectopic activity
Normal Left bundle branch block
Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter (a)
Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole
High grade ventricular ectopic activity

(a)

1211
International Conference on Computing, Communication and Automation (ICCCA2015)

211.00 211.50

161.00 161.50
RMS

Standard deviation
111.00 111.50

61.00 61.50

11.00 11.50
1 2 3 4 5 1 2 3 4 5

Normal Left bundle branch block


Normal Left bundle branch block
Right bundle branch block Atrial premature beat
Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter
Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation
Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole
Ventricular bigeminy Asystole
High grade ventricular ectopic activity
High grade ventricular ectopic activity

(b) (b)

Fig. 16. Variations in root mean square for some ECG signals (a) Fig. 18. Variations in standard deviation for some ECG signals (a)
without wavelet transformation, (b) with wavelet transformation. without wavelet transformation, (b) with wavelet transformation.

160025.00
825.00

140025.00
625.00
120025.00

Variance
425.00 100025.00
Average

80025.00
225.00

60025.00
25.00
40025.00

-175.00
20025.00

-375.00 25.00
1 2 3 4 5 1 2 3 4 5

Normal Left bundle branch block Normal Left bundle branch block
Right bundle branch block Atrial premature beat Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole Ventricular bigeminy Asystole
High grade ventricular ectopic activity
High grade ventricular ectopic activity

(a) (a)

4.50

3.50 50135.00

2.50
40135.00
Average

1.50

30135.00
Variance

0.50

-0.50 20135.00

-1.50
10135.00
-2.50
1 2 3 4 5
135.00
Normal Left bundle branch block 1 2 3 4 5

Right bundle branch block Atrial premature beat Normal Left bundle branch block
Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter
Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation
Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole
Ventricular bigeminy Asystole
High grade ventricular ectopic activity High grade ventricular ectopic activity

(b) (b)

Fig. 17. Variations in average for some ECG signals (a) without wavelet Fig. 19. Variations in variance for some ECG signals (a) without
transformation, (b) with wavelet transformation. wavelet transformation, (b) with wavelet transformation.
425.00

375.00
650

325.00
Standard deviation

275.00 150

225.00
Minimum

175.00 -350

125.00

-850
75.00

25.00
1 2 3 4 5 -1350
1 2 3 4 5
Normal Left bundle branch block
Normal Left bundle branch block
Right bundle branch block Atrial premature beat
Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter
Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation
Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole
Ventricular bigeminy Asystole
High grade ventricular ectopic activity
High grade ventricular ectopic activity

(a) (a)

1212
International Conference on Computing, Communication and Automation (ICCCA2015)

-190.00
2635.00

-390.00

2135.00
-590.00

-790.00 1635.00
Minimum

Range
-990.00
1135.00

-1190.00

635.00
-1390.00

-1590.00 135.00
1 2 3 4 5 1 2 3 4 5

Normal Left bundle branch block Normal Left bundle branch block
Right bundle branch block Atrial premature beat Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole Ventricular bigeminy Asystole
High grade ventricular ectopic activity High grade ventricular ectopic activity

(b) (b)

Fig. 20. Variations in minimum for some ECG signals (a) without Fig. 22. Variations in range for some ECG signals (a) without wavelet
wavelet transformation, (b) with wavelet transformation. transformation, (b) with wavelet transformation.

1525
890.00

1325
690.00
1125

Harmonic Mean
490.00
925
Maximum

725 290.00

525
90.00
325

-110.00
125

-75 -310.00
1 2 3 4 5 1 2 3 4 5
Normal Left bundle branch block Normal Left bundle branch block
Right bundle branch block Atrial premature beat Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole Ventricular bigeminy Asystole
High grade ventricular ectopic activity High grade ventricular ectopic activity

(a) (a)

150.00
1270.00
100.00

1070.00
Harmonic Mean

50.00

870.00
0.00
Maximum

670.00
-50.00

470.00 -100.00

270.00 -150.00

-200.00
70.00
1 2 3 4 5
1 2 3 4 5
Normal Left bundle branch block Normal Left bundle branch block
Right bundle branch block Atrial premature beat Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole Ventricular bigeminy Asystole
High grade ventricular ectopic activity High grade ventricular ectopic activity

(b) (b)

Fig. 21. Variations in maximum for some ECG signals (a) without Fig. 23. Variations in harmonic mean for some ECG signals (a) without
wavelet transformation, (b) with wavelet transformation. wavelet transformation, (b) with wavelet transformation.

2800
850

2300 650

450
1800
Range

Median

250
1300

50

800
-150

300 -350
1 2 3 4 5 1 2 3 4 5
Normal Left bundle branch block Normal Left bundle branch block
Right bundle branch block Atrial premature beat Right bundle branch block Atrial premature beat
Paced rhythm Ventricular flutter Paced rhythm Ventricular flutter
Ventricular tachycardia Ventricular fibrillation Ventricular tachycardia Ventricular fibrillation
Ventricular bigeminy Asystole Ventricular bigeminy Asystole
High grade ventricular ectopic activity High grade ventricular ectopic activity

(a) (a)

1213
International Conference on Computing, Communication and Automation (ICCCA2015)

150.00
ECG signals. Classification efficiency of 87.5% has been
100.00
obtained using wavelet transformed ECG signals.
Classification is done using kNN classifier. As a future
50.00

0.00

scope of this paper, an automated hardware system can be


Median

-50.00

-100.00

-150.00
developed which may record and diagnose heart disease
-200.00
1 2 3 4 5
automatically and can be used at remote places where it is
Normal
Right bundle branch block
Left bundle branch block
Atrial premature beat
difficult for medical practitioners to service the people.
Paced rhythm
Ventricular tachycardia
Ventricular flutter
Ventricular fibrillation
Also other classifiers like Support vector machines,
Ventricular bigeminy
High grade ventricular ectopic activity
Asystole
Gaussian Mixture Model, Hidden markov model can be
used for classification and their performance can be
(b)
compared with kNN.
Fig. 24. Variations in median for some ECG signals (a) without wavelet
transformation, (b) with wavelet transformation.

95.00

85.00 REFERENCES
75.00
[1] W.J. Tompkins, Biomedical Digital Signal Processing. Prentice Hall,
65.00
Upper Saddle River, New Jersey, 2000.
Energy

55.00
[2] P.W. Macfarlane, “Recent developments in computer analysis of
45.00
ECGs,” Clinical Physiology and Functional Imaging, vol 12, no 3, pp.
35.00
313–317, 1992.
25.00
1 2 3 4 5
[3] A.L. Goldberger, L.A.N. Amaral, L. Glass, J.M. Hausdorff, P.Ch.
Normal Left bundle branch block Ivanov, R.G. Mark, J.E. Mietus, G.B. Moody, C.K. Peng, and H.E.
Right bundle branch block
Paced rhythm
Atrial premature beat
Ventricular flutter
Stanley. PhysioBank, PhysioToolkit, and PhysioNet, “Components of
Ventricular tachycardia Ventricular fibrillation a new research resource for complex physiologic signals,” Circulation
Ventricular bigeminy Asystole 101(23):e215-e220 [Circulation Electronic Pages;
High grade ventricular ectopic activity
http://circ.ahajournals.org/cgi/content/full/101/23/e215]; June 13,
Fig. 25. Variations in energy for some ECG signals with wavelet 2000.
transformation. [4] V.X. Afonoso, and W.J. Tompkins, “Detecting ventricular
fibrillation: Selecting the appropriate time-frequency analysis tool for
the application,” IEEE Eng. in Medicine and Biology, pp. 152-159,
Twelve statistical features from raw ECG signals have 1995.
been evaluated. The training data consisted of 372 patterns, [5] S. Osowski, L.T. Hoai, and T. Markiewicz, “Support vector machine-
thus making the training matrix of size 372 x 12. Principal based expert system for reliable heartbeat recognition,” IEEE
component analysis has been used to reduce the training Transactions on Biomedical Engineering, vol 51, no 4, pp. 582–589,
2004.
matrix by extracting orthogonal components from input [6] B.U. Kohler, C. Hennig, and R. Orglmeister, “The principles of
features, thus reducing the training matrix to 372 x 8. This software QRS detection: Reviewing and comparing algorithms for
reduces memory requirement by 38.46 % as well as will detecting this important ECG waveform,” IEEE Engineering in
increase the speed of executing the algorithm. The resulting Medicine and Biology Magazine, vol 21, no 1, pp. 42–57, 2002.
orthogonal feature matrix has been classified using kNN [7] P.S. Gokhale, “ECG signal de-noising using discrete wavelet
transform for removal of 50Hz PLI noise,” International Journal of
classifier. Same procedure was followed for testing matrix. Emerging Technology and Advanced Engineering, ISSN 2250-2459,
Classification efficiency of 56.25 % has been achieved. To vol 2, Issue 5,pp 81-85, May 2012.
improve the efficiency, the ECG signal was decomposed [8] S.S. Mehta, and N.S. Lingayat, “Biomedical signal processing using
using wavelet transform and thirteen (including energy SVM,” lET-UK International Conference on Information and
Communication Technology in Electrical Sciences (ICTES 2007), Dr.
feature) statistical features were evaluated from these M.G.R. University, Chennai, Tamil Nadu, India, pp.527-532, Dec.
decomposed signals. After classification of statistical 20-22, 2007.
features of decomposed ECG signal, a classification [9] Abed Al Raoof Bsoul, Kevin Ward, Kayvan Najarian, and Soo-Yeon
efficiency of 87.5 % has been obtained which is an Ji, “A unified signal processing and machine learning method for
improvement of 31.25 %. An accuracy of 31.25 % was Detection of abnormal heart beats using electrocardiogram,” IEEE
International Conference on Bioinformatics and Biomedicine
achieved using ANN with 50-50 neurons in two hidden Workshops, pp. 453-460, 2010.
layers trained by Levenberg-Marquardt back-propagation [10] Meng-Chou Chang, Zong-Xin Lin, Che-Wei Chang, Hsiao-Lung
algorithm. This showed the supremacy of kNN over ANN. Chan, and Wu-Shiung Feng, “Design of a system-on-chip for ecg
signal processing,” the 2004 IEEE Asia-Pacific Conference on
IV. CONCLUSION Circuits and Systems, pp. 441-444, Dec 6-9, 2004.
[11] O Pahlm, and L. Sornmo, “Software QRS detection in ambulatory
To help medical practitioners diagnose subject’s monitoring – a review,” Medical & Biological Engineering &
heart diseases, ECG signal can be interpreted by software Computing, vol 22, pp.289–297, 1984.
[12] J. Wilbur, and P. James, “Diagnosis and management of heart failure
algorithms in the direction of achieving automated heart in the outpatient setting,” Primary Care: Clinics in Office Practice,
disease diagnosing system. In this paper classification is vol 32, pp. 1115–1129, 2005.
done from original ECG signals and wavelet transformed

1214
International Conference on Computing, Communication and Automation (ICCCA2015)

[13] N.D. Gillespie, “The diagnosis and management of chronic heart


failure in the older patient,” British Medical Bulletin, vol 75–76, no 1,
pp. 49–62, 2006.
[14] C.M. Bishop, Pattern Recognition and Machine Learning, Springer
publishing, 2006.
[15] MATLAB Wavelet toolbox user guide, ver. 2012a.

1215

You might also like