1. Introduction
Cardiovascular diseases (CVDs) maintain a persistently high mortality rate on a global scale, exerting a significant impact on human health [1]. Among these, arrhythmias constitute a critical branch of cardiovascular diseases, underscoring the clinical importance of early prevention and diagnosis. Current diagnostic approaches for cardiovascular diseases encompass radiological diagnostics, electrocardiographic diagnostics, and analyses of disease-related biochemical markers, and often rely on the naked eye of an expert to analyze [2]. Historically, electrocardiography (ECG) has been instrumental in diagnostic procedures, and it contains methods such as electrocardiograms, dynamic electrocardiograms, and vector cardiograms. ECG captures the cardiac muscle cell’s bioelectrical changes throughout the cardiac cycle, creating a graphical representation through the detection of electrical potential variations on the body’s surface. It is a non-invasive testing method widely employed to diagnose the presence of cardiac conditions in individuals [3].
Arrhythmias, characterized by abnormalities in heart rate or rhythm, are common cardiovascular disorders [4] and can lead to life-threatening consequences if not promptly treated [5]. MIT-BIH database stands as the most widely utilized [6], featuring a diverse array of ECG signal types and abundant data, totaling 48 records, each with a duration of 30 minutes. The dataset consists of records obtained from 47 individuals, comprising 25 males and 22 females, whose ages range from 23 to 89 years. The acquired data typically encompassed two channels, wherein the first channel commonly corresponded to the MLII lead, while the second channel was predominantly associated with the V1 lead (with some instances involving V2 or V5, and record 124 utilizing V4). To maintain lead consistency, this paper exclusively utilizes the MLII lead ECG signals for analysis.
Considering the emergence of artificial intelligence, the field of deep learning, a methodology focused on data-driven feature acquisition, has experienced a swift rise in recognition. In the contemporary era, Convolutional Neural Network (CNN) has emerged as a representative methodology [7]. For instance, Essa et al. [8] and Petmezas et al. [9] employed the CNN-LSTM approach for training an ECG signal classification model, while Xu et al. [10] and Hassan et al. [11] developed a composite architecture known as CNN-BiLSTM to fulfill the function of ECG signal classification.
CNNs are renowned deep learning models widely employed in the analysis and classification of two-dimensional datasets, encompassing functions like the categorization of images and partitioning of visual elements [12]. One-dimensional CNNs, derived from their two-dimensional counterparts with specific adaptations, have been tailored for tasks that involve the analysis of one-dimensional signals, such as biomedical signal processing [13].
This paper primarily aims to expedite ECG signal classification, enhance diagnostic efficiency for medical practitioners, and construct a high-accuracy classification model through the application of deep learning methods and a 10-layer 1D CNN architecture. The process begins with the application of a wavelet soft-threshold filter to denoise ECG signals, resulting in clean signals. Subsequently, heartbeats are segmented based on R-wave annotations from the MIT-BIH database, yielding five categories (N, A, V, L, R) of ECG signal samples suitable for deep learning. Finally, a 10-layer 1D CNN model is constructed to perform signal classification. To assess the value and advancement of the proposed model, this paper introduced an evaluation encompassing measures of accuracy, sensitivity, and specificity, followed by a comparative analysis against alternative approaches.
2. Methodology
2.1. Preprocessing technique for ECG signal
The ECG signal exhibits weak amplitude, low frequency, and stochastic nature, making it susceptible to interference from various noise sources [14]. These sources include noise generated within the biological system, such as noise arising from respiration, muscular tremors, and noise introduced by poor contact with surface electrodes. In summary, the three primary types of noise that significantly affect ECG signals are powerline interference, electromyographic interference, and baseline drift. These noise interferences also necessitate suppression and removal during the ECG signal preprocessing phase. Thus, an effective denoising method is needed to preprocess the ECG signal.
2.1.1. Wavelet thresholding denoising. Wavelet denoising technique is one of the primary methods for noise reduction in ECG signals, characterized by its multi-resolution analysis capability [15]. Through the utilization of this technique, the original signal containing noise can be decomposed and processed, breaking it down into high-frequency and low-frequency components based on frequency bands [16]. Given the disparate frequencies between ECG signals and noise, wavelet transformation decomposition yields distinct wavelet coefficients at different decomposition scales.
Threshold denoising is a widely adopted technique within the domain of wavelet denoising, known for its simplicity and effectiveness. In its application, this method specifically processes coefficients at various levels resulting from wavelet decomposition. After this selective processing, the wavelet coefficients are subjected to an inverse transformation, facilitating reconstruction analysis and ultimately yielding the denoised ECG signal.
In this paper, a 9-level wavelet decomposition approach was adopted for wavelet threshold denoising signal processing, as illustrated in Figure 1 below.
Figure 1. 9-level wavelet thresholding denoising flowchart.
2.1.2. QRS Wave Detection. For the human heart, a complete cardiac cycle comprises a single cycle of contraction and relaxation. The heartbeat generates electrical excitation, manifesting as subtle currents, while the electrocardiogram (ECG) captures the comprehensive variations in cardiac currents. A complete cardiac waveform typically encompasses similar structure including P wave and T wave, with the QRS complex in the middle [17, 18]. Figure 2 demonstrates an entire cardiac waveform.
Figure 2. An entire cardiac waveform.
2.2. Classification Recognition Based on Deep Learning Theory
2.2.1. The CNN Architecture. A convolutional neural network (CNN) is a specialized form of deep neural network distinguished by its utilization of convolutional computations, rendering it a prominent representative among deep learning algorithms [19]. In contrast to traditional machine learning approaches, CNN offers two distinct advantages: the ability to automatically extract features and accomplish classification tasks, as well as the capability to handle large-scale datasets [20, 21]. Figure 3 below illustrates one of the CNN network architectures.
Figure 3. An example of CNN architecture.
2.2.2. Model Design Steps. The model utilized in this investigation is a 10-layer 1D CNN classification architecture, the detailed structure is illustrated in the accompanying Figure 4. The input of the input layer consists of denoised and clean signal samples. The convolutional layers are utilized to extract the essential features required in this paper, while the pooling layers serve to perform feature dimensionality reduction. Convolutional and pooling operations alternate to enhance the efficacy of feature selection. After the signal undergoes convolutional and pooling operations, it undergoes a fully connected layer operation, ultimately transforming the feature vector into a one-dimensional representation. This vector is then fed into the output layer, yielding results for five distinct types of cardiac signal categories.
The analysis in this paper employed the openly accessible MIT-BIH arrhythmia dataset [6]. Each record in the database contains signals from two channels, with the first channel typically representing the MLII lead and the second channel representing the V1 lead. To ensure consistency in leads, this paper focused on the MLII lead ECG signals for research and analysis.
In this paper, five distinct categories of electrocardiogram signals were chosen for analysis, which include N, A, V, L, and R. In Python code, these five types are represented using the labels 0, 1, 2, 3, and 4. The dataset utilized for model training constitutes 70% of the total dataset, while the test set comprises 30%. Additionally, a dropout ratio of 0.2, a batch size of 256, and a maximum epoch count of 30 were employed during the training process. The diagram depicting the implementation process outlined in this manuscript is presented in Figure 5.
Figure 4. 10-layer 1D CNN structure in this paper.
3. Results and Discussion
To validate the efficacy of CNN in ECG signal classification, a 10-layer 1D CNN network model was devised in this paper, using the TensorFlow structure and Keras package based on Python in the PyCharm platform.
3.1. Results
3.1.1. CNN Network Architecture Parameters. The parameters for the CNN model, established through experimental validation, are detailed in Figure 6 below. In this paper, the preprocessed data that is input to the input layer is a data array of dimensions as 300 \( × \) 1, which, through the learning process, ultimately yields a classification model with dimensions as 5 \( × \) 1.
3.1.2. CNN Model Training Results. After training, the classification model fulfills its function in the test dataset. Figure 7 (a) provides the accuracy curve of the proposed classification model, while Figure 7 (b) illustrates its loss curve.
As illustrated in Figure 7 (a), the model presented in this study attained accuracy in the train dataset (99.63%) and accuracy in the test dataset (99.43%). Furthermore, it demonstrated a training set loss of around 0.012 and a testing set loss of just over 0.031 in Figure 7 (b).
3.2. Discussion
3.2.1. CNN Model Evaluation. To substantiate the efficacy and trustworthiness of the method devised in this study, the confusion matrix was employed to depict the predictive outcomes for the five categories of arrhythmia data [22]. The confusion matrix is a commonly employed algorithm for visualizing classification results. By displaying actual categories and predicted values, it intuitively reveals details about sample classification, facilitating model performance evaluation. The confusion matrix generated for the ECG 5-class classification in this paper is illustrated in the Figure 8. Most samples are correctly classified, with only a small portion being misclassified. This observation indicates the efficacy of the model trained in this paper. Through the utilization of the confusion matrix, it becomes feasible to compute the classification ability for individual classes and for the entire test sample dataset.
Figure 5. ECG signals classification process in this paper.
Through the confusion matrix, four primary indicators can be derived: the count of instances where the actual value is positive and the model classifies it as positive (TP - True Positive), the count of instances where the actual value is positive but the model classifies it as negative (FP - False Positive), the count of instances where the actual value is negative but the model classifies it as positive (FN - False Negative), and the count of instances where the actual value is negative and the model classifies it as negative (TN - True Negative).
Figure 6. The parameters of the proposed model.
Figure 7. The proposed 10-layer 1D CNN model’s accuracy and loss trends.
To further assess the performance of the methods, accuracy, precision, sensitivity, and specificity were employed as secondary indicators to evaluate the classification results of the ECG signals based on the confusion matrix. The calculation formulas for the accuracy (A), precision (P), sensitivity (S), and specificity (Sp) evaluation metrics are as following equation (1) (2) (3) and (4).
Figure 8. The proposed 10-layer 1D CNN model’s confusion matrix.
\( Accuracy=\frac{TP+TN}{TP+FP+TN+FN}\ \ \ (1) \)
\( Precision=\frac{TP}{TP+FP}\ \ \ (2) \)
\( Sensitivity=\frac{TP}{TP+FN}\ \ \ (3) \)
\( Specificity=\frac{TN}{TN+FP}\ \ \ (4) \)
Four secondary indicators were employed to assess the proposed 10-layer 1D CNN model further, aim to evaluate the ECG signal classification outcomes derived from the analysis of the confusion matrix. The mathematical outcomes are elucidated in the subsequent Table 1.
Table 1. The proposed 10-layer 1D CNN model’s performance.
Performance | Classes | ||||
N | A | V | L | R | |
Accuracy | 0.994 | 0.996 | 0.998 | 0.999 | 0.999 |
Precision | 0.996 | 0.931 | 0.986 | 0.995 | 0.997 |
Sensitivity | 0.993 | 0.916 | 0.987 | 0.999 | 0.998 |
Specificity | 0.988 | 0.998 | 0.998 | 0.999 | 0.999 |
The proposed model in this paper demonstrates superior classification performance on ECG signals. The evaluation criteria for various electrocardiogram signals approach a level close to 1, indicating the high stability of the model in this paper and its suitability for ECG signal classification applications.
3.2.2. Comparison Analysis. To validate the efficacy of the methodology presented in this paper, a comparative assessment was conducted, contrasting the secondary indicators of the different methods, as depicted in Figure 9. In this paper, the accuracy and specificity values are both equal to Petmezas et al. [9], standing at 0.99, surpassing other studies like Essa et al. [8], Xu et al. [10], and Hassan et al. [11], with an increment ranging from 0.1 to 0.3. Regarding sensitivity, this paper outperforms these four research articles, with an increase ranging from 0.1 to 0.3.
Figure 9. Existing work comparison.
The 10-layer 1D CNN model, introduced in this paper, demonstrates an accuracy rate (99.43%), sensitivity rate (97.86%), and specificity rate (99.64%). With a sufficient number of data samples used, the model can ensure a high degree of generalization and robustness.
4. Conclusion
The classification of ECG signals holds significant importance in aiding the classification of cardiovascular diseases. This paper primarily proposed a 10-layer 1D CNN and its input layer receives preprocessed ECG signals, then through feature extraction learning, ultimately outputs a classification model consisting of five categories. From the results, the proposed CNN model achieves over 99% in accuracy as well as in specificity, with a lower percentage in sensitivity (97.86%). The result of the paper provides an effective model for ECG signal classification. Specifically, it can recognize 5 different types with an accuracy of 99.43% and hence can be employed in clinical settings. Despite the model’s commendable performance levels, it is important to acknowledge certain constraints associated with the training data. The MIT-BIH arrhythmia database exhibits an imbalanced distribution of ECG signal types, with normal ECG signals comprising the vast majority. Despite these limitations, the model proposed in this paper still offers a viable direction for enhancing ECG signal recognition. It serves as a valuable reference for the implementation of high-accuracy automated ECG signal recognition systems. In the future, it is anticipated that more data will be recorded in the database for training new models, and this aspect represents a significant focus for future work in this paper.
References
[1]. Izci E, Ozdemir M A, Degirmenci M and Akan A 2019 Cardiac Arrhythmia Detection from 2D ECG Images by Dsing Deep Learning Technique (2019 medical technologies congress (TIPTEKNO)) (Izmir Turkey IEEE) pp 1-4
[2]. Zhang P, Cheng J and Zhao Y 2020 Classification of ECG Signals Based on LSTM and CNN (Artificial Intelligence and Security: 6th International Conference ICAIS 2020, Hohhot, China, Proc. Part III 6) (Singapore Springer) pp 278-289
[3]. Husain K, Mohd Zahid M S, UI Hassan S, Hasbullah S and Manadala S 2021 Advances of ecg sensors from hardware, software and format interoperability perspectives Electronics. 10(2) 105
[4]. Zeng W, Su B, Chen Y and Yuan C. 2023 Arrhythmia detection using tqwt, ceemd and deep cnn-lstm neural networks with ecg signals Multimed. Tools. Appl. 82(19) 29913-41
[5]. Murat F, Yildirim O, Talo M, Baloglu U B, Demir Y and Acharya U R 2020 Application of deep learning techniques for heartbeats detection using ecg signals-analysis and review Comput. Biol. Med. 120 103726
[6]. Moody G B and Mark R G 2001 The impact of the mit-bih arrhythmia database IEEE Eng. Med. Biol. Mag. 20(3) 45-50
[7]. Chou Y, Hong S, Zhou Y, Shang J, Song M and Li H 2020 Knowledge-shot learning: an interpertable deep model for classifying imbalanced electrocardiography data Neurocomputing 417 64-73
[8]. Essa E and Xie X 2021 An ensemble of deep learning-based multi-model for ecg heartbeats arrhythmia classification IEEE Access 9 103452-64
[9]. Petmezas G, Haris K, Stefanopoulos L, Kilintzis V, Tzavelis A, Rogers A J, Katsaggelos K A and Maglaveras N 2021 Automated artial fibrillation detection using a hybrid cnn-lstm network on imbalanced ecg datasets Biomed Signal Process Control 63 102194
[10]. Xu X, Jeong S and Li J 2020 Interpretation of electrocardiogram (ecg) rhythm by combined cnn and bilstm IEEE Access 8 125380-8
[11]. Hassan S U, Mohd Zahid M S, Abdullah T A and Husain K 2022 Classification of cardiac arrhythmia using a convolutional neural network and bi-directional long short-term memory Digit. Health 8 20552076221102766
[12]. Bizopoulos P and Koutsouris D 2018 Deep learning in cardiology IEEE Rev Biomed Eng 12 168-93
[13]. Liu X, Wang H, Li Z and Qin L 2021 Deep learning in ecg diagnosis: a review Knowl Based Syst 227 107187
[14]. Cheng J, Zou Q and Zhao Y 2021 Ecg signal classification based on deep cnn and bilstm BMC Medical Inform. Decis. Mak. 21 1-12
[15]. Zhao Y, Cheng J, Zhang P and Peng X 2020 Ecg classification using deep cnn improved by wavelet transform Comput. Mater. Contin. 64 1615-28
[16]. Marzog H A, Abd H J and Ashraf I 2022 Machine learning ecg classification using wavelet scattering of feature extraction Appl. Comput. Intell. Soft Comput. 2022 1-8
[17]. Sowmya S and Jose D 2022 Contemplate on ecg signals and classification of arrhythmia signals using cnn-lstm deep learning model Measuremetn: Sensors 24 100558
[18]. Omar N, Dey M and Ullah M A 2020 Detection of Myocardial Infarction from ECG Signal Through Combining CNN and Bi-LSTM (2020 11th international conference on electrical and computer engineering (ICECE)) (Dhaka Bangladesh IEEE) pp 359-398
[19]. Ahmed A A, Ali W, Abdullah T A, Malebary and Malebary S J 2023 Classification cardiac arrhythmia from ecg signal using 1d cnn deep learning model Mathematics 11(3) 562
[20]. Ali O M A, Kareem S W and Mohammed A S 2022 Evaluation of Electrocardiogram Signals Classification Using CNN, SVM, and LSTM Algorithm: A review (2022 8th International Engineering Conference on Sustainable Technology and Development) (Erbil Iraq IEEE) pp 185-191
[21]. Wasimuddin M, Elleithy K, Abuzneid A-S, Faezipour M and Abuzaghleh O 2020 Stage-based ecg signal analysis from traditional signal processing to machine learning approached: a survey IEEE Access 8 177782-803
[22]. Merdjanovska E and Rashkovska A 2022 Comprehensive survey of computational ecg analysis: databases, methods and applications Expert Syst. Appl. 203 117206
Cite this article
Hu,Z. (2023). ECG signal classification based on CNN deep learning. Theoretical and Natural Science,13,171-180.
Data availability
The datasets used and/or analyzed during the current study will be available from the authors upon reasonable request.
Disclaimer/Publisher's Note
The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of EWA Publishing and/or the editor(s). EWA Publishing and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
About volume
Volume title: Proceedings of the 3rd International Conference on Computing Innovation and Applied Physics
© 2024 by the author(s). Licensee EWA Publishing, Oxford, UK. This article is an open access article distributed under the terms and
conditions of the Creative Commons Attribution (CC BY) license. Authors who
publish this series agree to the following terms:
1. Authors retain copyright and grant the series right of first publication with the work simultaneously licensed under a Creative Commons
Attribution License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this
series.
2. Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the series's published
version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial
publication in this series.
3. Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and
during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See
Open access policy for details).
References
[1]. Izci E, Ozdemir M A, Degirmenci M and Akan A 2019 Cardiac Arrhythmia Detection from 2D ECG Images by Dsing Deep Learning Technique (2019 medical technologies congress (TIPTEKNO)) (Izmir Turkey IEEE) pp 1-4
[2]. Zhang P, Cheng J and Zhao Y 2020 Classification of ECG Signals Based on LSTM and CNN (Artificial Intelligence and Security: 6th International Conference ICAIS 2020, Hohhot, China, Proc. Part III 6) (Singapore Springer) pp 278-289
[3]. Husain K, Mohd Zahid M S, UI Hassan S, Hasbullah S and Manadala S 2021 Advances of ecg sensors from hardware, software and format interoperability perspectives Electronics. 10(2) 105
[4]. Zeng W, Su B, Chen Y and Yuan C. 2023 Arrhythmia detection using tqwt, ceemd and deep cnn-lstm neural networks with ecg signals Multimed. Tools. Appl. 82(19) 29913-41
[5]. Murat F, Yildirim O, Talo M, Baloglu U B, Demir Y and Acharya U R 2020 Application of deep learning techniques for heartbeats detection using ecg signals-analysis and review Comput. Biol. Med. 120 103726
[6]. Moody G B and Mark R G 2001 The impact of the mit-bih arrhythmia database IEEE Eng. Med. Biol. Mag. 20(3) 45-50
[7]. Chou Y, Hong S, Zhou Y, Shang J, Song M and Li H 2020 Knowledge-shot learning: an interpertable deep model for classifying imbalanced electrocardiography data Neurocomputing 417 64-73
[8]. Essa E and Xie X 2021 An ensemble of deep learning-based multi-model for ecg heartbeats arrhythmia classification IEEE Access 9 103452-64
[9]. Petmezas G, Haris K, Stefanopoulos L, Kilintzis V, Tzavelis A, Rogers A J, Katsaggelos K A and Maglaveras N 2021 Automated artial fibrillation detection using a hybrid cnn-lstm network on imbalanced ecg datasets Biomed Signal Process Control 63 102194
[10]. Xu X, Jeong S and Li J 2020 Interpretation of electrocardiogram (ecg) rhythm by combined cnn and bilstm IEEE Access 8 125380-8
[11]. Hassan S U, Mohd Zahid M S, Abdullah T A and Husain K 2022 Classification of cardiac arrhythmia using a convolutional neural network and bi-directional long short-term memory Digit. Health 8 20552076221102766
[12]. Bizopoulos P and Koutsouris D 2018 Deep learning in cardiology IEEE Rev Biomed Eng 12 168-93
[13]. Liu X, Wang H, Li Z and Qin L 2021 Deep learning in ecg diagnosis: a review Knowl Based Syst 227 107187
[14]. Cheng J, Zou Q and Zhao Y 2021 Ecg signal classification based on deep cnn and bilstm BMC Medical Inform. Decis. Mak. 21 1-12
[15]. Zhao Y, Cheng J, Zhang P and Peng X 2020 Ecg classification using deep cnn improved by wavelet transform Comput. Mater. Contin. 64 1615-28
[16]. Marzog H A, Abd H J and Ashraf I 2022 Machine learning ecg classification using wavelet scattering of feature extraction Appl. Comput. Intell. Soft Comput. 2022 1-8
[17]. Sowmya S and Jose D 2022 Contemplate on ecg signals and classification of arrhythmia signals using cnn-lstm deep learning model Measuremetn: Sensors 24 100558
[18]. Omar N, Dey M and Ullah M A 2020 Detection of Myocardial Infarction from ECG Signal Through Combining CNN and Bi-LSTM (2020 11th international conference on electrical and computer engineering (ICECE)) (Dhaka Bangladesh IEEE) pp 359-398
[19]. Ahmed A A, Ali W, Abdullah T A, Malebary and Malebary S J 2023 Classification cardiac arrhythmia from ecg signal using 1d cnn deep learning model Mathematics 11(3) 562
[20]. Ali O M A, Kareem S W and Mohammed A S 2022 Evaluation of Electrocardiogram Signals Classification Using CNN, SVM, and LSTM Algorithm: A review (2022 8th International Engineering Conference on Sustainable Technology and Development) (Erbil Iraq IEEE) pp 185-191
[21]. Wasimuddin M, Elleithy K, Abuzneid A-S, Faezipour M and Abuzaghleh O 2020 Stage-based ecg signal analysis from traditional signal processing to machine learning approached: a survey IEEE Access 8 177782-803
[22]. Merdjanovska E and Rashkovska A 2022 Comprehensive survey of computational ecg analysis: databases, methods and applications Expert Syst. Appl. 203 117206