You are on page 1of 5

ECG arrhythmia classification using

Convolutional Neural Networks


Mounika Vasimalla Allam Jaya Prakash Samit Ari
Department of ECE Department of ECE Department of ECE
NIT Rourkela, India NIT Rourkela, India NIT Rourkela, India
mounidimple391@gmail.com allamjayaprakash@gmail.com samit.ari@gmail.com

Abstract—Cardiac arrhythmias occur in a short duration of domain features. Some of the temporal features include R-R
time which can’t be distinguishable by a human eye. Detection intervals, Q-R interval, QRS complex duration, R-S intervals,
of cardiac arrhythmias is a tedious task since slight changes in ST time segments. These temporal features are not enough
ECG signal may lead to life-threatening diseases. Diagnosis and
medication at an early stage could help to the reduce the high for classification since there is a huge variation in the other
mortality rate among the heart patients. This paper presents morphological patterns within the same patient. Hence some
an accurate technique for the classification of five types of of the researchers have reported the mixture of both frequency
ECG arrhythmia namely Premature ventricular contraction(V), and time features as reported in [1]. Many transformation
Normal (N), Left bundle branch block (L), Right bundle branch techniques like S transform, Fourier transform, wavelet
block (R), Paced (P). This technique incorporates convolutional
neural networks (CNN) that combine both feature extraction transform [2] and dual tree complex wavelet transform [3]
and classification into a single body which restricts the use of are used to extract the features from the pre-processed data.
complex feature extraction techniques like DTCWT (Dual tree Extracted features are given to the input of classifier for
complex wavelet transform) and a separate classifier to classify classification into respective classes. Some of the classifiers
these features into appropriate classes. The performance of the are artificial neural networks [4], linear discriminant analysis
proposed technique is assessed by using MIT-BIH arrhythmia
database. Overall classification accuracy of 94.79% is obtained [5], support vector machine [6].
which is superior to many other algorithms proposed in the
literature. Detection of cardiac arrhythmias by applying Hidden
Index Terms—Cardiac arrhythmia, convolution neural net- Markov models is reported in [7]. This algorithm has
work (CNN), feature extraction, MIT-BIH arrhythmia database demonstrated very good promising results in classifying
Ventricular arrhythmias and detection of low amplitude P
wave detection. In [8], the author presented a customized
I. I NTRODUCTION
electrocardiogram (ECG) beat classifier using a mixture of
Electrocardiogram (ECG) is the recording of the electrical experts (MOE) approach. Linear vector quantization (LVQ)
phenomenon at the heart that represents the variability and self-organizing maps(SOM) are two classification models
of heart rate. Any deviation from the normal heart rate, based on clustering technique, LVQ is a supervised learning
disturbance in rhythm, site of origin or conduction of technique which classifies the feature vector corresponding
cardiac electric impulse is considered as an arrhythmia. to the label of the cluster pattern (code word) into which is
Most of the arrhythmias are seldom occurring and can’t clustered. In SOM, each centring of the cluster (prototype or
be distinguished by a person’s eye. Long duration of ECG code word) is represented by some weights of a neuron which
records are required to identify the abnormalities present in is assigned to correlate in the feature map. The classifier is
a patient. Moreover, huge variations in temporal and some modelled using mixture of SOM and LVQ approaches. The
other morphological characteristics from one patient to the network is designed in such a way that LVQ gives superior
other patient make detection of abnormalities a challenging classification performance for classes 1 and 3 however for
task. Hence it is very difficult to analyze and recognize class 2 and 4 SOM gives superior performance. Overall
these arrhythmias manually by an expert cardiologist. Hence classification accuracy of 94% is reported using this mixture
we require an automatic computer-aided diagnostic (CAD) of experts approach.
system that can quickly detect abnormalities within the patient.
A unique technique is proposed in [9] for a patient-adapted
In literature, there are many algorithms proposed on ECG heartbeat classification that consists of four stages
automatic classification of ECG Arrhythmias. Most of them namely, preprocessing, feature extraction, feature selection
have done ECG classification in the following steps i) and classification. Features are extracted in temporal and
Pre-processing ii) feature extraction iii) classification. These frequency domain. Frequency domain features include
feature extraction techniques include both time and frequency coefficients obtained by applying stock well transform. 184
samples around each R peak are taken by combining 4 posed framework. Section IV shows the results and discussion
temporal features (Pre R-R, Post R-R, average R-R, local of the proposed algorithm. The conclusion is explained in
R-R) and 180 samples of frequency domain features. BFO section V.
algorithm used to select the best features and reduce the
redundant features. These features are given to the LMS II. ECG DATA PROCESSING
based multi-class classifier and obtained better classification MIT-BIH ECG Arrhythmia database is utilized for assessing
results as reported in [9]. In [10], Features are extracted from the performance of the proposed technique. The database
the ECG signals by using discrete wavelet transform (DWT) consists of some deadly arrhythmias. Most of the researchers
for classification of ECG beats. Classification of the extracted consider as the standard database for detection of cardiac
features is done by using Random Forest algorithm. Five arrhythmias. The database contains forty-eight files of ECG
types of ECG beats are classified with a success rate of 99.8%. recordings, every file contains 30 min of ECG segment
selected from 24 hours recordings of 48 specific patients.
In [11], a novel classification system based on particle The first 23 recordings correspond to the routine clinical
swarm optimization and Support Vector Machine (SVM ) recordings while the remaining recordings contain the complex
classifier is presented. The optimization of SVM classifier ventricular, junctional, and supraventricular arrhythmias [16].
is done by detecting three best discriminative features. This These ECG recordings are sampled at 360 Hz and band-pass
classification method has attained an accuracy of 89.72% on filtered at 0.1-100 Hz. Annotation file contains labels for each
testing over 20 files of MIT-BIH database. rhythm that are detected by using a simple slope sensitive
ECG beat recognition and classification is reported in [12]. detector. The results are cross-checked by two independent
This is a new classification algorithm consists of multi layer cardiologists for the verification. These labels are used in the
perceptron (MLP) and fuzzy self-organizing subnetwork training and testing phase of the implemented algorithm. In
connected in series called hybrid fuzzy neural network. The this work, five different types of cardiac arrhythmias namely,
fuzzy self-organizing layer analyses and distributes the data, normal (N), paced (P), right bundle branch block (R), left
groups them into clusters with different membership values. bundle branch block (L) and premature ventricular contraction
On the basis of these membership values, the MLP network (V) arrhythmias are classified by implementing the proposed
classifies the applied input vector, presenting the heartbeat method.
into corresponding classes.
III. P ROPOSED F RAMEWORK
All these fixed, handcrafted feature extraction techniques The proposed algorithm consists of three stages, Pre-
do not contribute reliable information when classifying new processing, Beat detection, Classification as shown in Fig
patients data since the same set of features are used for all 1. In pre-processing stage, ECG data is normalized to zero
patients under all circumstances. Also due to the several intra mean and standard deviation of unity to reduce amplitude
patients variations, this particular feature set can give poor variations of the data from the file to file. ECG signal is
performance results when classifying the same patients data sampled at 360Hz and then band pass filtered at 0.1-100
afterwards. Extracting several features using transformation Hz to eliminate various noises embedded in the signal. R
techniques, removing the redundancies and selecting the best peak locations are found by following the algorithm as
features using Bacteria Foraging Algorithm (BFO), reducing reported in [17]. Exact locations of the beat are detected
dimensions of features set using Principal component analysis for each and every file. 256 samples around each beat are
(PCA) increases the complexity of the feature extraction selected and fed into the input of CNN. CNN has the ability
techniques. to extract the reliable features from the raw ECG data
and classify these features into respective classes by using
In order to address the above limitations a novel approach a simple MLP which is present at the last stage of the network.
based on Convolutional Neural networks is proposed for
the classification of ECG arrhythmias. Convolutional neural CNN is used for both feature extraction and classification of
networks (CNNs) are widely used for image classification, each individuals patients raw ECG data. CNN is a multistage
object recognition [13], natural language processing [14], network. First stages of the network consist of convolutional
visual recognition [15] and many other pattern recognition layers that can extract global and local patterns from the
applications. CNN are special kind of neural networks works input raw data. The unique ability to extract feature maps
similar to human visual cortex. These are used for processing from the input sequence makes them widely used in many
data that has patterns like grid topology. The unique ability pattern recognition applications. A simple CNN architecture
to extract the features from the input sequence makes CNN consists of several convolutional layers followed by pooling
extensively useful in pattern recognition applications. layers, a simple MLP and a soft-max layer at the end.
This processed data is given to the input of convolutional
The remaining paper is organized as follows: Section II layer. Multiple filters present in the convolutional Layer
presents MIT-BIH database that is used to evaluate the per- automatically convolves with the input raw data to produce
formance of the proposed algorithm. Section III contains pro- output feature maps. Each of these convolutional layers is
Fig. 1. Overview of the proposed ECG arrhythmia classification system.

followed by a pooling layer that reduces the resolution of the The proposed technique consists of raw data representation.
convolved feature maps by sub-sampling. This feature maps Raw data representation includes temporal (average RR
are subsampled and given to an MLP in the fully connected interval, pre RR and post RR interval, local RR interval ) and
layer that classifies the arrhythmias into respective classes. morphological characteristics of the signal. Morphological
characteristics are represented by taking 256 samples around
Let us consider input data samples are represented as x0i = each heartbeat. Training dataset contains mixture of first
[x1 , x2 , x3 ....xN ] . As the name suggests that the convolution five minutes segment from each ECG record and 75 beats
layer performs a mathematical operation called convolution. randomly taken from five classes of ECG beats.
This is described by the following equation
M
X
Fjl,i = σ(bi + wki x0i
j+k−1 ) (1)
k=1

Where wki is the weight in the ith feature map at k th filter In this work, we have implemented a basic 1D CNN by
index. bi is the bias term of the ith feature map. M is the following the network architecture explained in [18], [19].
size of the kernel or filter. The output obtained from the The proposed architecture consists of multiple blocks. The
convolutional layer is sub-sampled by using the following first block is for feature extraction that consists of input
operation in the pooling layer. This equation 2 represents the layer in which 256 samples of the ECG signal are given
Max-pooling operation, it is a downsampling strategy across into the network. This is Followed by a convolutional, Relu,
a window of a particular size, Maximum value across this and Max pooling layers in further stages. All of these three
window is the resulting output of this operation. layers are used for feature extraction from the input samples.
This structure is repeated once again to enable the CNN for
l,j
Pil,j = max(Fi×S+r ) (2) better feature extraction. The extracted features are fed to a
r∈H fully connected layer followed by soft-max layer. The size
where H is the size of window stride and S is the size of of the soft-max layer is kept as 5 (the number classes to be
the pooling stride. The main advantage of this max-pooling classified). The kernel size for first and second convolutional
operation is, it facilitates generalization and reduction in layer was set to 5,3 respectively and both the pooling layers
number of parameters within the model. The output feature contain a sub-sampling factor of 2 is used for Max pooling
maps are fed into MLP. This is a feed-forward neural network operation. The maximum number of epochs is set to 50, the
that separates the nonlinear patterns. Simple MLP layer initial learning rate is 0.001 which is changed in accordance
present at the end of the network that maps input features to with the mean squared error (MSE) in each iteration. When
the respective classes. Gradient descent algorithm is used to the trained mean-squared error decreases in the present
minimize the mean square error. Since the number of classes iteration then the learning rate is increased by 2% in the next
to be classified is more than two we use soft-max layer at last iteration else we decrease learning rate by 15% for the next
stage of the network for representing features into appropriate training iteration.
classes.
IV. R ESULTS AND D ISCUSSION from the confusion matrix.
Performance of the proposed technique is evaluated by using
48 files of MIT-BIH arrhythmia database. The network is Table II shows the accuracy, sensitivity, specificity, positive-
trained by using 9945 beats which indicate that only 10% predictivity obtained on by using CNN for classification. All
of them are used for training and remaining 90% (94,979) 48 files including four files of paced beats also included for
of them are used for testing, which demonstrates that only a the performance evaluation. The overall accuracy of 94.79%
small amount of data is used for training. Table 1 shows the is obtained which shows that the proposed method attained
comparison of the confusion matrices obtained on classifying superior performance compared to all the other classification
48 files of the MIT-BIH arrhythmia database using dual techniques. Fig .2, shows the ROC curve plotted between true
tree complex wavelet (DTCWT) features and artificial neural
TABLE II
network (ANN) classifier and CNN respectively. Diagonal C LASSIFICATION P ERFORMANCE USING CNN
elements of the confusion matrix show the correctly classified
beats. From the Table I, we can see that 963 N beats, Method Class Acc(%) Sens(%) Spe(%) PPr(%)
N 95.24 98.59 86.43 95.01
1156 P beats, 721 L beats, 274 R beats and 890 V beats CNN P 98.49 85.55 99.73 96.80
are misclassified.This shows that less number of beats are (Proposed L 98.99 83.69 99.77 94.89
misclassified as compared to technique reported in [20] small method ) R 98.17 86.93 99.44 94.67
V 98.45 81.36 99.39 88.08
amount (only 10% of data). This shows that the proposed
technique has classified arrhythmias with good accuracy. positive rate (TPR) and false positive rate (FPR) that explains
the relationship between sensitivity and specificity. Perfect
TABLE I classification model contains TPR of unity and zero FPR
C OMPARISON OF THE R ESULTS OBTAINED ON CLASSIFYING OF 48 FILES
FROM MIT-BIH A RRHYTHMIA DATABASE that coincides with the coordinate at upper left corner. The
proposed method achieved an average sensitivity of 94.79%.
Method Class N P L R V From Fig 2, we can see that the proposed method has higher
N 65968 134 625 207 334
P 68 6225 35 14 24 TPR and lower FPR than DTCWT method.
DTCWT features L 981 157 5925 11 273
and R 1024 2 114 5341 12
ANN classifier V 639 144 169 59 5409
N 67562 127 156 367 313
CNN P 1005 6843 13 50 88
(Proposed L 649 13 3699 25 34
method) R 105 71 7 8145 91
V 835 15 23 17 3885

The classification results are evaluated using five statistical


metrics found in the literature [8]. Accuracy,specificity sen-
sitivity and positive-predictivity. Accuracy is defined as the
ratio of correctly classified patterns to the total no of patterns
classified.
TP + TN
Accuracy(Acc) = (3) Fig. 2. Analogy between TPR and FPR for proposed method and DTCWT
TP + TN + FP + FN
Sensitivity is defined as the rate of correctly classified events Table 3 represents the comparative performance of the
among all events. proposed method with different techniques reported on ECG
TP arrhythmia classification technique. In De Chazal et al [21],
Sensitivity(Sen) = (4) Features are selected based on heartbeat morphology and some
TP + FN
temporal features like heartbeat intervals and RR intervals
Specificity is defined as the rate of correctly classified non
are taken and are classified using linear discriminant that has
events among all non events.
attained a low accuracy of 85.9%. In [20], 1D DTCWT is per-
TN formed by decomposing QRS complex up to five scales. The
Specif icity(Spe) = (5)
TN + FP absolute value of the DTCWT coefficients is taken and 1D FFT
Positive-Predictivity is defined as the rate of correctly classi- is calculated. All these features extracted using DTCWT and
fied events in all detected events are combined with temporal features extracted around QRS
complex of each beat. These features are fed into the ANN
TP
P ositive predctivity(P pr) = (6) network and reported a classification accuracy of 94.64%.
TP + FP Although this method yields very good classification accuracy
where TP, TN, FP, FN are true positive, true negative, false it has the following disadvantages (i) A fixed handcrafted
positive, false negative respectively which can be calculated feature extraction method may not be suitable for extracting
TABLE III
S UMMARY OF DIFFERENT CLASSIFICATION TECHNIQUES USING MIT-BIH DATABASE

literature Feature extraction and classification method No of classes Overall accuracy (%)
De Chazal et al [21] morphological and heart beat interval features are classified using Linear Discriminent 5 85.9
Manu Thomas et al [20] DTCWT features and ANN classifier 5 94.64
proposed method (CNN) Feature extraction of raw data, classification using CNN 5 94.79

patient-specific features when classifying beats of a particular [10] N. Emanet, “Ecg beat classification by using discrete wavelet transform
person (ii) Complexity in the structure of this technique and random forest algorithm,” in Soft Computing, Computing with
Words and Perceptions in System Analysis, Decision and Control, 2009.
imposes difficulty in implementation. As mentioned in table ICSCCW 2009. Fifth International Conference on, pp. 1–4, IEEE, 2009.
3, the proposed method has attained an average accuracy of [11] F. Melgani and Y. Bazi, “Classification of electrocardiogram signals
94.79% when trained with the small amount (only 10%) of with support vector machines and particle swarm optimization,” IEEE
transactions on information technology in biomedicine, vol. 12, no. 5,
data. This shows that the proposed technique has classified pp. 667–677, 2008.
beats with good accuracy. [12] S. Osowski and T. H. Linh, “Ecg beat recognition using fuzzy hybrid
neural network,” IEEE Transactions on Biomedical Engineering, vol. 48,
V. C ONCLUSION no. 11, pp. 1265–1271, 2001.
[13] D. Scherer, A. Müller, and S. Behnke, “Evaluation of pooling operations
In this work, ECG arrhythmia classification technique by in convolutional architectures for object recognition,” in International
conference on artificial neural networks, pp. 92–101, Springer, 2010.
using CNN is proposed. CNN simplifies two main blocks, [14] W. Yin, K. Kann, M. Yu, and H. Schütze, “Comparative study of cnn and
feature extraction and classification into a single entity. If a rnn for natural language processing,” arXiv preprint arXiv:1702.01923,
particular CNN is trained, it can be used to classify any other 2017.
[15] C. Nebauer, “Evaluation of convolutional neural networks for visual
patients data. The proposed method assists implementation recognition,” IEEE Transactions on Neural Networks, vol. 9, no. 4,
of CNN in low resolution using only few samples of data. pp. 685–696, 1998.
Hence, we conclude that the proposed method is robust, fast [16] G. B. Moody and R. G. Mark, “The impact of the mit-bih arrhyth-
mia database,” IEEE Engineering in Medicine and Biology Magazine,
and achieves superior classification accuracy, which shows that vol. 20, no. 3, pp. 45–50, 2001.
it is a unique method that can be suited for any new patients [17] J. Pan and W. J. Tompkins, “A real-time qrs detection algorithm,” IEEE
data. The proposed technique can be used in applications transactions on biomedical engineering, no. 3, pp. 230–236, 1985.
[18] S. Kiranyaz, T. Ince, and M. Gabbouj, “Real-time patient-specific ecg
like remote patient monitoring, automatic cardiac arrhythmia classification by 1-d convolutional neural networks,” IEEE Transactions
monitoring systems, cardiac pacemakers, lightweight wearable on Biomedical Engineering, vol. 63, no. 3, pp. 664–675, 2016.
heart monitoring systems. [19] M. Zubair, J. Kim, and C. Yoon, “An automated ecg beat classification
system using convolutional neural networks,” in IT Convergence and
Security (ICITCS), 2016 6th International Conference on, pp. 1–5, IEEE,
R EFERENCES 2016.
[1] O. T. Inan, L. Giovangrandi, and G. T. Kovacs, “Robust neural- [20] M. Thomas, M. K. Das, and S. Ari, “Automatic ecg arrhythmia
network-based classification of premature ventricular contractions using classification using dual tree complex wavelet based features,” AEU-
wavelet transform and timing interval features,” IEEE transactions on International Journal of Electronics and Communications, vol. 69, no. 4,
Biomedical Engineering, vol. 53, no. 12, pp. 2507–2515, 2006. pp. 715–721, 2015.
[2] D. Cvetkovic, E. D. Übeyli, and I. Cosic, “Wavelet transform feature [21] P. De Chazal, M. O’Dwyer, and R. B. Reilly, “Automatic classification of
extraction from human ppg, ecg, and eeg signal responses to elf pemf heartbeats using ecg morphology and heartbeat interval features,” IEEE
exposures: A pilot study,” Digital signal processing, vol. 18, no. 5, transactions on biomedical engineering, vol. 51, no. 7, pp. 1196–1206,
pp. 861–874, 2008. 2004.
[3] G. Chen, “Automatic eeg seizure detection using dual-tree complex
wavelet-fourier features,” Expert Systems with Applications, vol. 41,
no. 5, pp. 2391–2394, 2014.
[4] J. J. Oresko, Z. Jin, J. Cheng, S. Huang, Y. Sun, H. Duschl, and
A. C. Cheng, “A wearable smartphone-based platform for real-time car-
diovascular disease detection via electrocardiogram processing,” IEEE
Transactions on Information Technology in Biomedicine, vol. 14, no. 3,
pp. 734–740, 2010.
[5] Y.-C. Yeh, W.-J. Wang, and C. W. Chiou, “Cardiac arrhythmia diagnosis
method using linear discriminant analysis on ecg signals,” Measurement,
vol. 42, no. 5, pp. 778–789, 2009.
[6] J. A. Nasiri, M. Naghibzadeh, H. S. Yazdi, and B. Naghibzadeh,
“Ecg arrhythmia classification with support vector machines and genetic
algorithm,” in Computer Modeling and Simulation, 2009. EMS’09. Third
UKSim European Symposium on, pp. 187–192, IEEE, 2009.
[7] D. A. Coast, R. M. Stern, G. G. Cano, and S. A. Briller, “An approach
to cardiac arrhythmia analysis using hidden markov models,” IEEE
Transactions on biomedical Engineering, vol. 37, no. 9, pp. 826–836,
1990.
[8] Y. H. Hu, S. Palreddy, and W. J. Tompkins, “A patient-adaptable ecg
beat classifier using a mixture of experts approach,” IEEE transactions
on biomedical engineering, vol. 44, no. 9, pp. 891–900, 1997.
[9] M. K. Das and S. Ari, “Patient-specific ecg beat classification technique,”
Healthcare technology letters, vol. 1, no. 3, pp. 98–103, 2014.

You might also like