0% found this document useful (0 votes)
5 views

detection-of-cardiovascular

This study presents a novel lightweight convolutional neural network (CNN) architecture for the prediction of cardiovascular diseases using ECG images, achieving an accuracy of 98.23%. The proposed model outperforms existing methods, including SqueezeNet and AlexNet, and demonstrates significant improvements in classification accuracy when used as a feature extractor for traditional machine learning algorithms. The research highlights the potential of integrating advanced AI techniques in healthcare for early disease detection and improved diagnostic accuracy.

Uploaded by

hari183320
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

detection-of-cardiovascular

This study presents a novel lightweight convolutional neural network (CNN) architecture for the prediction of cardiovascular diseases using ECG images, achieving an accuracy of 98.23%. The proposed model outperforms existing methods, including SqueezeNet and AlexNet, and demonstrates significant improvements in classification accuracy when used as a feature extractor for traditional machine learning algorithms. The research highlights the potential of integrating advanced AI techniques in healthcare for early disease detection and improved diagnostic accuracy.

Uploaded by

hari183320
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

IEEE TRANSACTIONS ON ARTIFICIAL INTELLIGENCE, VOL. 4, NO.

2, APRIL 2023 373

Detection of Cardiovascular Diseases in ECG Images


Using Machine Learning and Deep Learning
Methods
Mohammed B. Abubaker and Bilal Babayig˘ it

Abstract—Cardiovascular diseases (heart diseases) are the lead-


ing cause of death worldwide. The earlier they can be predicted I. INTRODUCTION

A
and classified; the more lives can be saved. Electrocardiogram CCORDING to the World Health Organization, cardio-
(ECG) is a common, inexpensive, and noninvasive tool for
measuring the electrical activity of the heart and is used to detect vascular diseases (heart diseases) are the leading cause of
cardiovascular disease. In this article, the power of deep learning death worldwide. They claim an estimated 17.9 million lives
techniques was used to predict the four major cardiac each year, accounting for 32% of all deaths worldwide. About
abnormalities: abnormal heartbeat, myocardial infarction, history 85% of all deaths from heart disease are due to heart attacks,
of myocardial infarction, and normal person classes using the also known as myocardial infarctions (MI) [1]. Many lives
public ECG images dataset of cardiac patients. First, the transfer
learning approach was in- vestigated using the low-scale can be saved if an efficient diagnosis of cardiovascular
pretrained deep neural networks SqueezeNet and AlexNet. disease is detected at an earlier stage [1]. Different techniques
Second, a new convolutional neural net- work (CNN) are used in the healthcare system to detect heart diseases, such
architecture was proposed for cardiac abnormality prediction. as electro- cardiogram (ECG), echocardiography (echo),
Third, the aforementioned pretrained models and our proposed cardiac magnetic resonance imaging, computed tomography,
CNN model were used as feature extraction tools for traditional
machine learning algorithms, namely support vector machine, blood tests, etc. [2], [3]. The ECG is a common, inexpensive,
K-nearest neighbors, decision tree, random forest, and Naïve and noninvasive tool for measuring the electrical activity of
Bayes. According to the experimental results, the perfor- mance the heart [4]. It is used to identify heart-related cardiovascular
metrics of the proposed CNN model outperform the exiting diseases [4], [5]. A highly skilled clinician can detect heart
works; it achieves 98.23% accuracy, 98.22% recall, 98.31% pre- disease from the ECG waves.
cision, and 98.21% F1 score. Moreover, when the proposed CNN
model is used for feature extraction, it achieves the best score of
However, this manual process can lead to inaccurate results
99.79% using the NB algorithm. and is very time-consuming [5].
Impact Statement—Artificial intelligence plays an important There is great potential to benefit from advances in
role in improving the quality of life. In particular, early artificial intelligence in healthcare to reduce medical errors. In
detection of diseases can help save lives. In this work, the particular, the use of machine learning and deep learning
proposed new lightweight CNN architecture has improved the
accuracy rate of cardiovascular disease classification to 98.23%
techniques for automatic prediction of heart diseases [3], [6]–
compared with the existing state-of-the-art methods, using the [10]. The machine learning methods require an expert entity for
dataset of ECG images of cardiac patients, and can be performed features extraction and selection to identify the appropriate
on a single CPU, overcoming the limitation of computational features before apply- ing the classification phase. Feature
power. In addition, the classification accuracy has significantly extraction is a process of reducing the number of features in a
improved after applying the proposed method as a feature
extraction tool for traditional machine learning algorithms. For
data set by transforming or projecting the data into a new
example, an accuracy of 99.79% has been achieved using the lower-dimensional feature space preserving the relevant
Naïve Bayes algorithm. Thus, this method could be integrated information of the input data [11], [12].
into the IoT ecosystem in healthcare. This will encourage other The concept of feature extraction is concerned with creating
AI researchers to explore other methods for cardiovascular a new set of features (different from the input feature) that
disease detection.
area combination of original features into a lower-
Index Terms—Cardiovascular, deep learning, electrocar dimensional space that extract most, if not all, of the
diogram (ECG) images, feature extraction, machine learning,
transfer learning. information in input data. The most well-known feature
extraction method is a principal component analysis [13],
[14]. However, feature selection is a process of removing
irrelevant and redundant features (di- mensions) from the data
set in the training process of machine learning algorithms.
Manuscript received 2 March 2022; accepted 11 March 2022. Date of pub- Various methods can be used for feature selection, classified
lication 15 March 2022; date of current version 24 March 2023. This article as unsupervised, which refers to the method that does not need
was recommended for publication by Associate Editor Mihail Popescu upon
evaluation of the reviewers’ comments. (Corresponding author: Mohammed
the output label for feature selection, and supervised, which
B. Abubaker) refers to the methods that use output label for feature selection.
Mohammed B. Abubaker is with the Department of Computer Engineering, Under supervised feature selection, there are three methods:
Erciyes University, 38039 Melikgazi, Turkey, and also with the Palestine
Tech- nical College, Gaza P920, Palestine (e-mail:
the filter method, the wrapper method, and the embedded
[email protected]). method [11], [12].
Bilal Babayig˘it is with the Department of Computer Engineering, Erciyes Many machine learning methods have been used for
University, 38039 Melikgazi, Turkey (e-mail: [email protected]).
Digital Object Identifier 10.1109/TAI.2022.3159505
predict- ing cardiovascular diseases. Soni et al. [15] compared
several
2691-4581 © 2022 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission.
See https://www.ieee.org/publications/rights/index.html for more information.
2 IEEE TRANSACTIONS ON ARTIFICIAL INTELLIGENCE, VOL. 4, NO. 2, APRIL 2023

disease classification. In addition, a new CNN model is proposed


for heart disease prediction using ECG images and used for
feature extraction of the ECG images after training the new
proposed CNN model.
The main contributions of this study are summarized as fol-
lows.
1) A new lightweight deep learning CNN architecture is
Fig. 1. Abstract concept of machine learning and deep learning. proposed for cardiovascular diseases prediction using 12
lead-based ECG images.
2) The proposed CNN model achieves a success rate of
machine learning algorithms, such as decision tree (DT), 98.23%, outperforming the existing work [22] and the
Naïve Bayes (NB), K-nearest neighbors (K-NN), and neural state-of-the-art low-scale SqueezeNet and AlexNet, which
network (NN) on UCI Cleveland heart disease dataset. They achieved 95.10%, 95.47%, and 96.79%, respectively.
concluded that DT had the highest accuracy of 89%. 3) To the best of our knowledge, this is the second study
Dissanayake and Md Johar [16] studied the effect of the using the ECG images dataset of cardiac patients [23],
feature selection process on machine learning classifiers for which will encourage other researchers to explore other
predicting heart diseases from the UCI Cleveland heart methods to detect cardiovascular diseases using this
disease dataset. They examined differ- ent feature selection dataset.
techniques, such as ANOVA, Chi-square, forward and 4) The transfer learning approach using SqueezeNet and
backward feature selection, and Lasso regression. After that, Alex-Net was investigated and compared with the pro-
they applied six machine learning classifiers, which are DT, posed model.
random forest (RF), support vector machine (SVM), K-NN, 5) The pretrained networks SqueezeNet, AlexNet and our
logistic regression (LR), and Gaussian NB (GNB). With the proposed CNN model were used as feature extractors to
feature selection process, the prediction accuracy was im- apply the extracted features to the conventional machine
proved such that using the backward feature selection method, learning methods: SVM, K-NN, DT, RF, and NB. The best
the highest classification accuracy of 88.52% has been results were achieved by our proposed CNN model for
achieved with the DT classifier. The use of machine learning the NB algorithm in which the accuracy rate was
algorithms, such as NB, SVM, and DT algorithms, was reported as 99.79%.
studied in [17] using ten-fold cross-validation, on the South The rest of this article is organized as follows. Section II
African heart dis- ease dataset with 462 instances. The best presents the literature review. The methods and the proposed
results were obtained from NB for detecting heart disease CNN model used in this article are explained in Section III.
with an accuracy rate of 71.6%, sensitivity of 63%, and Section IV illustrates the dataset and experimental settings
specificity of 76.16%. Kim et al. [18] compared NN, SVM, used. Section V provides the results and discussions, whereas
classification based on multiple association rule (CMAR), Sec- tion VI concludes this article and provides future
DT, and NB algorithms to predict cardiovascular diseases on perspectives.
two types of datasets consisting of ultrasound images of
carotid arteries (CAs) and heart rate variability (HRV) of the II. LITERATURE REVIEW
ECG signal. The combined extracted features from the CAs+
Many research works [24]–[27] have been conducted for
HRV dataset obtained higher accuracy than the separated
automatically predicting cardiovascular diseases using machine
features of CAs and HRV. Thus, SVM and CMAR classifiers
learning and deep learning methods by utilizing ECG as
outperformed the others by the accuracy of 89.51% and
digitals or images data representation.
89.46%, respectively.
Bharti et al. [28] compared machine learning and deep
On the other hand, deep learning, which is a subfield of
learn- ing methods on the UCI heart disease dataset to predict
machine learning, automatically extracts important features and
two classes. The deep learning method achieved the highest
patterns from the training datasets for the classification phase
accuracy rate of 94.2%. In their architecture of deep learning
without the intervention of separate entities for features ex-
model, they used three fully connected layers: the first layer
traction and selection. Fig. 1 illustrates the abstract concept
consists of 128 neurons followed by a dropout layer with 0.2
of machine learning and deep learning. In deep learning, a
rate, the second layer consists of 64 neurons followed by a
model is created by constructing multiple hidden layers of
dropout layer with
NNs. Convolutional neural network (CNN) is a deep learning
0.1 rate, and the third layer consists of 32 neurons. The
method, which has achieved satisfactory results on image
machine learning methods with features selection and
classification tasks.
outliers’ detection achieved accuracy rates as: RF is 80.3%,
The power of deep learning and pretrained networks can
LR is 83.31%, K-NN is 84.86%, SVM is 83.29%, DT is
be used for feature extraction without having to retrain the
82.33%, and XGBoost is 71.4%. The research in [29]
whole network, transfer learning, and classification [19]. In
concluded that deep learning has proven to be a more accurate
this article, the pretrained networks, i.e., SqueezeNet [20] and
and effective technology for a variety of medical problems
AlexNet [21], are used as a transfer learning approach to
such as prediction. Deep learning methods will replace the
study their performance in heart disease classification and as
traditional machine learning based on feature engineering.
feature extraction for traditional machine learning methods
Kiranyaz et al. [30] proposed a CNN that consisted of three
for heart
layers of an adaptive implementation of
ABUBAKER AND BABAYIG˘ IT: DETECTION OF CARDIOVASCULAR DISEASES IN ECG IMAGES USING MACHINE LEARNING 375

one-dimensional (1-D) convolution layers. This network was


trained on the MIT-BIH arrhythmia dataset to classify long ECG
data stream. They achieved accuracy rates of 99% and 97.6%
in classifying ventricular ectopic beats and supraventricular
ec- topic beats, respectively. Also, the work in [31] proposed a
CNN that consisted of three 1-D convolution layers, three max-
pooling layers, one fully connected layer, and one softmax
layer. The filter size for the first and second convolutional
layers was set to 5 and a stride of 2 was used for the first two
Fig. 2. Example of a convolution operation.
max-pooling layers. They achieved an accuracy rate of 92.7%
in classifying ECG heartbeats using the MIT-BIH arrhythmia
dataset.
Khan et al. [22] applied transfer learning approach using connected layers for classification, but instead used an
the pretrained single shot detector (SSD)-MobileNet-v2 [32] average pooling layer followed by a softmax layer. This model
to detect cardiovascular diseases from the ECG images achieved an accuracy rate of 98.33%.
dataset of cardiac patients by predicting the four major heart Acharya et al. [38] implemented a deep CNN with four
abnormalities: abnormal heartbeat (AH), MI, history of MI (H. 1-D convolutional layers and three fully connected layers for
MI), and normal person (NP) classes. As preprocessing steps, detecting MI using ECG signals in the PTB dataset. In this
the data size was adjusted and the 12 leads of each ECG image model, the leaky rectifier linear unit (LeakyRelu) was used as the
were labeled. SSD is used to classify and localize the objects in activation function layer. Each convolutional layer was followed
one step. The dataset was split 80% for training and 20% for by a max-pooling layer with a filter size of 2 and a stride of 2.
testing. They used a batch size of 24, 200K training iterations The filter sizes for convolutional layers were 102, 24, 11, and
for the training step, and a learning rate of 0.0002 to train their 9 in order. The numbers of neurons for fully connected layers
model. Their training phase lasted almost 4 days. They were 30, 10, and 2 in that order. The last fully connected layer
achieved a high precision rate for the MI class, i.e., 98.3%. was followed by a softmax layer. They achieved an average
Rahman et al. [33] provided a deep CNN transfer learn- accuracy rate of 93.53% and 95.22% for ECG beats with and
ing approach to predict COVID-19 and four major car- without noise removal, respectively.
diac abnormalities using ECG images. The dataset contained Naz et al. [39] converted ECG signals into 32 × 32 binary
five classes: COVID-19, AH, MI, H. MI, and NP classes. images. Their model was tested with the MIT-BIH dataset
Six different pretrained deep CNN models, i.e., ResNet18, using the pretrained CNN models AlexNet, VGG19, and
ResNet50, ResNet101, DenseNet201 [34], Inception-V3 [35], Inception-V3 to detect ventricular arrhythmias of the heart.
and MobileNet-v2, were used for classification. Gamma cor- Transfer learn- ing was performed to extract and concatenate
rection, image resizing, and z-score normalization were used features from the pretrained models. SVM and K-NN
as preprocessing steps for the ECG images. As a result, for classification methods were then used for binary
two-class classification (COVID-19 and normal) and three-class classification. Using the SVM, they achieved an accuracy of
classification (COVID-19, normal, and other cardiac abnormali- 97.60%.
ties), DenseNet201 outperformed the other networks with accu-
racy rates of 99.1% and 97.36%, respectively. For the five-
III. METHODS
class classification, Inception-V3 outperformed the other
networks with an accuracy rate of 97.83%. A. Convolutional Neural Networks (CNN)
Pal et al. [36] presented a deep CNN transfer learning strategy
In deep learning, a CNN is a type of deep artificial NN
using pretrained DenseNet arrhythmia classifications (AH) from
specifically designed for image classification and processing
ECG signals in PTB and MIT-BIH arrhythmia datasets con-
[40]. The neurons in CNNs are arranged in three dimensions:
verted to 2-D images. Since the dataset was imbalanced, a
height, width, and depth (channel). For example, an input
data augmentation technique was applied to the data. The
image is 227 × 227 × 3, which means that the width and
DenseNet model was chosen because it provides a solution to
height of the input image are 227 and the depth (channel) is 3.
the vanishing gradient problem in deep networks by using
The main task of CNNs is to extract important features from
dense connections between layers. Their model was referred
the input images. The two main components of CNNs are
to as CardioNet. The precision, recall, and F1 score values were
convolutional layers and pooling layers. The higher layers in
98.62%, 98.68%, and 98.65%, respectively.
CNNs can be fully connected layers and the last layer is a
Avanzato and Beritelli [37] proposed a deep CNN with four
sigmoid or softmax activation func- tion layer to get the
1-D convolutional layers for detecting three classes of cardiac
predicted output. The convolution process is performed with
abnormalities using ECG signals in the MIT-BIH arrhythmia
convolutional layers on the input data using a filter or kernel
dataset. Each convolutional layer was followed by a batch
to create a feature map representing the detected features of
nor- malization layer, a rectifier linear unit (ReLU) layer
the input. Convolution is performed by sliding the filter over
activation function, and a max-pooling layer with a filter
the input. At each position, matrix multiplication is performed
(kernel) size of 4. A size 80 filter was used for the first
and the result is summed onto the feature map. Fig. 2 shows a
convolutional layer, and the others had a filter size of 4. This
simple example of a convolution process for an input with a
architecture did not use fully
depth of 1.
376 IEEE TRANSACTIONS ON ARTIFICIAL INTELLIGENCE, VOL. 4, NO. 2, APRIL 2023

Fig. 3. Example of 2 × 2 max-pooling with stride = 2.

The convolution process is linear. To add nonlinearity to


the output, the convolution layer is followed by an activation
function layer such as ReLU or its variants. After the convolution
layer, a pooling layer such as max-pooling layer could be used to
downsample the feature map to reduce the computational cost.
Fig. 3 shows a simple example of max-pooling for an input
with depth of 1.

B. Pretrained Deep Learning Models


The pretrained deep NNs can be used for transfer learning,
feature extraction, and classification. In this article, low-
scaled SqueezeNet and AlexNet pretrained CNN networks
that can be executed on a single CPU are used for transfer
learning and feature extraction.
The transfer learning approach is commonly used with pre-
trained deep NNs applied to a new dataset. Therefore, it could
benefit from the pretrained network that has already learned a
variety of features that can be transferred to other similar
tasks. Most of the pretrained networks have been trained with
more than a million images and can classify images into 1000
object classes. In applying the transfer learning approach, the
final layers of the pretrained network are replaced with new
layers to learn the specific features of the new dataset. Then,
the model is fine-tuned by training it on a new training dataset
with specific training parameters and testing its performance
measure on a new test dataset.
The pretrained deep NNs can be used as a feature extraction
tool without wasting time and effort on training. In this
article, the extracted features from the pretrained networks are
used to train traditional machine learning classifiers, namely
SVM [41], K-NN [42], DT [43], RF [44], and NB [45]. The
details of using the pretrained networks are explained in the
next Sections.
Fig. 4. Representation architecture of the proposed CNN model.
C. Proposed CNN Architecture
The proposed CNN model contains besides the input and
output layers, six 2-D convolutional layers, three fully the max-pooling layer. In the leakyReLU layer, a leakyReLU
connected layers, three max-pooling layers, eight leaky ReLU activation function with a scale of 0.1 is used. Unlike ReLU,
layers, eight batch normalization layers, five dropout layers, leakyReLU has a slight slope in the negative range, which can
two depth con- catenation layers, and one softmax layer. In eliminate the problem of dying neurons [46]. The batch
total, there are 38 layers. The architecture of the proposed normal- ization layer is used to normalize its inputs for each
model is shown in Fig. 4. The proposed CNN model consists minibatch, which can train the model faster and increase
of two branches that help extract more representative features, the accuracy of the model. The max-pooling layer applies the
namely the stack branch and the full branch. The proposed max-pooling operation to the feature map by selecting the
CNN model accepts input image of size 227×227×3. The maximum element from the region covered by the filter. This
input image flows into the two helps to reduce the spatial size of the feature map to reduce the
branches simultaneously. number of parameters and computational cost in the model. The
The stack branch consists of three stacked 2-D 3×3 proposed CNN model uses max-pooling layers of 6×6 filter
convolu- tional layers. Each of these 2-D convolutional layers size with a stride of 3. In this branch, 64, 128, and 224 filters
is followed by the leakyReLU layer, the batch normalization are used to extract deep
layer, and
ABUBAKER AND BABAYIG˘ IT: DETECTION OF CARDIOVASCULAR DISEASES IN ECG IMAGES USING MACHINE LEARNING 377

TABLE I
LAYERS ANALYSIS OF THE PROPOSED CNN MODEL

leakyReLU: scale=0.1, batch normalization: MeanDecay=0.1, VarianceDecay=0.1, Epsilon=0.00001, total number of learnable parameters=3430308

features of the data for the first, second and third


convolutional layers, respectively. The size of the output at the
end of the stack branch is 2 × 2 × 224.
The first layer in the full branch of our proposed CNN
model is a fully connected layer, hence its name. In our
model, the fully connected layer contains 16 neurons. Each
neuron in a fully connected layer is connected to each neuron in
the previous layer. This is in contrast to a neuron in a
convolutional layer, which is connected to some neurons in
the previous layer defined by the size of the convolutional
filter. Although most of the parameters in the CNN come from
the fully connected layers, the number of calculations in the
convolutional layer requires much more memory. The fully
connected layer is followed by a leakyReLU layer, a batch
normalization layer, and a dropout layer, which helps to
Fig. 5. Schematic of using the proposed CNN model for ECG images of
reduce overfitting and emphasize the generalization capability cardiac patients’ classification.
of the model. As can be seen in Fig. 4, the two convolutional
layers, named conv04 and conv05, are located at the same
level after the block of the fully connected layer to help nonlinearity of the model and reduce the depth or number of
extract broader features. feature maps to reduce computational cost. A fully connected
Conv04 is a 32 2 × 2 convolutional layer witha stride of 1 and layer with 512 neurons is added to strengthen the
a padding of 1, whereas conv05 isa 64 3×3 convolutional classification process. For the output, a fully connected layer
layer with a stride of 2 and a padding of 2. The feature maps with four neurons corresponding to the number of classes to be
of these two convolutional layers are concatenated to produce classified, followed by a softmax layer to obtain the predicted
a feature map of 2 × 2 × 96. After concatenating the output. The analysis of the trained network for the proposed
features, a dropout layer is applied to reduce the impact of CNN model is given in Table I.
correlated features and avoid overfitting. The schematic of using the proposed CNN model for the
The two outputs generated by the two branches are concate- classification of ECG images of cardiac patients is shown in
nated to create a feature map of 2×2×320. Then, a dropout Fig. 5. First, the input images are preprocessed by cropping,
layer is added to reduce the overfitting of the model. A 1×1 resizing, and augmenting them. Then, the preprocessed
convolutional layer with 256 filters is added to increase the images are stored in the image datastore. The proposed model
is trained
378 IEEE TRANSACTIONS ON ARTIFICIAL INTELLIGENCE, VOL. 4, NO. 2, APRIL 2023

TABLE II
PUBLIC ECG IMAGES DATASET DESCRIPTION

Fig. 7. Sample from the ECG images dataset after performing cropping as a
preprocessing.

TABLE III
TRAINING PARAMETERS AND VALUES FOR DEEP LEARNING METHODS

a 4 GB NVIDIA GeForce 820M GPU1 and running Windows


10 Pro 64-b.
Preprocessing. As can be seen in Fig. 6, the ECG images in
the dataset contain header and footer information that have no
relation to the features we need. Therefore, we have applied
cropping for all images to focus on the valuable features as
Fig. 6. Samples from the ECG images dataset. (a) NP. (b) AH. (c) MI. (d) H.
MI.
shown in Fig. 7. In addition, all ECG images were resized to
the same resolution of 227×227 with 3 channels (RGB)
before performing model training.
with the above-mentioned training parameters using the ECG Data augmentation. To increase the robustness and
images stored in the image datastore. The model learns the accuracy of the developed model, data augmentation was
features and adjusts its learnable parameters accordingly. applied to the dataset [47]. It helps to increase the number of
After training, the model is ready to test ECG images for images in the dataset and eliminate the effects of training the
classifying cardiac abnormalities as one of the four classes: model on an imbalanced dataset. Three augmentation
NP, AH, MI, and H. MI. techniques (rotation, flipping, and translation) were applied to
the given dataset [48]. This increased the number of images in
the dataset to 4700 images.
IV. EXPERIMENTS Deep learning training parameters. Since the optimization
A. ECG Images Dataset of Cardiac Patients of hyperparameters is very computationally intensive, all
experi- ments were performed using the training parameters
The mentioned methods were tested on the ECG Images listed in Table III. Adam optimizer is applied to train the
dataset of cardiac patients [23]. This dataset contains 928 model for 16 epochs with a minibatch size of 128. However,
differ- ent patient records with 4 different classes as shown in since the initial learning rate value (LR) is the most important
Table II. These four classes are NP, AH, MI, and H. MI. Fig. hyperparameter, different values for LR were used in the
6 depicts some samples from the dataset. An NP is a healthy experiments, which are mentioned in the next section.
person who does not have any heart abnormalities. An AH According to these parameters, the number of iterations per
(arrhythmia) occurs when the electrical impulses in the heart epoch is 29 and the number of iterations for training the
become too fast, too slow, or irregular so that the heart beats model is 464.
irregularly. MI, also known as heart attack, occurs when To obtain reliable results when testing and evaluating the
blood flow in the coronary artery of the heart decreases or model, fivefold cross-validation was performed. In this process,
stops, causing damage to the heart muscle. The patients with the dataset is divided into five parts, with four parts used for
an H. MI have recently recovered from MI or heart attack. the training phase and the remaining part used for the testing
phase (3760 images for training and 940 images for testing).
B. Experimental Settings Thus, five different distinctions between training and testing
were applied. The results are the average of the five folds.
The experiments were conducted with MATLAB 2021b on
Intel coreTM i7-4510U CPU @ 2.00 GHz with 8GB RAM and 1
Its compute capability is 2.1 and it is not supported by MATLAB 2021b.
Hence, all experiments were run on a single CPU.
ABUBAKER AND BABAYIG˘ IT: DETECTION OF CARDIOVASCULAR DISEASES IN ECG IMAGES USING MACHINE LEARNING 379

TABLE IV
PERFORMANCE MEASURES TABLE VI
CALCULATED PERFORMANCE MEASUREMENTS FOR SQUEEZE-NET, ALEXNET,
AND THE PROPOSED CNN MODEL FOR DIFFERENT RL VALUES

TABLE V
NETWORKS PROPERTIES2

LR: initial learning rate, A.: accuracy, R.: recall, P.: precision, F1: F1 score, T1: training
time, T2: testing time.
The bold values indicate the best results.
For all networks, input image size is 227×227×3.
TABLE VII
PERFORMANCE MEASUREMENTS VALUES OBTAINED FOR EACH FOLD OF THE
PROPOSED MODEL

Fig. 8. Semantic of the confusion matrices for four classes results.

V. RESULTS AND DISCUSSIONS


For performance analysis, accuracy, precision, recall, F1
score, and training and testing times were used. These mea-
surements are based on the analysis of the data in a confusion
matrix. Table V shows how the measurements are defined
based on the confusion matrix. Where the accuracy is the
percentage of positively predicted observations relative to the
total number of observations. Recall represents the ratio of
positively predicted observations to all observations in the
true class (should be positively estimated). Precision expresses
the ratio of positively predicted observations to all
observations in the predicted class (should be positively
predicted). The F1 score is the weighted average of both The bold values indicate the average of the five folds.
Recall and Precision. Thus, it takes into account both the false
negatives and the false positives values.
Fig. 8 shows the semantics of the confusion matrix for 4 number of neurons as the number of our predicted classes, i.e., 4.
classes datasets as in our case, the ECG images dataset of cardiac However, since SqueezeNet does not use fully connected
patients. The performance measurements of the experiments layers, we replace the last convolutional layer which is used to
are calculated based on the equations given in Table IV. identify 1000 classes with a new convolutional layer
containing 4 1×1 filters. For both pretrained networks used, a
A. Results of Transfer Learning and Proposed CNN Model new classification layer is added in place of the existing one,
The state-of-the-art architectures of the pretrained networks which produces an output based on the probabilities computed
SqueezeNet and AlexNet were used to apply the transfer learning by the softmax layer. The properties of the pretrained networks
approach in our study. Both were originally trained for the used and our proposed CNN are shown in Table V.
classification of 1000 image classes. To retrain these networks Table VI shows the performance measures of the pretrained
for classifying the new set of ECG images in the dataset, we models (SqueezeNet and AlexNet) used as the transfer
replace the last layers of these models to make them suitable learning approach and our proposed CNN model for the ECG
for the new task. In AlextNet, the last fully connected layer is images dataset. Each model was trained with different values
replaced with a new fully connected layer containing the same for learn- ing rate LR (0.01, 0.001, and 0.0001). As noticed,
the most successful result with an average accuracy rate of
2
98.23% was obtained by our proposed CNN model when the
Here, the total number of layers in the network was counted, not even the
convolutional layers and dense layers.
RL was 0.0001. Table VII shows the detailed analysis of the
proposed model. The
380 IEEE TRANSACTIONS ON ARTIFICIAL INTELLIGENCE, VOL. 4, NO. 2, APRIL 2023

Fig. 9. Training Progress for our proposed CNN model on the ECG images
dataset in fold-1 (LR: 0.0001 and other hyperparameters are as in Table III).

TABLE VIII
MODELS COMPARISON

NP: normal person, AH: abnormal heartbeat, MI: myocardial infarction, H. MI:
history of myocardial Infarction classes.

average accuracy rate for the proposed CNN model shows


simi- lar high results when the RL values are changed. In
contrast, the pretrained SqueezeNet and AlexNet models show
poor results when the initial learning rate were 0.01 and
0.001, but they start to show slightly good results when the Fig. 10. Confusion matrices of the proposed CNN model for classification of
LR is set to 0.0001. This is because, in transfer learning, the heart diseases in the ECG images dataset for each fold (RL: 0.0001 and other
hyper-parameters are as in Table III).
weights of the pretrained models are not learned from scratch.
Therefore, to avoid getting stuck in local minima, it is better to
TABLE IX
start with a lower LR such as 0.0001 when applying transfer PROPERTIES OF THE EXTRACTED FEATURES FROM PRETRAINED NETWORKS
learning techniques.
The average accuracy rates are 96.79% and 95.43% for
AlexNet and SqueezeNet, respectively with RL of 0.0001. On
the other hand, the proposed CNN model also outperforms the
other models in terms of time cost, as can be seen in Table VI.
Although SqueezeNet has the smallest number of parameters
and is a fully CNN, it achieves the worst performance in terms
of time cost. This is because the number of computations in
the
convolutional layers is very high, so it takes more time to be
respectively. They used a batch size of 24 and a learning rate
processed, especially when running on a single CPU platform.
of 0.0002 to train their model. Their training phase lasted
Fig. 9 depicts the training progress of our proposed CNN
model on the ECG images dataset in fold-1 (LR = 0.0001). The almost 4 days. According to their paper, they achieved a high
accuracy rate increases gradually with each successive iteration. precision rate for class MI, which is 98.3%, whereas our
Moreover, the loss decreases smoothly as the iteration progresses proposed CNN model outperforms them with a precision rate
and reaches 0.0043. of 99.4% for class MI. Table VIII compares the results from
The confusion matrices which were obtained for each fold [22], in which the accuracy rates of each class were extracted
after training our proposed CNN models with an RL value of from their confusion matrix, with our proposed CNN model.
0.0001 on the ECG images dataset are shown in Fig. 10.
To the best of our knowledge, the only work in the B. Results of Using Pretrained Deep Learning Models As
literature that uses the same dataset and classifies the four a Feature Extractor
classes is the work in [22], which has been discussed in The pretrained SqueezeNet and AlexNet networks were
Section II. In [22], the dataset was split as 80% and 20% for used to extract the features of the ECG images in the dataset.
training and testing, As well
ABUBAKER AND BABAYIG˘ IT: DETECTION OF CARDIOVASCULAR DISEASES IN ECG IMAGES USING MACHINE LEARNING 381

TABLE X
CALCULATED PERFORMANCE MEASUREMENTS FOR MACHINE LEARNING ALGORITHMS THAT USE PRETRAINED NETWORKS SQUEEZENET, ALEXNET, AND
PROPOSED CNN AS FEATURES EXTRACTOR APPLIED ON ECG IMAGES DATASET

The bold values indicate the best results.

as, our proposed CNN model was used as a feature extractor


VI. CONCLUSION
and the results were compared. The power of deep learning
can be used to extract image features without re-training the In this article, we propose a lightweight CNN-based model
entire network. The activations of the network are computed to classify the four major cardiac abnormalities, i.e., AH, MI,
by forward propagation of the input images up to the specific H. MI, and NP classes, using public ECG images dataset of
feature layer. The activation feature layers used are conv10 (layer cardiac patients. According to the results of the experiments,
number 64), fc7 (layer number 20) and fc02 (layer number the proposed CNN model achieves remarkable results in
32) for SqueezeNet, AlexNet and our proposed CNN model, cardio- vascular disease classification and can also be used as
respectively. Table IX illustrates the characteristics of the ex- a feature extraction tool for the traditional machine learning
tracted features. Then, these extracted features were used to classifiers. Thus, the proposed CNN model can be used as an
train the machine learning algorithms: SVM, k-NN, DT, RF, assistance tool for clinicians in the medical field to detect
and NB. cardiac diseases from ECG images and bypass the manual
The performance measures are calculated and presented in process that leads to inaccurate and time-consuming results.
Table X. As can be seen, the most successful result was obtained In the future work, optimization techniques can be used to
with a rate of 99.79% for the accuracy, recall, precision, and obtain optimized values for the hyperparameters of the proposed
F1-score of the NB algorithm when our proposed CNN model CNN model. The proposed model can also be used for predicting
was used as the feature extractor. The accuracy rates of other types of problems. Since, the proposed model belongs to
99.47%, 97.87%, and 97.66% were obtained by the SVM the family of low-scale deep learning methods in terms of the
algorithm when our proposed CNN model, SqueezeNet, and number of layers, parameters, and depth. Therefore, a study
AlextNet, respectively, were used to extract the features. As a on using the proposed model in the Industrial Internet of
result, the best achievements for all performance measures Things domain for classification purposes can be explored.
were obtained when using our proposed CNN model as the
feature extractor. When comparing SqueezeNet and AlexNet, REFERENCES
we almost achieved better accuracy rates for SVM, RF and [1] World Health Organization (WHO), “Cardiovascular diseases,” Jun. 11,
NB algorithms using the features extracted from SqueezeNet 2021. Accessed: Dec. 27, 2021. [Online]. Available: https://www.who.
than those from AlexNet. However, the training and testing int/health-topics/cardiovascular-diseases
[2] Government of Westren Australia, Department of Health, “Com-
times for SqueezeNet-based algorithms were longer due to the mon medical tests to diagnose heart conditions,” Accessed: Dec. 29,
larger size of the extracted features. Although the extracted 2021. [Online]. Available: https://www.healthywa.wa.gov.au/Articles/A_
feature size of our proposed CNN model is the smallest, it E/Common-medical-tests-to-diagnose-heart-conditions
[3] M. Swathy and K. Saruladha, “A comparative study of classification and
achieved the best results on all performance measures, as prediction of cardio-vascular diseases (CVD) using machine learning
shown in Table X. Therefore, this is an indication that our and deep learning techniques,” ICT Exp., to be published, 2021.
proposed model is built to learn the key features of the ECG [Online].
Available: https://doi.org/10.1016/j.icte.2021.08.021
images dataset. Thus, the advantages of the proposed model [4] R. R. Lopes et al., “Improving electrocardiogram-based detection of rare
are not only the better accuracy rates but also the lower genetic heart disease using transfer learning: An application to phos-
computational costs compared to the works in the literature. pholamban p.Arg14del mutation carriers,” Comput. Biol. Med., vol. 131,
2021, Art. no. 104262. [Online]. Available: https://doi.org/10.1016/j.
However, the proposed model could achieve better results if compbiomed.2021.104262
optimization algorithms are used to determine the values of its [5] R. J. Martis, U. R. Acharya, and H. Adeli, “Current methods in electro-
hyperparameters. cardiogram characterization,” Comput. Biol. Med., vol. 48, pp. 133–149,
2014. [Online]. Available: https://doi.org/10.1016/j.compbiomed.2014.
02.012
382 IEEE TRANSACTIONS ON ARTIFICIAL INTELLIGENCE, VOL. 4, NO. 2, APRIL 2023

[6] A. Rath, D. Mishra, G. Panda, and S. C. Satapathy, “Heart disease


detection using deep learning methods from imbalanced ECG samples,” [28] R. Bharti, A. Khamparia, M. Shabaz, G. Dhiman, S. Pande, and P.
Biomed. Signal Process. Control, vol. 68, 2021, Art. no. 102820. Singh, “Prediction of heart disease using a combination of machine
[Online]. Avail- able: https://doi.org/10.1016/j.bspc.2021.102820 learning and deep learning,” Comput. Intell. Neurosci., vol. 2021, 2021,
[7] A. Mincholé and B. Rodriguez, “Artificial intelligence for the electro- Art. no. 8387680. [Online]. Available: https://doi.org/10.1155/2021/
cardiogram,” Nature Med., vol. 25, no. 1, pp. 22–23, 2019. [Online]. 8387680
Available: https://doi.org/10.1038/s41591-018-0306-1 [29] P. Bizopoulos and D. Koutsouris, “Deep learning in cardiology,” IEEE
[8] A. Isin and S. Ozdalili, “Cardiac arrhythmia detection using deep Rev. Biomed. Eng., vol. 12, pp. 168–193, 2018. [Online]. Available:
learning,” Procedia Comput. Sci., vol. 120, pp. 268–275, 2017. https:
[Online]. Available: https://doi.org/10.1016/j.procs.2017.11.238 //doi.org/10.1109/RBME.2018.2885714
[9] H. Bleijendaal et al., “Computer versus cardiologist: Is a machine learn- [30] S. Kiranyaz, T. Ince, and M. Gabbouj, “Real-time patient-specific ECG
ing algorithm able to outperform an expert in diagnosing phospholam- classification by 1-D convolutional neural networks,” IEEE Trans.
ban (PLN) p.Arg14del mutation on ECG?,” Heart Rhythm, vol. 18, Biomed. Eng., vol. 63, no. 3, pp. 664–675, Mar. 2016. [Online].
no. 1, pp. 79–87, 2020. [Online]. Available: https://doi.org/10.1016/j. Available: https:
//doi.org/10.1109/TBME.2015.2468589
hrthm.2020.08.021
[10] U. R. Acharya, H. Fujita, O. S. Lih, M. Adam, J. H. Tan, and C. K. [31] M. Zubair, J. Kim, and C. Yoon, “An automated ECG beat classification
Chua, “Automated detection of coronary artery disease using different system using convolutional neural networks,” in Proc. 6th Int. Conf. IT
durations of ECG segments with convolutional neural network,” Knowl.- Convergence Secur., 2016, pp. 1–5. [Online]. Available: https://doi.org/
Based Syst., vol. 132, pp. 62–71, 2017. [Online]. Available: 10.1109/ICITCS.2016.7740310
[32] M. Sandler, A. Howard, M. Zhu, A. Zhmoginov, and L.-C. Chen, “Mo-
https://doi.org/10.1016/j. knosys.2017.06.003
[11] M. Kantardzic, Data Mining: Concepts, Models, Methods, and bilenetv2: Inverted residuals and linear bottlenecks,” in Proc. IEEE
Algorithms, 3rd ed. Hoboken, NJ, USA: Wiley, 2020. Conf. Comput. Vis. Pattern Recognit., 2018, pp. 4510–4520.
[12] S. García, J. Luengo, and F. Herrera, Data Preprocessing in Data [33] T. Rahman et al., “COV-ECGNET: COVID-19 detection using ECG trace
Mining, 1st ed. Berlin, Germany: Springer, 2015. images with deep convolutional neural network,” 2021,
[13] G. Dougherty, Pattern Recognition and Classification: An Introduction. arXiv:2106.00436.
Berlin, Germany: Springer, 2013. [34] G. Huang, Z. Liu, L. V. D. Maaten, and K. Q. Weinberger, “Densely
[14] A. Subasi, Practical Machine Learning for Data Analysis Using Python. connected convolutional networks,” in Proc. IEEE Conf. Comput. Vis.
Cambridge, MA, USA: Academic, 2020. Pattern Recognit., 2017, pp. 2261–2269.
[15] J. Soni, U. Ansari, D. Sharma, and S. Soni, “Predictive data mining [35] C. Szegedy, V. Vanhoucke, S. Ioffe, J. Shlens, and Z. Wojna,
for medical diagnosis: An overview of heart disease prediction,” Int. J. “Rethinking the inception architecture for computer vision,” in Proc.
Comput. Appl., vol. 17, no. 8, pp. 43–48, 2011. IEEE Conf. Comput. Vis. Pattern Recognit., 2016, pp. 2818–2826.
[16] K. Dissanayake and M. G. Md Johar, “Comparative study on heart [36] A. Pal, R. Srivastva, and Y. N. Singh, “CardioNet: An efficient ECG
disease prediction using feature selection techniques on classification arrhythmia classification system using transfer learning,” Big Data Res.,
algorithms,” Appl. Comput. Intell. Soft Comput., vol. 2021, 2021, Art. vol. 26, 2021, Art. no. 100271. [Online]. Available: https://doi.org/10.
no. 5581806. [Online]. Available: 1016/j.bdr.2021.100271
https://doi.org/10.1155/2021/5581806 [37] R. Avanzato and F. Beritelli, “Automatic ECG diagnosis using convo-
[17] A. H. Gonsalves, F. Thabtah, R. M. A. Mohammad, and G. Singh, “Pre- lutional neural network,” Electronics, vol. 9, no. 6, 2020, Art. no. 951.
diction of coronary heart disease using machine learning: An experimental [Online]. Available: https://doi.org/10.3390/electronics9060951
analysis,” in Proc. 3rd Int. Conf. Deep Learn. Technol., 2019, pp. 51– [38] U. R. Acharya, H. Fujita, S. L. Oh, Y. Hagiwara, J. H. Tan, and M.
56. [Online]. Available: https://doi.org/10.1145/3342999.3343015 Adam, “Application of deep convolutional neural network for automated
[18] H. Kim, M. I. M. Ishag, M. Piao, T. Kwon, and K. H. Ryu, “A data detection of myocardial infarction using ECG signals,” Inf. Sci., vol.
mining approach for cardiovascular disease diagnosis using heart rate 415– 416, pp. 190–198, 2017. [Online]. Available:
variability and images of carotid arteries,” Symmetry, vol. 8, no. 6, https://doi.org/10.1016/j.ins. 2017.06.027
2016, Art. no. 47. [Online]. Available: [39] M. Naz, J. H. Shah, M. A. Khan, M. Sharif, M. Raza, and R.
https://doi.org/10.3390/sym8060047 Damaševicˇius, “From ECG signals to images: A transformation based ap-
[19] T. Ozcan, “A new composite approach for COVID-19 detection in X-ray proach for deep learning,” PeerJ Comput. Sci., vol. 7, 2021, Art. no.
images,” Appl. Soft Comput., vol. 111, 2021, Art. no. 107669. [Online]. e386, doi: 10.7717/peerj-cs.386.
Available: https://doi.org/10.1016/j.asoc.2021.107669 [40] H. El-Amir and M. Hamdy, Deep Learning Pipeline: Building a Deep
[20] F. N. Iandola, S. Han, M. W. Moskewicz, K. Ashraf, W. J. Dally, and K. Learning Model With TensorFlow. New York, NY, USA: Apress Media,
Keutzer, “SqueezeNet: Alexnet-level accuracy with 50x fewer 2020.
parameters and< 0.5 MB model size,” 2016, arXiv:1602.07360. [41] M. A. Hearst, S. T. Dumais, E. Osuna, J. Platt, and B. Scholkopf,
[21] A. Krizhevsky, I. Sutskever, and G. E. Hinton, “Imagenet classification “Support vector machines,” IEEE Intell. Syst. Appl., vol. 13, no. 4,
with deep convolutional neural networks,” Adv. Neural Inf. Process. Syst., pp. 18–28,
vol. 25, pp. 1097–1105, 2012. Apr. 1998. [Online]. Available: https://doi.org/10.1109/5254.708428
[22] A. H. Khan, M. Hussain, and M. K. Malik, “Cardiac disorder [42] M. Abubaker and W. M. Ashour, “Efficient data clustering algorithms: Im-
classification by electrocardiogram sensing using deep neural network,” provements over Kmeans,” Int. J. Intell. Syst. Appl., vol. 5, no. 3, pp. 37–
Complexity, vol. 2021, 2021, Art. no. 5512243. [Online]. Available: 49, 2013. [Online]. Available: https://doi.org/10.5815/ijisa.2013.03.04
https://doi.org/10. 1155/2021/5512243 [43] B. Charbuty and A. Abdulazeez, “Classification based on decision tree
[23] A. H. Khan and M. Hussain, “ECG images dataset of cardiac patients,” algorithm for machine learning,” J. Appl. Sci. Technol. Trends, vol. 2,
Mendeley Data, vol. V2, 2021. [Online]. Available: https://doi.org/10. no. 1, pp. 20–28, 2021.
17632/gwbz3fsgp8.2 [44] L. Breiman, “Random forests,” Mach. Learn., vol. 45, no. 1, pp. 5–32,
[24] C. Potes, P. Saman, A. Rahman, and B. Conroy, “Ensemble of feature- 2001. [Online]. Available: https://doi.org/10.1023/A:1010933404324
based and deep learning-based classifiers for detection of abnormal heart [45] E. Miranda, E. Irwansyah, A. Y. Amelga, M. M. Maribondang, and
sounds,” in Proc. Comput. Cardiol. Conf., 2016, pp. 621–624. M. Salim, “Detection of cardiovascular disease risk’s level for adults
[25] A. Nannavecchia, F. Girardi, P. R. Fina, M. Scalera, and G. Dimauro, using naive Bayes classifier,” Healthcare Inform. Res., vol. 22, no. 3,
“Personal heart health monitoring based on 1D convolutional neural pp. 196–205, 2016. [Online]. Available: https://doi.org/10.4258/hir.2016.
network,” J. Imag., vol. 7, no. 2, 2021, Art. no. 26. [Online]. Available: 22.3.196
https://doi.org/10.3390/jimaging7020026 [46] G. Masetti and F. D. Giandomenico, “Analyzing forward robustness of
[26] Q. Zhang, D. Zhou, and X. Zeng, “HeartID: A multiresolution convolu- feedforward deep neural networks with LeakyReLU activation function
tional neural network for ECG-based biometric human identification in through symbolic propagation,” in Proc. Joint Eur. Conf. Mach. Learn.
smart health applications,” IEEE Access, vol. 5, pp. 11805–11816, 2017. Knowl. Discov. Databases, 2020, pp. 460–474.
[Online]. Available: https://doi.org/10.1109/ACCESS.2017.2707460 [47] S. Shahinfar, P. Meek, and G. Falzon, “How many images do I need?”
[27] U. R. Acharya, S. L. Oh, Y. Hagiwara, J. H. Tan, M. Adam, and R. S. Understanding how sample size per class affects deep learning model
Tan, “A deep convolutional neural network model to classify performance metrics for balanced designs in autonomous wildlife mon-
heartbeats,” Comput. Biol. Med., vol. 89, pp. 389–396, 2017. [Online]. itoring,” Ecological Inform., vol. 57, 2020, Art. no. 101085. [Online].
Available: https: Available: https://doi.org/10.1016/j.ecoinf.2020.101085
//doi.org/10.1016/j.compbiomed.2017.08.022 [48] B. Zoph, E. D. Cubuk, G. Ghiasi, T. Lin, J. Shlens, and Q. V. Le,
“Learning data augmentation strategies for object detection,” in Proc.
Eur. Conf. Comput. Vis., 2020, pp. 566–583.

You might also like