Cardiac Arrhythmia classification using deep learning

The present work aims to obtain an automated program based on deep learning to detect and classify cardiac arrhythmia using electrocardiogram (ECG) data. One of the main obstacles in working with medical dataset is the limited availability of public medical data and the fact that only a small fraction of data represents non-normal medical conditions. In the present work we will compare the two convolutional neural network models inspired by VGGNet and ResNet in predicting of cardiac arrhythmia. Our calculations show that the two methods are equally good in predicting the overall accuracy for large dataset. However, ResNet shows a slightly better performance in predictions for much smaller dataset.


Introduction
Cardiovascular diseases (CVDs) are still the leading cause of death both globally and locally [1,2]. Some of these diseases are related to the structural issue in the heart compartments and some others are more related to electrical disorder. Cardiac arrhythmia is one of the CVDs that is caused by this electrical disorder that may or may not indicate serious heart condition. Electrocardiogram has been gold standard in acquiring electrical signals that travel along heart compartments. The signal is recorded over a period of time and is then analyzed and interpreted by medical doctor. In the early stage of arrhythmia, the nonnormal signal may show up only few times over a long period of time, thus posing difficulties for doctor to monitor and confirm. Another issue is that the normal signal morphologies may vary from person to person and differs from individuals with active to individuals with sedentary lifestyles [3][4][5].
This study aims to design two machine learning (ML) models based on convolutional neural network (CNN) frameworks to classify cardiac arrhythmia with ECG records as input data. One of the frameworks is inspired by VGGNet [6], a popular choice for machine learning in computer vision due to its simplicity and accuracy. The other framework is based on ResNet [7], an ML model that is capable to continually improve the learning with more depth of added layers. In the present work we use PhysioNet database [8] to test our models.

Data preparation and segmentation
The ECG signals obtained from PhysioNet Database is classified into many arrhythmia conditions sampled at 360 Hz. The Association for the Advancement of Medical Instrument (AAMI) classifies arrhythmia into 5 categories: fusion beats (F), normal beat (N), unknown beat (Q), ventricular ectopic beat (V), and supra-ventricular beat (S). The differences among these beats are related to differences in morphological features of the ECG signals.
The first step in data preparation is to clean ECG signals from the baseline wander which is mainly caused by the respiration of patients during ECG recording. This is done by applying two median filters 200 ms and 600 ms consequentially [9] and the result is shown in Figure 1.
The next step is to crop the whole ECG signals around each of the peaks, namely R points, with 260 data points around each of these peaks. The distances between neighboring peaks are not constant and vary from patient to patient. This number is chosen to best represents all possible different length of signals in whole ECG dataset.

Method
In this present work we utilize two different type of neural networks which are based on convolutional neural network (CNN). The first one is a CNN inspired by VGGNet [6] and the second one is a CNN which uses ResNet architecture [7]. The computer program is implemented in Tensorflow framework [10].

CNN -VGGNet blocks
The whole neural network is divided into 3 main blocks, namely:

CNN -ResNet blocks
One of the main advantages of ResNet [7] over the previously built algorithm is that is capable to avoid or reduce gradient degradation that occurs in typical machine learning framework. This is achieved by utilizing skipping connections in the framework as shown in Figure 3. In this present work we use ResNet with depth values 20 to approximately match the number of parameters used in VGGNet.   Figure 4 shows that both models show convergences with increase number of epochs. It also shows that our model does not overfit. The two methods give around 99% overall accuracy. Although the overall accuracy is good, it is not equally distributed across the five classes. Arrhythmia class with small amount of data has lower predictive accuracy. This could result in misdiagnosis, as the nonnormal medical conditions may be recognized as normal. Two important parameters to check are precision and recall values and here we are particularly interested in calculating recall values because it contains information of fraction of false negative predictions, and these values are displayed in confusion matrices described in the next section. Figure 5 shows the correlations between true labels and prediction known as confusion matrices. It has been tailored to show recall values and both shows that class F is quite often predicted as class N or V, and class S is quite often predicted as class N.

Use of smaller dataset
The dataset we use is inherently imbalance because the amount of data of normal heart condition is much larger than the amount of data of non-normal heart condition. Here we want to study the predictive power of the two methods with much smaller dataset (each class has 800 single ECG signal) (a) CNN -VGGNet (b) CNN -ResNet Figure 6. Confusion matrices for both models for smaller dataset The confusion matrices for the two methods again show relatively equal performance. However, ResNet seems to show a slightly better overall accuracy (~91.75 %) than VGGNet (~91.25 %).

Conclusion
A study has been conducted to compare the performance of two CNN-based frameworks in classifying arrhythmia using ECG signals. The two methods show relatively good and equal performance in predicting the classification in test data set, using 4-cross validation. However, the ResNet shows a slightly better performance (+0.5%) when used to predict a much smaller data set. Future work is required to improve the overall accuracy for all classes of arrhythmia. This can be approached with two methods: use of synthetic data to overcome the imbalance data issue and use of importance sampling to improve the predictions in less prevalent class.