Arrhythmia Classification using 2D Convolutional Neural Network

Arrhythmia is an abnormal situation of heartbeat rate that may cause a critical condition to our body and this condition gets more dangerous as our cardiovascular system gets more vulnerable as we grow older. To diagnose this abnormality, the arrhythmia expert or cardiologist uses an electrocardiogram (ECG) by analyzing the pattern. ECG is a heartbeat signal that is produced by a tool called an electrocardiograph sensor that records the electrical impulses produced by the heart. Convolutional Neural Networks (CNN) is often used by researchers to classify ECG signals to Arryhtmia classes. The state-of-the-art research had applied CNN 2D (CNN 2D) with accuracy up to 99% with 128x128 image size obtained by transforming the ECG signal. In this paper, authors try to classify arrhythmia disorder with a different approach by creating simpler image classifier using CNN 2D with a smaller variety of input size that is smaller than state-the-art input and group the classes based on transformed ECG signal from MITBIH Arrhythmia database with the purpose to know what the most optimum input and the best accuracy to classify ECG signal image. The result of this research had produced an accuracy of up to 98.91% for 2 Classes, 98.10% for 7 Classes dan 98.45% for 8 Classes. Keywords—Convolutional neural network; CNN; CNN 2D; image classifier; electrocardiogram; ECG; arrhythmia


I. INTRODUCTION
Arrhythmia is a heart disorder that can be life-threatening. The symptom is a heartbeat rhythm abnormally that can be any of the following: too fast, too slow or irregular. Irregular heartbeats can impact other organs because the blood does not flow well, the impacts can either be hurting the organ or stop it [1]. One way to find out or diagnose this disorder is by using an electrocardiogram (ECG). ECG is a diagram produced by Electrocardiograph sensors that record electricity impulses produced by the heart [2]. However, this process takes a long time and the number of experts who can handle these cases are very few and it's hard to diagnose this disorder manually. Therefore, if arrhythmia pattern on ECG data can be detected automatically, it will help experts to detect this disorder early and can reduce casualties.
Convolutional Neural Network (CNN) is often used by researcher to classify ECG signal patterns into arrhythmia classes by using both 1D CNN and 2D CNN showing accuracy up to 92 % for the former for up to 17 classes [3]- [10] and 99% for the latter up to 8 Classes using 128x128 pixel transformed ECG signal [11]- [13]. This shows that 2D CNN performed better in classifying arrhythmia with higher accuracy than 1D CNN [14]. Using 128x128 size produced high accuracy but it also consumed high computational resources to train the model, moreover, the transformed data that is used to train the model is quite a lot.
In this paper, authors' purpose is to propose a new approach of 2D CNN model to classify up to 8 classes of arrhythmia including Normal Beat (NRML), Atrial premature beat (APB), Premature ventricular contraction (PVC), Premature Beat (PB), Fusion of paced and normal beat (FPBN), Fusion of ventricular and normal beat (FVCN), Left bundle branch block beat (LBBB) and Right bundle branch block beat (RBBB) with smaller input size than current 2D CNN model Classifier [11], [12]. Authors try to compare multiple input sizes including 64x64, 32x32 and 16x16 to see the different accuracies between input sizes and also group classes that are divided into three groups: Normal (NRML) And Abnormal (ANML), All Abnormal Classes and All Classes to see how our model accuracy between different input. This paper is structured as follows: Section 2 contains a literature review about arrhythmia, ECG and Neural Networks. In Section 3, the authors show all related works about the classification of Arrhythmia group classes by using ECG as input. Section 4 shows methods that authors used including dataset, proposed solution, experimental design, and evaluation method. In Section 5 authors show experiment results and finally, the conclusion is in Section 6.

A. Arrhythmia
Arrhythmia is a disorder that occurs to the heart, making the heartbeat pace either too fast or too slow. In some cases, the heartbeat rhythm is erratic. This disorder causes ineffective pumping of the blood to the organ and can cause organ death or organ damage that might cause sudden death [1], [15]. Experts use ECG to detect and analyze arrhythmia by incorporating pattern recognition [2].

B. Electrocardiogram
An electrocardiogram or ECG is a recording of the electrical activity of the heart [2]. ECG analysis is very important for diagnosing arryhthmia. Some features can be extracted from ECG signals including P Wave, QRS Complex, T Wave, and other features which can be seen in Fig. 1. Vol. 11, No. 4, 2020 202 | P a g e www.ijacsa.thesai.org

C. Deep Learning
Deep Learning enables computational models consisting of several layers of processing to study the representation of data with various levels of abstraction [14]. Deep Learning models have dramatically improved state-of-the-art speech recognition, visual object recognition, object detection and many other domains such as drug discovery and genomics. In-depth learning finds complicated structures in large data sets by using the backpropagation algorithm to show how machines must change the internal parameters used to calculate representations at each layer from representations in the previous layer. The Deep Convolutional Neural Network has produced breakthroughs in processing images, video, speech, and audio, while the Recurrent Neural Network (RNN) shows sequential data processing such as text and speech [17].

III. RELATED WORKS
Acharya et al. [3] conducted research to establish Computer-aided Diagnosis (CAD) to diagnose arrhythmia using eleven CNN layers based on the PhsyioBank public dataset with a total of 614,526 ECGs. Before processing the data, the data are cleansed by using Daubechies wavelet 6 (Singh and Tiwari 2006), then the data are segmented and sorted by heart condition with a notation that previously existed in the database. Each segment is normalized with a Z-Score to eliminate the amplitude scale and eliminate the offset effect before the data are processed for 1-Dimensional CNN Deep Learning training and testing. This method shows 92.5% accuracy in data with a length of 2 seconds and 94.9% with data that is 5 seconds in length.
Rajpurkar et al. [5] conducted research that began by collecting a dataset in which there are 30,000 unique patient data and annotated 64,000 datasets. The 336 data samples were obtained using 34 Convolutional Neural Network layers. To optimize the model, the Residual Network architecture uses a portion of the connection shortcut. The trained model was then tested by comparing the classifications made by the model and those performed by cardiologists in 12 classes of Arrhythmia. The result, this model showed superiority in comparison to cardiologists with a value of 80% precision and 82% sensitivity while cardiologists with 76% precision and 75% sensitivity.
Yıldırım et al. [10] classified a total of 17 classifications using the MTI-BIH dataset containing data from 45 patients with a length of 10 seconds where the data were not filtered or cleansed first but before being re-processed the data on a scale was first obtained with 16 CNN 1D layers. The model that was built not only showed a high accuracy of 91.33% for 17 classes, but it also showed a fast detection of 0.015s for the model classifying ECG signals.
Xiong et al. [6] built RyhtmNet, 1 Dimension Convolutional Recurrent Neural Network with 21 layers that is a combination of Convolutional Neural Network and Recurrent Neural Network. The dataset used for this training model comes from the 2017 PhysioNet / Computing in Cardiology (CinC) Challenge. It consists of 8528 ECG data with 9 -60 seconds of data variation. The model that was built processes 5 seconds data successfully classifying 3 types of arrhythmia with an accuracy of 82%.
Billeci et al. [4] developed an algorithm to classify ECG signals specifically for atrial fibrillation, only 2 classifications are carried out by this algorithm, namely atrial fibrillation and other arrhythmias. The database used is from MIT-BH AF. This algorithm is a combination of RR Analysis, P-Wave and Frequency Spectrum Analysis that had been modified to detect Arrhythmia AF. This algorithm shows good accuracy which is 98% even with a small classification.
Izci et al. [13] used 2D Convolutional Neural to classify 5 arrhythmia classes by transforming MIT-BIH Arrhythmia database to 128x128 size grayscale image and 5 layer CNN resulting in 97.42% accuracy.
Jun et al. [12] used 2D CNN with 11 layers by firstly transforming ECG signal from MIT-BIH Arrhythmia dataset into images with size 128x128. Afterward, the transformed data is used to train the model resulting in an average accuracy of 99.05% with 8 class classification.
Huang et al. [18] classified 5 arrhythmia classes using MIT -BIH arrhythmia database that was transformed into a timefrequency spectrogram with size 256x256 within 10 seconds of data to train and test the model resulting in 99% average accuracy.

IV. METHODS
The research begins by determining the background problem of the research to be conducted, then conducting a literature study to find out the state-of-the-art of the field to be examined. Then the next set of objectives and scope of research, at this stage also conducted a literature study to show the views of the research to be conducted. after that, the new model is then built added to the theories and techniques used to build the model. After the model has been built, the model is then validated compared to the current research showing the contribution of the research conducted.

A. Data Set
From the MIT-BIH Arrhythmia database [19], hosted at PhysioNet (http://www.physionet.org), ECG signals were acquired. This dataset contains an ECG signal from 48 subjects that had been annotated with 360 Hz frequency. Authors then transformed this data by first segmenting the signal for every second with 360 Hz frequency resulting 108819 heartbeat signal images with 8 Classes including Normal beat (NRML), Atrial premature beat (APB), Premature ventricular contraction (PVC), Premature Beat (PB), Fusion of paced and normal beat (FPBN), Fusion of ventricular and normal beat (FVCN), Left bundle branch block beat (LBBB) and Righ bundle branch block beat (RBBB). A sample of every signal can be seen in Fig. 2.

B. Proposed Solution
This 2D Convolutional Neural Network Classifier is 8 layers Neural network. As seen in Fig. 3, at the first layer, there are Convo2D with 32 filters and kernel size 3x3 and then 64 filters with 3x3 kernel size on the next layer. Next is to use max-pooling to pool the best feature. Afterward, the output randomly dropout data with a rate of 0.25 to remove inconsistency data. On the next layer, there is flatten to preparing data to be fully connected to the next layer. We do dropout again with rate 0.5 and then on the final layer, we are using Softmax activation to convert the matrix into probability.

C. Experimental Design
Using Transformed ECG signal image we convert it to several sizes including 64x64, 32x32 and 16x16 as illustrated in Fig. 4. We also group the data into 3 group which is Group 1 Consist of 2 Class Normal and Abnormal (ANML). Group 2 is 7 Class of Abnormal Class and Group 3 that Contains 8 Class including Normal And abnormal class.

D. Evaluation Method
To measure the level of accuracy created by the model, researchers used a k-fold cross-validation strategy. This measurement strategy divides data as many as k randomly and equally and then conducts training with 90% of the data and uses 10% of the other data to do the test [20] as illustrated in Fig. 5. This strategy is used to determine whether the model that has been built with limited data, in general, can predict data that is not used in training. The performance of each kfold is evaluated based on the accuracy (Acc), Precision (P), Recall (R) and F1-Score (F1).  After doing the experiment, we collect the result and compare the accuracy result from each experiment to another.

A. Result of 2 Classes
From 10-fold validation for group 1, it contains 2 classes, input size 64x64 leading consistently following input size 32x32 and 16x16. With the difference between 64x64 and 32x32, less than 1% and all accuracies are more than 96% showing our model classified well within 2 classes as seen in Fig. 6. Table I shows the score for every class and input, as shown the highest score for precision is ANML class for 99.10%. The highest score for Recall is NRML class with 99.60% and the best F1 score is NRML class with 99.22%, showing on this model NRML class is predicted better than ANML class.
From Fig. 7, the 64x64 input size shows the best accuracy with 98.91% followed by 32x32 input size with 98.41% accuracy and 16x16 input size with 96.34% accuracy. The difference between 64x64 and 32x32 is less than 1% and accuracy is more than 96% showing that our model can classify arrhythmia classes with high accuracy of 2 classes.

B. Result of 7 Classes
From 10-fold validation for group 2, it contains 7 classes of Abnormal class, input size 64x64 leading consistently, following with input size 32x32 and 16x16. With the difference between 64x64 and 32x32, less than 1% and all accuracy are more than 91% showing our model classified well within 7 classes as seen in Fig. 8. Table II shows the highest precision score is RBBB class with 99.23%. The highest recall score is PB class with 99.64% and for F1, the highest score is PB class showing that PB class is predicted better than another one. And for classes that are fusion beats like FPBN and FVCN has big difference score with another class and getting smaller when the input size is smaller for 16x16 input size precision score is 81.70%, recall is 41.05% and F1 is 53.51% and FVCN has a precision of 83.01%, recall 61.91% and F1 70.78%. Fig. 9 shows that PVCN was predicted as PVC with 22% accuracy and FPBN was predicted as PB with 27% accuracy. This may happen because fusion beats have a similar feature with another beat. Fig. 10 shows that 64x64 input size is showing the best accuracy with 98.1% followed by 32x32 input size with 97.42% accuracy and 16x16 input size with 92.82% accuracy. The difference between 64x64 and 32x32 is less than 1% and accuracy is more than 92% accuracy, showing that our model can classify arrhythmia classes with high accuracy of 7 classes and less than average accuracy of 2 classes.

C. Result of 8 Classes
From 10-fold validation for group 3, it contains 8 classes, input size 64x64 leading consistently following input size 32x32 and 16x16. With the difference between 64x64 and 32x32, less than 1% and all accuracy are more than 94% showing our model classified well within 8 classes as seen in Fig. 11. Table III shows that the highest precision score is RBBB class with score of 99.00%, for recall score the best score is NRML with 99.70% and the highest for F1 score is PB with score of 99.23%. In these group classes, there is a big decreasing accuracy related to fusion beats for class FPBN and PVCN for input size 16x16 FPBN class had precision score 94.47%, recall 18.28% and F1 30.23%. FVCN had precision score of 87.81%, recall 13.86% and F1 23.26% which is worse than group 2 with 7 classes.
As seen in Fig. 12, for input size 16x16, the FVCN class predicted as NRML up to 87% and PVC 6%. FPBN also predicted as NRML with 49% dan PB with 16%. The precision for fusion beat gets worse because on group 3 classes, Normal class which is FVCN and FPBN has similar features.  (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 11, No. 4, 2020 206 | P a g e www.ijacsa.thesai.org For input 32x32 and 8 class in Fig. 13, it shows better accuracy even though FVCN still predicted as PVC 14% and NRML 25%. FPBN was still predicted as NRML 4% and PB 10%.
In Fig. 14, average accuracy for 8 class for input with size 64x64 shows the best accuracy with score of 98.45% followed by 32x32 input size with 97.98% accuracy and 16x16 input size with 95.08% accuracy. The difference between 64x64 and 32x32 is less than 1% and the difference between 32x32 and 16x16 is less than 3%. Overall accuracy is more than 95% showing that our model can classify arrhythmia classes with high accuracy of 8 classes and more than 7 classes.
In Fig. 15, a group of 2 class has the highest accuracy with 97.89% followed by a group of 8 class with 97.17% and a group of 7 class with 96.11%. even though a group of 2 class has the highest score, it only had a 1% difference with a group with 8 class. making a group with 8 classes is the best choice for a group of classes.   Overall accuracy for input size in Fig. 16 shows that input with size 64x64 has the highest score with 98.49% followed by input size 32x32 with 97.94% accuracy and input with size 16x16 with 94.75% accuracy. The difference between input size 64x64 and 32x32 is less than 1%. Making input of 32x32 as a better choice for less computational resources and input with size 64x64 is a better choice for a higher accuracy model. www.ijacsa.thesai.org

D. Comparison with Related Works
After the experiment, authors then compared authors' result with related works that also used CNN 2D and used the MIT-BIH arrhythmia database but with different approaches as seen in Table IV. As seen in Table IV, authors' proposed approach shows that with smaller input over the state-of-the-art approach, the result showed the difference on accuracy with the highest accuracy being less than 1%. Authors' approach also has only 8 layers, which is less complex than the state-of-the-art approach that consists of 11 and 13 layers even though the complexity is higher than Izci et al. [13]. This proves that authors' proposed approach has better accuracy.

VI. CONCLUSION
For all the experiments result, authors can conclude that authors' 8 layer CNN 2D model can classify arrhythmia classes from transformed ECG signal images without feature extraction (Non-QRS Complex) with high accuracy and smaller input size compared to [11], [12]. With this model and input, we can use less computational resources and still attain high accuracy.
The highest accuracy is on 64x64 input with an average of 98.91% for 2 Class, 98.10% for 7 Class and 98.45% for 8 Classes. However, 32x32 size input also had high accuracy with an average 98.41% for 2 class, 97.42% for 7 class and 97.98% for 8 class which is less than 1% difference. For input size 16x16, showing significance accuracy drop with an average of 96.32% for 2 class, 92.82 for 7 class and 95.08 for 8 class, but this accuracy is still high which is higher than 90%.
After looking at the experiment result, it can be concluded that the most optimum input size is 64x64 using 8 classes with accuracy up to 98.45%. The input size of 32x32 using 8 can also be a good choice for less computational resources with accuracy up to 97.98%.
In this experiment, we learned that the accuracy of fusion beat class decreased when the input size is smaller, this happened because fusion beat has a similar feature with another beat and when transformed into a smaller size the feature gets similar and gets harder to predict. In the end, we can conclude that a 64x64 input size has better accuracy than 32x32 and 16x16.
In the future study, we can improve the accuracy of smaller input like 16x16 size, we can increase the complexity of CNN layer on models and change how transforming ECG, hence the pattern can be differentiated between fusion beat classes.