# Cardiac Disorder Classification by Electrocardiogram Sensing Using Deep Neural Network

Authors: Ali Haider Khan; Muzammil Hussain; Muhammad Kamran Malik
Journal: Complexity
 (2021)

---

## Abstract

Cardiac disease is the leading cause of death worldwide. Cardiovascular diseases can be prevented if an effective diagnostic is made at the initial stages. The ECG test is referred to as the diagnostic assistant tool for screening of cardiac disorder. The research purposes of a cardiac disorder detection system from 12-lead-based ECG Images. The healthcare institutes used various ECG equipment that present results in nonuniform formats of ECG images. The research study proposes a generalized methodology to process all formats of ECG. Single Shoot Detection (SSD) MobileNet v2-based Deep Neural Network architecture was used to detect cardiovascular disease detection. The study focused on detecting the four major cardiac abnormalities (i.e., myocardial infarction, abnormal heartbeat, previous history of MI, and normal class) with 98% accuracy results were calculated. The work is relatively rare based on their dataset; a collection of 11,148 standard 12-lead-based ECG images used in this study were manually collected from health care institutes and annotated by the domain experts. The study achieved high accuracy results to differentiate and detect four major cardiac abnormalities. Several cardiologists manually verified the proposed system’s accuracy result and recommended that the proposed system can be used to screen for a cardiac disorder.


---

## Body

## 1. Introduction

According to the Centers for Disease Control and Prevention (CDC) and the American Health Monitoring Organization, the leading cause of death is cardiovascular disease [1]. CDC revealed that 74% of the population is affected yearly by heart disease. Cardiovascular diseases can be prevented if an effective diagnostic is made at the initial stages [2]. Modern medical science has shown substantial and potent solutions to cope with heart-related problems. In the era of technology, medical issues can be tackled with advanced techniques of Information technology. The most common heart disease detection technique is based on electrocardiogram (ECG), angiography screening, and blood test. The ECG test is also referred to as the diagnostic assistant tool for screening heart diseases [3]. ECG is a visual signal captured or measured by placing electrodes on the body’s surface to detect voltage changes (Figure 1).Figure 1
ECG electrodes.ECG represents the possible cardiac abnormalities in their ST segments: normally, the rises in ST segments, changes in segments, or flipping ofT waves, or new Q wave; these abnormal segments reflect cardiac disease symptoms.Researchers [4–6] investigated many techniques for automatically detecting cardiovascular disease using machine and deep learning techniques, typically by using ECG in one or two-dimensional voltage amplitude data represented as time-series signals. To classify ECG signals in time series, different methods are explored and show a substantial result. Ubeyli [7] used an eigenvector method for feature extraction and to classify ECG beats. Sharma et al. [8] used time frequency-based ECG signals for feature extraction of the eigenvalue decomposition of Hankel matrix and Hilbert transform and used the random forest to detect the cardiovascular disorder.In the current era, systems are being developed for the automatic detection of cardiac-related issues. These systems predict high accuracy results based on one-dimensional ECG beats signals but are still not adopted as tools in health care institutes. The main areas that affect the success of these approaches, i.e., selection of feature, extraction techniques, types of classification algorithms, and the most important, the use of imbalanced data for classification can reduce the recognition accuracy of the minority class [6]. Moreover, state-of-the-art studies represents the classical methods to show high accuracy in classification and detection tasks on one lead-based ECG images instead of standard 12-lead-based ECG images. Furthermore, the healthcare institutes used various ECG equipment, presenting results in nonuniform formats of ECG images. The state-of-the-art research was unable to propose a generalized methodology for nonuniform formats of ECG images. The availability of 12-lead-based ECG source images is not publicly available for researchers. In this research, the main focus is to provide a novel automatic detection tool relatively similar and adaptable for the cardiac hospitals to process the 12-lead-based ECG images.Automated cardiac disorder detection via a deep neural network using 12-lead-based ECG image processing is critical. Deep neural network works in the same fashion as a human brain, founded on mathematical formulas/models. The mathematics of functional principles of deep neural networks targets to understand and recognize the pattern among different components. The deep neural network’s fundamental unit is a neuron trained by repetitive tasks and gets experienced just like a human brain through acquired knowledge attained in training. The focus of training and acquiring knowledge is to establish a connection between input and output. After training, the system is capable of detecting the objects about what it has been trained.The primary motivation of this study is to develop an efficient automated model for the diagnosis of cardiac disorder on ECG that can feasibly be implemented on portable healthcare devices. Figure2 shows the structure of forward pass convolutional neural network with SSD detector.Figure 2
Structure of a forward pass convolutional neural network with SSD detector.The paper is organized into seven sections. The research community’s related work in the current field is presented in section2 with a close comparison. Section 3 illustrates the collection of the dataset used in this study, and data preprocessing techniques are discussed in section 4. Section 5 illustrates the methodology with the proposed cluster. Simulated results are discussed in section 6. The paper is concluded and discourses the future directions of our work in section 7.


## 2. Related Work

In the past few decades, the research community has focused on artificial intelligence by working in digital image processing, computer vision, and machine learning to provide a platform between human and machine theory [6–9]. This work is widely recognized by several companies and medical fields for classification, detection, and identification of cardiac disorder, which play a vital role in the health community. Techniques used for the identification of cardiac disorder using deep learning have been focused on for many years.In recent studies, the state-of-the-art research on deep learning gained the potential growth with satisfactory results in detection and classification tasks on medical images [9]. Most studies treated dimensional ECG signals as time-series classification by keeping in the view of deep learning. For example, PCGs and ECGs are used to diagnose heart disease. PCGs (also known as heart sound auscultation) is commonly listened to or recorded by practitioners through a stethoscope, identifying the heart irregularities. For this reason, heart signals have been critically studied to make a diagnosis [10–13]. CNN is considered a state-of-the-art tool for detecting and classification heart signals and has been studied with several variations like 1-dimensional, 2-dimensional, or the combination of both [14, 15]. Similarly, Noman et al. [15] proposed a framework based on 1-dimensional CNN for direct feature learning from raw heart signals and 2-dimensional CNN, which takes 2-dimensional time-frequency feature maps. Xia et al. [16] proposed a model for automatic wearable ECG classification. Huang et al. [17] transformed five types of heartbeats’ signals into time-frequency spectrograms and then trained a 2D-CNN for classifying arrhythmia types. Lu et al. [18] transformed the 1D signals into 2D images by joining the dots of 1D signals. Ji et al. [19] also used a 1D signal, converted all signals into 2D, and used R-CNN for ECG classification.In the state-of-the-art research studies, these time-series data used feature selection manually, which is not adaptable in different application environments. Moreover, ECG’s time-series data with signal leads are not appropriate for stable baseline wanders, muscle contraction, and power line interface. In general, the practical methods normally adopted by a cardiologist for screening cardiac patients are 12-lead-based ECG images. In standard 12-lead-based ECG images, six leads are considered “limb leads” because they are placed on the individual’s arms and/or legs. The other six leads are considered “precordial leads” because they are placed on the torso (precordium). The six limb leads are lead I, II, III, aVL, aVR, and aVF. The six precordial leads are called leads V1, V2, V3, V4, V5, and V6. Figure3 shows sample 12-lead-based ECG image used in this study.Figure 3
Sample ECG image.As concerned with ECG images, this research study is unique. In the real, collection of ECG images is done by recording or screening from Telehealth ECG diagnostic tool used in healthcare institutes. It is hard to gain these 12-lead-based on ECG images. Moreover, these images are used as a standard tool to detect the cardiac disorder in real-time applications.In this research, the main focus is to provide a novel automatic detection tool relatively similar and adaptable for cardiac hospitals by using a deep neural network (DNN). The DNN has been widely recognized as a reliable approach to directly detect the characteristics of features from medical images [20, 21]. DNN is best suited for medical images problem; that is the main reasons authors used SSD MobileNet V2, a deep neural network-based architecture to detect the cardiac disorder on 12-lead-based ECG images.


## 3. Dataset

The steps involved in collecting the 12-lead-based ECG Images data required to develop the system is thoroughly described in this section.


### 3.1. Link Identification

Data resource identification was the main and primary challenge for the cardiac disease detection system. Consequently, in the first phase, various sites, repositories were explored. However, in spite of all efforts, all publicly available datasets that can be collected are time-series data. Nevertheless, those available datasets are inconsistent with the data needed for this study. The manual collection of 12-lead-based standard ECG images directly from the cardiac institute is a difficult task. The authors approached one of the best cardiac institutes, i.e., Ch. Pervaiz Elahi Institute of Cardiology Multan, Pakistan, for data collection. The manual collection of ECG images from the cardiac institute took several months. The ECG images collected have been endorsed and annotated by numerous cardiologists and reexamined by the domain experts who have experience in ECG interpretation.


### 3.2. Data Description

Table1 shows the total numbers of Images used for cardiac disorder detection used for each class.Table 1
Data description.
Sr.Class12-lead ECGTotal images1Myocardial infarction (MI)24028802Abnormal heartbeat23327963Previous history of MI17220644Normal2843408


### 3.3. Data Availability

This study has collected data uploaded to a data repository [22], which contains complete data-related information to help the scientific community.


## 3.1. Link Identification

Data resource identification was the main and primary challenge for the cardiac disease detection system. Consequently, in the first phase, various sites, repositories were explored. However, in spite of all efforts, all publicly available datasets that can be collected are time-series data. Nevertheless, those available datasets are inconsistent with the data needed for this study. The manual collection of 12-lead-based standard ECG images directly from the cardiac institute is a difficult task. The authors approached one of the best cardiac institutes, i.e., Ch. Pervaiz Elahi Institute of Cardiology Multan, Pakistan, for data collection. The manual collection of ECG images from the cardiac institute took several months. The ECG images collected have been endorsed and annotated by numerous cardiologists and reexamined by the domain experts who have experience in ECG interpretation.


## 3.2. Data Description

Table1 shows the total numbers of Images used for cardiac disorder detection used for each class.Table 1
Data description.
Sr.Class12-lead ECGTotal images1Myocardial infarction (MI)24028802Abnormal heartbeat23327963Previous history of MI17220644Normal2843408


## 3.3. Data Availability

This study has collected data uploaded to a data repository [22], which contains complete data-related information to help the scientific community.


## 4. Data Preprocessing

Data preprocessing is an important step before inputting the data into the model for training. In this phase, data can be organized into meaningful information. Figure4 shows the steps used in data preprocessing.Figure 4
Data preprocessing.


### 4.1. Data Resizing

The ECG images are higher than the 800 KB in size, requiring lots of time to train the algorithm, so all images required modification. The ECG images were modified to less than 300 KB in size to achieve more training steps in lesser time.


### 4.2. Data Labeling

This study collected data required to label all 12 leads of each ECG image before training. In this study, LabelImg tool is used to label the dataset classes, which means authors labelled 48 objects of all four classes shown in Figure5 that our trained model will need to detect.Figure 5
(a) Abnormal heartbeat; (b) myocardial infarction; (c) previous history of MI; (d) normal Class.
(a)(b)(c)(d)


## 4.1. Data Resizing

The ECG images are higher than the 800 KB in size, requiring lots of time to train the algorithm, so all images required modification. The ECG images were modified to less than 300 KB in size to achieve more training steps in lesser time.


## 4.2. Data Labeling

This study collected data required to label all 12 leads of each ECG image before training. In this study, LabelImg tool is used to label the dataset classes, which means authors labelled 48 objects of all four classes shown in Figure5 that our trained model will need to detect.Figure 5
(a) Abnormal heartbeat; (b) myocardial infarction; (c) previous history of MI; (d) normal Class.
(a)(b)(c)(d)


## 5. Methodology

The methodology used in this paper is to process the 12-lead-based ECG images to detect a cardiac abnormality. Single shot detector (SSD) MobileNet v2 is used in this study for model design. SSD is used to detect the objects that can classify and locate the objects in one step. The block diagram of the model used in this research study is shown in Figure6.Figure 6
Research model.


### 5.1. Model Configuration

In this study, the model is implemented using Tensorflow API and Google Colab to build and train a cardiac disorder detector, using pretrained SSD MobileNet V2. In this study authors used the batch size of 24 and 200K training steps for model training. Complete detail of the implementation with working source code is uploaded and can be seen on the GitHub of this project [23].


#### 5.1.1. Dataset Splitting

The dataset used in this study is split so that 80% of the images are used for training the algorithms, while the remaining 20% is used for testing each class.


#### 5.1.2. Number of Classes

Classes mean the number of objects that the model should learn and detect after training. In this case, the algorithms are responsible for detecting 4 classes (i.e., normal, abnormal heartbeat, myocardial infarction, and previous history of MI), and each class contains 12 leads; therefore, the number of objects is set to 48.


#### 5.1.3. Learning Rate

A default learning rate of 0.0002 has been used to train the algorithms.


### 5.2. Training

Once all hyperparameters are configured, then the training process starts with an average step speed of 0.50 s. Training will take almost 4 days to complete the desired steps. The model will validate itself on the test dataset on each iteration and then display the prediction accuracy and loss. A sufficient number of steps are required for a better prediction of the model. Figure7 shows the average loss (price paid for the wrong detection) of the model.Figure 7
Average loss.


### 5.3. Code Availability

The code used in this study can be found athttps://github.com/alijiskani/ECG_Object_Detection, which contains code configuration files, source code, and a user manual.


## 5.1. Model Configuration

In this study, the model is implemented using Tensorflow API and Google Colab to build and train a cardiac disorder detector, using pretrained SSD MobileNet V2. In this study authors used the batch size of 24 and 200K training steps for model training. Complete detail of the implementation with working source code is uploaded and can be seen on the GitHub of this project [23].


### 5.1.1. Dataset Splitting

The dataset used in this study is split so that 80% of the images are used for training the algorithms, while the remaining 20% is used for testing each class.


### 5.1.2. Number of Classes

Classes mean the number of objects that the model should learn and detect after training. In this case, the algorithms are responsible for detecting 4 classes (i.e., normal, abnormal heartbeat, myocardial infarction, and previous history of MI), and each class contains 12 leads; therefore, the number of objects is set to 48.


### 5.1.3. Learning Rate

A default learning rate of 0.0002 has been used to train the algorithms.


## 5.1.1. Dataset Splitting

The dataset used in this study is split so that 80% of the images are used for training the algorithms, while the remaining 20% is used for testing each class.


## 5.1.2. Number of Classes

Classes mean the number of objects that the model should learn and detect after training. In this case, the algorithms are responsible for detecting 4 classes (i.e., normal, abnormal heartbeat, myocardial infarction, and previous history of MI), and each class contains 12 leads; therefore, the number of objects is set to 48.


## 5.1.3. Learning Rate

A default learning rate of 0.0002 has been used to train the algorithms.


## 5.2. Training

Once all hyperparameters are configured, then the training process starts with an average step speed of 0.50 s. Training will take almost 4 days to complete the desired steps. The model will validate itself on the test dataset on each iteration and then display the prediction accuracy and loss. A sufficient number of steps are required for a better prediction of the model. Figure7 shows the average loss (price paid for the wrong detection) of the model.Figure 7
Average loss.


## 5.3. Code Availability

The code used in this study can be found athttps://github.com/alijiskani/ECG_Object_Detection, which contains code configuration files, source code, and a user manual.


## 6. Results

SSD MobileNet V2 was used to detect cardiovascular disease detection. High accuracy results were calculated for cardiac disease detection. The mean average precision against all four classes is evaluated. The study showed high accuracy results to differentiate and detect four cardiac abnormalities. “Myocardial Infarction” and “Previous History of MI” both classes achieved high accuracy among the results of all four classes. Table2 shows the mean average precision (mAP) of all classes.Table 2
Model evaluation.
ClassAccuracyMyocardial infarction (MI)98.33Abnormal heartbeat97.22Previous history of MI98.28Normal96.18Figure8 shows the original label and the predicted output results from the proposed model and their accuracy results.Figure 8
Predicted results.The authors compare the cardiac disorder detection system performance with existing research studies related to ECG cardiac classification works. However, the mentioned work has a different dataset based on time-series data and different types of classes, so it is not justified to directly compare their results. This study achieved remarkable results on the detection of four cardiac abnormalities and achieved high accuracy results. Table3 shows the comparative results related to the study.Table 3
Result comparison.
ClassifierWorkData setPublicly availableAccuracyTotal classesSSD MobileNet V2Proposed12-lead ECG imagesYes (now available)98.334CNNAcharya et al. [24]Time seriesNo94.9021D CNNKiranyaz et al. [25]Time seriesYes94.732NNInan et al. [26]ECG beatsYes95.202Logistic regressionSadhukhan et al. [27]Multilead ECGNo95.602CNNLodhi et al. [28]12-lead ECGYes93.532


### 6.1. Confusion Matrix

The confusion matrix presents true positive, false positive, false negative, and true negative categories in each class (i.e., myocardial infarction, abnormal heartbeat, previous history of MI, and normal class). Table4 displays the confusion matrix of the related study.Table 4
Confusion matrix.
Myocardial infarction (MI)Abnormal heartbeatPrevious history of MINormalMyocardial infarction (MI)96.221.891.890.00Abnormal heartbeat3.7093.591.351.36Previous history of MI0.001.6196.781.61Normal0.002.753.5193.74The class “myocardial infarction” generates the highest average score. The two major aspects of good prediction are low variance and large datasets. The training dataset has an important and effective role while learning high-level attributes, but the variance plays a vital role in emphasizing key features.


## 6.1. Confusion Matrix

The confusion matrix presents true positive, false positive, false negative, and true negative categories in each class (i.e., myocardial infarction, abnormal heartbeat, previous history of MI, and normal class). Table4 displays the confusion matrix of the related study.Table 4
Confusion matrix.
Myocardial infarction (MI)Abnormal heartbeatPrevious history of MINormalMyocardial infarction (MI)96.221.891.890.00Abnormal heartbeat3.7093.591.351.36Previous history of MI0.001.6196.781.61Normal0.002.753.5193.74The class “myocardial infarction” generates the highest average score. The two major aspects of good prediction are low variance and large datasets. The training dataset has an important and effective role while learning high-level attributes, but the variance plays a vital role in emphasizing key features.


## 7. Conclusion

Cardiac disorder detection plays a significant role in medical and health science. The study focuses on processing the ECG images to detect cardiac abnormalities. The deep neural network has proven its capabilities in various applications of image processing and computer vision. This paper critically discusses the related work and analysis, specifically on cardiac disease detection. The study proposes a generalized methodology to process all formats of ECG. Single shoot detection (SSD) MobileNet v2 based Deep Neural Network architecture was used to detect cardiovascular disease detection. The study presented high accuracy results in differentiating and detecting four major cardiac abnormalities and showed remarkable results with an average accuracy of 98%. Several cardiologists manually verified the proposed system’s accuracy result and recommended that the proposed system be used to screen for cardiac disorder. The work is relatively rare based on their dataset using standard 12-lead-based ECG images used by cardiac professors in health care institutes.This work can be extended by training a larger dataset, particularly on more cardiac abnormalities, validating the recognition ratio using DNNs. The extraction of advanced features on ECG images with image acquisition, adaptive image enhancement, and various boundary detection algorithms on various cardiac-related issues can be detected with medical experts’ help with new developing tools. The way of learning domain adaptation is another big task for researchers to do in the future.


## 8. Practical Implication

This study achieved high accuracy results in detecting cardiac abnormalities, and several cardiologists manually verified the accuracy result of the proposed system. Moreover, this model can be implemented in the “mobile cardiac unit” as a beta version where no or fewer cardiac facilities are available.



---

*Source: 5512243-2021-03-23.xml*