MENDEL — Soft Computing Journal, Volume 23, No.gk, .2+2K#2` 202k, Brno, Czech RepublicX ISSN: 1803-3814 (Printed), 2571-3701 (Online) https://doi.org/10.13164/mendel.202k.k.062 The Use of the Multi-Scale Discrete Wavelet Transform and Deep Neural Networks on ECGs for the Diagnosis of 8 Cardio-Vascular Diseases Soumiaa Mhamed-Amine , El Habbari Sara, Mansouri Mohamed LAMSAD Laboratory, Hassan 1st University, ENSA Berrechid, Morocco [email protected] , elhabba[email protected],
[email protected] Abstract Cardiovascular diseases (CVD) continues to be the leading cause of death worldwide, with over 17 million deaths each year. In 2015, approximately 422 million people suffered from cardiovascular disease (CVD). Reading and analyzing electrocardiograms (ECGs) can be time consuming, and the development of decision support tools based on automated systems can facilitate and speed up the diagnosis of ECGs. In this paper, we propose a 12 leads ECG signals classification using Multi-level Discrete Wavelet Transform and ResNet34 Deep Learning algorithm which classifies 8 types of cardiovascular diseases: Atrial fibrillation (AF), 1st degree atrioventricular block (AV), Left bundle branch block (LBBB), Right bundle branch block (RBBB), Premature ventricular contraction (PVC), Premature atrial contraction (PAC), ST segment depression (STD), and ST segment elevation (STE). The ECGs are preprocessed, and different features are extracted using Multi-level Discrete Wavelet Transform. The model is trained on a database of more than 6000 electrocardiograms which includes 9 types of 12-lead ECGs: a normal type and the 8 abnormal ones which correspond to the diseases mentioned above. Keywords: Electrocardiogram, ECG, Cardiology, Deep learning, Artificial Neural Networks, Classification, Diagnosis, Automation, Discrete Wavelet Transform, Signal Processing. Received: 25 October 2022 Accepted: 27 November 2022 Online: 07 December 2022 Published: 20 December 2022 1 Introduction Electrocardiograms contains electrical signals that correspond to the patient’s heartbeat, these signals allow doctors to check if the heartbeat is correct [1,9]. However, visual analysis of ECGs by specialists is a timeconsuming and sometimes difficult task due to problems with low voltage or low amplitude electrical equipment that an ECG can contain [3]. This traditional method is based on the experience of doctors, and there is always the likelihood that the results of their analyses contain human errors related to fatigue and daily stress at work. That’s why we propose this automated ECG processing and classification system using deep learning. The ECG records the electrical activity of the heart during normal functioning. A standard ECG contains 12 leads, 6 leads in the frontal plane placed on the arms and legs, also called limb leads: D1, D2, D3, aVR, aVL, aVF, and 6 in the horizontal plane placed on the torso (precordium), called the precordial leads: V1, V2, V3, V4, V5 and V6. Most of the work carried out on the analysis of electrocardiograms uses deep learning algorithms directly on ECGs in image format. In our approach, we applied ResNet34 classification algorithm on the physical signals extracted from each ECG, keeping the 12 different leads of each ECG. To filter out signal noise and derive more useful information from it, we applied a Multilevel Discrete Wavelet Transform using several wavelet models such as Daubechies and Symlet. The resulting coefficients of this method in addition to other features extracted from the signals are used in the training of the model. 2 Methods and Data Processing 2.1 Dataset Information We decided to use the Physiological Signals Challenge database held in China (CPSC 2018) [7]. This database is among the largest sources in terms of number of ECG recordings and also number of abnormalities type, it has 6,877 ECGs collected from 11 hospitals in China. The ECGs were provided in MATLAB format (.mat extension), each file contains the 12 electrocardiogram leads as you can see in Figure 1, in addition to the patient’s gender and age. The data was sampled at a frequency of 500 Hz. The recording time varies between 6 and 60 seconds. 2.2 Dataset Distribution Of the 6877 electrocardiograms, 3178 are for women and 3699 are for men. Among all the ECGs, there are 476 multi-classes, these recordings concern patients 62
MENDEL — Soft Computing Journal, Volume 23, No.gk, .2+2K#2` 202k, Brno, Czech RepublicX Soumiaa-g2igHX,gT he Use of the Multi-Scale Discrete Wavelet Transform and Deep Neural Networks on ECGs for ... Figure 1: Example of 12-leads ECG of a person having RBBB. diagnosed with 2 or 3 types of cardiac arrhythmias. There are 470 patients with 2 types of disease and 6 patients with 3 types of disease. 2.3 Data Processing The extracted signals are generally noisy and influenced by several sources. To extract useful information from it, a signal processing method must be used. The most widely used methods include the Fourier transform (TF), which collects information on the frequency of a signal. In theory, TF (Equation (1)) allows any function to be decomposed into a sum of waves, that is, sine and cosine functions with different frequencies and amplitudes. Xk= N−1 X n=0 xne−2πikn N,for 0 ≤k≤N−1 (1) This method is convenient for permanent stationary signals, where frequencies persist throughout the signal, such as in sound signals, but it does not provide the temporal localization of the frequencies. Thus, the Fourier transform is not suitable for quasi-periodic signals with short oscillation times like signals from ECGs. Another alternative is the short-term Fourier transform (TFCT), it comes to overcome the problem of poor temporal resolution of the Fourier transform. The TFCT (Equation (2)) consists in cutting the signal into several segments and performing the Fourier transform on each segment. STFT{x[n]}(m, ω)≡X(m, ω) = P∞ n=−∞ x[n]ω[n−m]e−jωn (2) The function xto transform is multiplied by a window function wof a fixed length, which allows to define the portions of the signal. The disadvantage is that the temporal and frequency resolutions are fixed throughout the signal because of the fixed size of the window, a narrow window allows to have a good temporal resolution but a poor frequency resolution, and on the other hand a wide window gives poor temporal resolution but good frequency resolution. The Wavelet Transform comes to answer this problem through Multi-Resolution Analysis (MRA) which analyses the signal in different frequencies at different resolutions [2]. A wavelet is a localized waveform oscillation with an amplitude starting from zero. The wavelet has a role equivalent to the window function in the TFCT. As the wavelet moves through the signal, its width and the center frequency can be changed by changing the denominator s. A large value of s allows the wavelet to be spread to seek low frequencies, on the other hand a small value of s will crush the wavelet to seek high frequencies with good temporal resolution. We have chosen to use a Discrete Wavelet Transform (DWT) which uses a finite set of wavelets during signal analysis. As the wavelet of a particular scale moves through the signal, at every moment, the wavelet is multiplied by the signal [5]. The product of this multiplication is the wavelet coefficient at that time and for the chosen scale. The result of the application of the MRA on the signal give us detail and approximation coefficient as we can see the Figure 2. Figure 2: Multiresolution signal analysis (MRA). The resulting DWT (Equation (3)) approximation coefficient vectors, alongside other statistical features extracted from the ECGs signals, are used for training the deep learning model. D[a, b] = 1 √b p−1 X m=0 f[tm]ψtm−a b(3) For the application of the Multi-scale Discrete Wavelet Transform on the set of electrocardiograms, we have chosen a wavelet of the Daubechies family with 4 moment of escape ”D2”, also called ”db4”, and a wavelet of the Symlet family with 4 vanishing moments “Sym4”. Both chosen wavelets resemble to the beats in ECG signals, as we can see in Figure 3. Figure 3: Db4 wavelet and Sym4 wavelet at level 4. Levels 1 and 2 correspond to high frequencies which generally consist of noise. From level 3, we start to see a noise-free signal, and we can clearly distinguish the “R” peaks of the ECG signal. In Figure 4, we can distinctly see the difference between the two signals, before and after applying the multilevel Dwt on an 63
MENDEL — Soft Computing Journal, Volume 23, No.gk, .2+2K#2` 202k, Brno, Czech RepublicX ECG signal of a person suffering from AF, the noise has clearly reduced. Figure 4: The ECG signal of a person suffering from AF and the same signal after applying DWT using Sym4 wavelet with level 4. After extracting the approximation coefficient from the level 4 using the DWT, we use them to calculate the Shannon entropy (Equation (4)), which is a measure that helps to quantify the amount of information in the signal. E(S) = − n X i=0 pilog2(pi) (4) To train the deep learning model, we decided to use the obtained information resulting from the level 4 of the DWT applied to the signal, in addition of other statistical features that we calculate from each lead of the ECG, like the mean, the median, the variance, the standard deviation and the Shannon entropy. All the 12 leads of the 6877 electrocardiograms are used, so we have 82524 signals as input of the model. 2.4 Processing and Model Architecture To classify the signals extracted from electrocardiograms, we decided to use the deep learning model ResNet34 [4]. The resulting coefficients of the MultiScale Discrete Wavelet Transform and the calculated statistical measures are the input of the data model. ResNet34 is based on the residual neural network ResNet [4], which is an artificial neural network (ANN) that contains multiple residual blocks linked with shortcut connections forming a residual network. As we can see in Figure 5, the model consists of a first convolution layer with a 7x7 convolution followed by 4 convolution layers blocks that incorporate 34 parameter layers with a 3x3 convolution. The conv layers in-side the same block has the same dimensions. The input of each layer has an additional connection to the output of the next layer, using the technique of skip connections or shortcut connections, which allows to avoid the vanishing gradient problem. The first block is composed of 6 convolution layers with an output size of 56x56. The second block have 6 layers with an output size of 28x28. The third block have 12 layers with an output size of 14x14. The fourth block have 6 layers with an output size of 7x7. Then we do an average and a max polling followed by a dense layer, at the out-put, we have the class of the disease predicted by the model. The data cleaning, pre-processing, and the model development were Figure 5: Preprocessing and Model training architecture. done using Python language and the library Pytorch. For the training, we used a Dell Latitude E5470, Intel Core i5-6300 vPro, CPU 2.50 GHz 16 Go RAM. 3 Results and Discussion 3.1 General Metrics After using sym4 and db4 wavelets in the multi-level discrete wavelet transform, the proposed deep learning model based on ResNet34 shows an AUC of 0.98, a high accuracy of 0.97, and a F1 scores of 0.86 and 0.84 for db4 and sym4 wavelets. Table 1: Metrics results using wavelets ’Db4’ and ’Sym4’. Wavelet AUC Accuracy F1-Score Db4 0.98 0.971 0.86 Sym4 0.98 0.97 0.848 64
MENDEL — Soft Computing Journal, Volume 23, No.gk, .2+2K#2` 202k, Brno, Czech RepublicX Soumiaa-g2igHX,gT he Use of the Multi-Scale Discrete Wavelet Transform and Deep Neural Networks on ECGs for ... Table 2: AUC Metric results for the 9 classes using wavelets ’Db4’ and ’Sym4’. Wavelet SNR AF LAVB LBBB RBBB PAC PVC STD STE Db4 0.972 0.988 0.993 0.998 0.993 0.962 0.983 0.972 0.962 Sym4 0.98 0.987 0.99 0.998 0.992 0.956 0.978 0.974 0.966 Table 3: Accuracy Metric results for the 9 classes using wavelets ’Db4’ and ’Sym4’. Wavelet SNR AF LAVB LBBB RBBB PAC PVC STD STE Db4 0.952 0.974 0.983 0.994 0.964 0.949 0.975 0.959 0.99 Sym4 0.949 0.971 0.975 0.99 0.974 0.943 0.977 0.964 0.987 Table 4: F1-Score Metric results for the 9 classes using wavelets ’Db4’ and ’Sym4’. Wavelet SNR AF LAVB LBBB RBBB PAC PVC STD STE Db4 0.824 0.929 0.92 0.92 0.934 0.711 0.855 0.821 0.829 Sym4 0.821 0.921 0.877 0.877 0.952 0.683 0.862 0.847 0.78 3.2 Detailed Results 3.2.1 AUC The Area Under Curve (AUC) represents the degree of separability. It gives the probability that the model classifies a random positive example on top of a random negative example. A higher AUC means the model distinguish between patients with CDV and no CDV. 3.2.2 Accuracy Accuracy (5) represents the ratio of the number of the correct predictions to the total number of dataset samples. Accuracy =Nr of correct predictions Total nr of predictions made =TP+TN Total samples (5) 3.2.3 F1-Score F1 score (6) balances between precision and recall. It gives us how many examples were predicted correctly and shows the robustness of the model by verifying that is not missing a significant number of instances. F1 score = 2 ∗Precision ∗Recall Precision + Recall (6) 3.2.4 Confusion matrix The confusion matrix is a way to summarize the performance of the classification model. It calculates precision, sensitivity, specificity and other metrics from values: true positives (TP), true negatives (TN), false positives (FP), false negatives (FN). In the Figure 6, on the left, we can see that our model predicted 98.9% of the TP and 90.7% of the TN, which means that 98.9% of people suffering from Atrial Fibrillation disease were predicted correctly, and 90.7% of people who does not suffer from AF were also predicted correctly. 3.3 Discussion In the last 5 years, many researchers proposed different deep learning model and approaches to clasFigure 6: Confusion Matrix of Atrial fibrillation (AF) disease prediction after using Dwt with Db4 wavelet and Sym4 wavelet. sify ECG signals. In this paper [8], the authors propose a hybrid system combining Long Short-Term Memory (LSTM) and Convolution Neural Networks (CNN) model to classify 4 abnormalities right bundle branch block (RBBB), premature ventricular contraction (PVC), atrial premature beats (APB) and left bundle branch block (LBBB), using a database of 48 ECG recording, they got an accuracy of 98.1%. In another study [6], the authors used SVM algorithm and DWT to classify the same 4 abnormalities, the results gave 97.3% accuracy. In this work [10], authors used Rhythm Net to classify one abnormality atrial fibrillation (AF), they got an accuracy of 82%. Few works have used DWT and all the 12 leads of the electrocardiogram to do a multi-classification with large number of abnormalities. In our study, we did the classification of 8 cardiovascular diseases using all the 12 leads. The dataset used is one of the largest databases available in the medical field, containing 6877 ECG records with 12 leads, which means 82524 signals were pre-processed. We also used statistical measures calculated from the signals and the coefficients extracted from the Multi-scale Discrete Wavelet Transform using the Daubechies wavelet ‘Db4’ and the Symlet wavelet Sym4, as input of the deep learning model, instead of an image of the signal or ECG raw data. The classification gave us high scores, 97.1% accuracy and 86% F1-Score using the Db1 wavelet and 97% accuracy and 84.48% F1-Score using the Sym4 wavelet. 65
MENDEL — Soft Computing Journal, Volume 23, No.gk, .2+2K#2` 202k, Brno, Czech RepublicX 4 Conclusion In our paper, we proposed a 12 lead ECG signals classification for 8 different types of cardiovascular diseases, using the coefficients extracted for the application of the multi-scale discrete wavelet transform and some statistical measures calculated form the signals. After trying different wavelet families, we choose ‘Db4’ wavelet from the Daubechies family and ‘Sym4’ wavelet of the Symlet family for the DWT preprocessing. The results of the multi-classification of our approach using all 12 leads of the electrocardiograms, gave us high accuracy of 97.1%. We compared our work to existing papers, which most of them use Image classification while we used multilevel DWT and statistical features extracted from the ECG signal, to train the deep learning model. For the future, we will work on the optimization of the model, and try to improve the results by using additional data from other ECG datasets, and we will work on integrating the solution into a software with a graphical interface that can be used in the health sector. References [1] Cardiovascular diseases (cvds) - key facts. world health organisation (who), 2021. Available on: https://www.who. int/news-room/fact-sheets/detail/ cardiovascular-diseases-(cvds) (Accessed on 15 june 2021). [2] Bunrit, S., Kerdprasop, N., and Kerdprasop, K. Multiresolution analysis based on wavelet transform for commodity prices time series forecasting. International Journal of Machine Learning and Computing 8, 2 (2018), 175–180. [3] Hannibal, G. B. Interpretation of the lowvoltage ecg. AACN Advanced Critical Care 25, 1 (2014), 64–68. [4] He, K., Zhang, X., Ren, S., and Sun, J. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition (2016), pp. 770–778. [5] Kandaswamy, A., Kumar, C. S., Ramanathan, R. P., Jayaraman, S., and Malmurugan, N. Neural classification of lung sounds using wavelet coefficients. Computers in biology and medicine 34, 6 (2004), 523–537. [6] Li, H., Yuan, D., Wang, Y., Cui, D., and Cao, L. Arrhythmia classification based on multidomain feature extraction for an ecg recognition system. Sensors 16, 10 (2016), 1744. [7] Liu, F., Liu, C., Zhao, L., Zhang, X., Wu, X., Xu, X., Liu, Y., Ma, C., Wei, S., He, Z., et al. An open access database for evaluating the algorithms of electrocardiogram rhythm and morphology abnormality detection. Journal of Medical Imaging and Health Informatics 8, 7 (2018), 1368–1373. [8] Oh, S. L., Ng, E. Y., San Tan, R., and Acharya, U. R. Automated diagnosis of arrhythmia using combination of cnn and lstm techniques with variable length heart beats. Computers in biology and medicine 102 (2018), 278–287. [9] Roth, G. A., Johnson, C., Abajobir, A., Abd-Allah, F., Abera, S. F., Abyu, G., Ahmed, M., Aksut, B., Alam, T., Alam, K., et al. Global, regional, and national burden of cardiovascular diseases for 10 causes, 1990 to 2015. Journal of the American college of cardiology 70, 1 (2017), 1–25. [10] Xiong, Z., Nash, M. P., Cheng, E., Fedorov, V. V., Stiles, M. K., and Zhao, J. Ecg signal classification for the detection of cardiac arrhythmias using a convolutional recurrent neural network. Physiological measurement 39, 9 (2018), 094006. 66