Automatic Electrocardiogram Sensing Classifier Based on Improved Backpropagation Neural Network

As


Introduction
An electrocardiogram (ECG) shows the prospective electrical signal of the heartbeat on the skin, taping heart rhythm, and also its physical and pathological information of electrical conduction, which objectively mirrors the physiological standing and also features of all parts of the heart. It has been widely used in assessment, medical diagnosis, and even in the identification of the heart condition of individuals. (1)(2)(3)(4)(5) Although trained and knowledgeable cardiologists carry out ECG medical diagnosis, misdiagnosis inevitably occurs. ECG tests are also expensive and time-consuming. Therefore, automatic ECG testing is necessary. In spite of decades of innovations in filtering, examination, and also developing various types of ECG, (6)(7)(8)(9) noise disturbance over ECG, divided into types of signs and symptoms, and even a specific variant challenge both the credibility and precision of ECG signal classification.
ECG signal acquisition is sensitive to baseline drift, myoelectric interference, and power frequency harassment. Therefore, before classifying ECG signals, we must first remove noise. Conventional denoising methods include morphological filtering, Kalman filtering, empirical mode decomposition, and wavelet filtering. Wavelet transform is prominent in multiresolution signal analysis, which attracts many researchers, and on the basis of this method, denoising methods were thereby put forward. (10)(11)(12)(13) For example, Poungponsri and Yu proposed adaptive filtering based on wavelet transform and an artificial neural network. (10) Jenkal et al. developed a denoising algorithm for ECG signals based on adaptive double threshold filtering and a discrete wavelet transform. (11) Fedotov carried out multiresolution wavelet filtering. (13) All the methods are effective in eliminating noise from ECG signals.
The existing ECG signal recognition is primarily achieved with principal component analysis (PCA), support vector machine (SVM), backpropagation (BP) neural network, and convolutional neural network (CNN). (14)(15)(16)(17)(18)(19) As an example, Raj and Rayv adopted a distinct cosine transform (DCT) as well as PCA to obtain time-frequency features and SVM to categorize ECG signals. (15) Arif et al. proposed the automated detection and localization of coronary infarction (MI) in which a BP neural network (BPNN) classifier with time-domain name functions of each beat drawn out from a 12-electrode ECG is used. (16) Dewangan and Shukla used a distinct wavelet transform (DWT) for preprocessing and attributed extraction, as well as a neural network, to categorize five kinds of arrhythmias. (17) Rajpurkar et al. trained a 34-layer CNN, which maps a sequence of ECG samples to a series of rhythm classes. (18) Urtnasan et al. established six modified convolutional layers. They also proposed automatic discovery using a CNN for obstructive sleep apnea (OSA) examined using a monopolar-electrode ECG. (19) The methods mentioned above have achieved favorable validity but with the following limitations. Firstly, it is essential to choose an adaptive wavelet base function when wavelet transform is performed on filter noise. However, the wavelet base functions of the methods described above cannot achieve sufficient regularity or symmetry. Secondly, in character extraction, the extracted parameters cannot correctly represent ECG characteristics. Thirdly, although SVM presents a high precision in the recognition of ECG signals, it cannot attain sufficient generalization when processing large volumes of data. Fourthly, CNN exhibits a high validity for ECG signal recognition but lacks a real-time capability.
The BPNN has preventive robustness, fault tolerance, memory ability, and alternative self-learning ability. Its accuracy and adaptability have the potential to be improved by establishing a multilayer neural network model to solve the problem of automatic recognition and classification. Furthermore, parallel processing enables a large number of calculations to be performed quickly. Therefore, the BPNN performs better in ECG signal classification than other algorithms. On the basis of the above considerations, the BPNN is thought to be competent in the automated recognition of ECG signals. Experiments were carried out using the MIT-BIH database obtained with an ECG sensor to verify the legitimacy as well as the stability of the BPNN.

ECG signal preprocessing
Human electrocardio signals are weak physiological signals that are nonstationary, nonlinear, and stochastic. The acquired ECG signals commonly mix with noise from acquisition devices and the surroundings. Such noise will cause difficulties in the feature extraction and classification recognition of subsequent ECGs. To suppress the noise interference of the ECG signal and retain information useful in enhancing the ECG signal, it is necessary to preprocess the ECG signal. Wavelet transform can provide both time and frequency information of the ECG signal, making it highly suitable for processing nonstationary signals. Moreover, DWT can provide good time and frequency resolutions. It also has the ability to interpret the hidden complexity in ECG at different scales or resolutions. Therefore, the ECG signal can be denoised using DWT.

Spline-based biorthogonal wavelet transforms
In DWT, the Malal algorithm is most commonly used. The second DWT of the ECG signal can be achieved using the Malal algorithm: where x ( j) (n) represents the approximate coefficient of the signal x(n) on the scale and d ( j) (n) is the wavelet coefficient of the signal x(n) on the j scale. Furthermore, h 0 (k) and h 1 (k) are the coefficients of the low-pass and high-pass filters corresponding to the wavelet functions used, respectively. The low-pass filter coefficient h 0 (k) used in this study is 1/4, 3/4, 3/4, or 1/4, and the high-pass filter coefficient h 1 (k) is −1/4, −3/4, 3/4, or 1/4. The use of biorthogonal DWT not only reduces the computational load of wavelet computation but also satisfies the linear phase and has a good correspondence relationship with the original signal.

QRS complex wave detection
The QRS complex wave is predominant in a solitary ECG signal. It shows the electric activity of the heart during the ventricular contraction and consumes the most electrocardiographic signal energy. The QRS complex is located in the medium-and high-frequency locations of a single ECG signal with a peak between 10 and 20 Hz. It is the strongest, most frequent, and sharpest wave. Mathematically, this QRS complex characteristic is called "self-hood" and features a slope anomaly as well as nondifferentiable factors (peak and valley). This is why the QRS complex was identified first among the characteristic waveforms of ECG signals.
By time-scale analysis, the wavelet transforms present the feature of multiresolution and can represent local time-frequency features of signals. The variable time and frequency windows make wavelet transform more adaptable in characteristic signal extraction as ECG signals undergo multiresolution decomposition by wavelet transform. Different frequency components are prominent in distinct frequency bands featuring their apparent singularities. Wavelet transform with odd-symmetric filters turns signal S into F1, with the maximum module corresponding to the zero-crossing point of F1, while that with even-symmetric filters turns signal S into F2 with the maximum module corresponding to the zero-crossing point of F2.
On the basis of the results of the above analysis, we selected biorthogonal spline wavelet transform with the low-and high-pass filter coefficients of 1/4, 3/4, 3/4, and 1/4 and −1/ 4, −3/4, 3/4, and 1/4, respectively, to accurately identify R waves. First, we adopted spline dyadic 4-layer wavelets to decompose ECG signals to obtain the approximation as well as information coefficients of each layer. Second, we determined the modulus maximum of the wavelet coefficients of the ECG signals with scales of j = 1, 2, 3, and 4. Figures 1 and 2 show the maximum moduli of the wavelet coefficients of ECG Nos. 102 and 111 with different scales, respectively. The figure shows that in the heartbeat, as the scale increases, each pair of modulo  maxima corresponding to the frequency band becomes more apparent, but the R-wave offset also increases. The maximum and minimum pairs can be found by using three levels of detail coefficients. Finally, we calculated the zero-crossing point of the minimax value pair to locate R waves. In the procession of the dyadic wavelet transform, the time drift of about 1/36 s occurs between the 3-layer detail coefficient and the unfiltered signal, and the final position of R waves is determined as the located R wave minus 1/36.
Because false and missed detections may occur in locating R waves, we analyzed the relationship between the time difference (R_R) and the average time distance of two consecutive R waves (RRmean) to delete falsely detected R waves and add missing ones. We deleted R waves with low scores of R_R ≤ 0.4 * RRmean, which represents false detection, and located an R wave between two consecutive R waves using the zero-crossing points of minimax values.
Suppose that the quadratic spline wavelet decomposes the ECG signal through Mallat's algorithm and that the wavelet coefficients at the scales of j = 1, 2, 3, and 4 are d 1 , d 2 , d 3 , and d 4 The points of large positive and large negative values on d 3 are p 3 (i) and N 3 (i) (i = 1, 2, ...), respectively. Threshold th1 is β 1 times the average modulus maximum value of p 3 (i), and threshold th2 is β 2 times the average modulus maximum value of N 3 (i). The specific algorithm of R-wave detection is shown in Fig. 3.
Since the characteristics of Q and S waves are mainly concentrated on the wavelet transform J = 1 scale, the peak point of the R wave is obtained by the above-described detection method. The maximum negative point detected in the previous window interval of the J = 1 scale is the peak of the Q wave, and the negative peak in the next window is the peak of the S wave.

P-and T-wave detections
P and T waves have prominent characteristics at scales. Therefore, P and T waves can be detected using the wavelet coefficients and their modulus maxima at the scales j = 3, using the detection algorithms shown by the flowcharts in Figs. 4 and 5.
The startpoints and endpoints of P and T waves can be detected on the basis of their morphological similarity. There are certain relationships between the use of modulo maximum pairs and the startpoint of the waveform, but there is usually an absolute displacement. Therefore, the detected extreme points of P and T waves can be shifted to the right by 3 points. The position at this time is P, the startpoint of the T wave. On the basis of the principle of approximate symmetry, the startpoints and endpoints of P and T waves are calculated.

ECG signal feature extraction
Each cardiac cycle in ECG signals includes routine waves, including the P wave, QRS complex, and T wave. The startpoint, endpoint, top, and valley, as well as interval mirror information of heart mobility, provide considerable information for the diagnosis of heart disease by cardiologists. As a result, we determine 21 characteristic values, including six amplitude and 15 distance features, to form a feature vector, called FeatureVector. In a heartbeat interval, we define the amplitudes of the QRS complex as QV, RV, and SV, and the areas as QL, RL, and SL. We denote the magnitude of the P wave as PV and its location as PL with startpoints and endpoints PB and PE, respectively. They also have comparable magnitudes of PBV and PEV. We denote the size of the T wave as TV, its location as TL, and startpoints and endpoints as TB and TE, respectively, with their matching amplitudes as TBV and TEV. The formulas of the voltage and time-distance vectors are as follows.  VoltageVector is the amplitude feature vector, and TimeDisVector is the time distance feature vector. The feature vectors must be normalized to make the range of each eigenvalue be [−1, 1]. Because the two feature vectors are different, they must be normalized separately in order to combine the magnitude and distance feature vectors to form a heartbeat interval feature vector, that is, the ECG signal feature vector FeatureVector = [VoltageVector, TimeDisVector], which represents the overall and local features of the ECG signal.

ECG signal collection
The ECG signals from 48 sets of arrhythmia data provided by MIT-BIH were used. Each collection of ECG data includes three parts: a header file (.hea), a data file (.dat), and a comment file (.atr). The ECG signal data are read from the header and data files, and the annotation information of each type of ECG diagnosis by the ECG expert is read from the annotation file. Figures 6 and 7 show the first 8 min before reading the data file Nos. 102 and 111, respectively. The ECG signal diagram is labeled with the diagnosis type given by the ECG expert for  each beat of the ECG signal. For example, type 2 represents left bundle branch blockage, 12 represents a pacing heartbeat, and 28 represents a rhythm change.

ECG signal wavelet denoising
As shown in Figs. 5 and 6, the existing baseline drift and high-frequency noise in the ECG signals are detrimental to the acquisition and recognition of ECG signal characteristics. Therefore, the denoising of the original ECG signals is necessary. In our study, wavelet transform is adopted to denoise the ECG signals with the selected wavelet base function combined with signal features of its own. Because of the wide frequency band of ECG signals, the frequencies of interfering and useful signals overlap to some extent. It is hoped that they will be separated as much as possible after signal decomposition. Moreover, because the filtered signals must be analyzed for character extraction and classification, we must ensure that they are distortionless to reduce information loss. To guarantee this, firstly, the wavelet base function must be of high resolution, that is, it must have a high regularity. Secondly, it must be symmetrical to keep the signals distortionless. Thirdly, wavelets usually achieve various filtering effects due to length disparities between the vanishing moment and compact support in the same wavelet. However, no wavelet can fulfill all these requirements. In order to select a suitable wavelet basis function, mean squared error (MSE) and signal noise ratio (SNR) are used to evaluate the denoising performance. If the MSE value is smaller and the SNR is larger, the selected wavelet function is better for ECG signal denoising. Table 1 shows that the bior3.5 wavelet presents superior performance over other wavelets and is preferable for denoising ECG.
Here, N represents the length of the signal, s is the noisy ECG signal, and x i represents the ECG signal after noise removal. Therefore, we use the 8-layer bior3.5 biorthogonal wavelet to perform the multiresolution decomposition and reconstruction of ECG signals. First, the corresponding detail and approximate coefficients are obtained by wavelet decomposition. Baseline drift noise is mainly reflected in large-scale estimation factors. Therefore, the approximate ratios on this scale are set directly to zero to eliminate baseline drift. At the same time, since most high-frequency noise is concentrated on low-level detail coefficients, zeroing the low-level detail coefficients can effectively remove high-frequency noise. Figures 8 and 9 show the results of wavelet denoising of ECG signal Nos. 102 and 111, respectively. It can be seen that the baseline drift and high-frequency noise have disappeared without any loss of the essential frequency characteristics of the ECG signal having useful frequency components.

QRS complex and TP wave detection
Since the detection of QS and TP waves is based on R waves, the accuracy of R-wave detection will significantly affect the detection effect of QS and TP waves. The following experiments were performed with the biorthogonal spline wavelet transform method for R-wave detection to verify the accuracy of R waves. The experimental results are shown in Table 2 below. It can be seen from the table that the accuracy of R-wave detection is confirmed.   Figures 10 and 11 show the results of the detection of QRS waves of ECG signal Nos. 102 and 111, respectively. R waves are marked with red lines, Q waves are marked with green lines, and S waves are marked with blue lines. Figures 12 and 13 show the results of the detection of QRS and PT waves of ECG signal Nos. 102 and 111, respectively, where the P wave is in turquoise, the T wave is in magenta, the starting points of P and T waves are in yellow, and endpoints are in black.

Feature extraction
In this research, 21 features, labeled 1, 2, 3, and 5, were extracted by each of the heartbeat diagnostic experts from the 48 types of arrhythmia data provided by MIB-BIT by the feature extraction method described in Sect. 2.4. Type 1 indicates healthy pulsation, type 2 represents left bundle branch blockage, type 3 represents right bundle branch blockage, and type 5 represents a premature ventricular beat. These features include both the amplitude information of each wave and the distance information between waves, which better represent the global and local characteristics of ECG signals in a heartbeat cycle. Figures 14 and 15 show cutaway diagrams of partial feature vectors labeled categories 1 and 2, respectively.

Improved BPNN classification algorithm
We carried out experiments to verify the validity of the improved BPNN classification algorithm of ECG signals. First, we read the heartbeat information of all medical diagnosis types 1, 2, 3, and 5 from the 48 collections of ECG data of MIT-BIH, and determined the  function vector types of each classification. 1300 feature vector types were determined for a total of 5200 vector types. We arbitrarily selected 4000 vector types as training data and 1200 vector types as test information. The results of numerous experiments of the five chosen procedures are listed in Table 3. From the outcomes, it can be seen that when the amounts of training data in each type are similar, the correct recognition rate of type 1 is close to or becomes 100%, and the ratings are types 2 and 3. An acceptable correct recognition rate is 98-100%, but the correct recognition rate of type 4 is primarily between 91 and 95%, and the overall average correct recognition rate is less than 98%. The results reveal that we have achieved favorable correct recognition rates of the selected ECG signal attributes. At the same time, the results for type 5 are worse than those for the other three types. This weakness might be attributed to the algorithm itself and the shortage of training samples of type 5 compared with the other three types. As a result, we can improve the correct recognition rate in two ways: (1) increase the number of training samples of type 5 with a small number of training samples of types 2 and 3, and (2) divide the samples into the training, validation, and examination sets. The recognition set is applied to verify the outcomes and identify the optimal training set, while the test set is used to evaluate the stability of the model.
The flowchart of the ECG signal recognition algorithm of the above analysis is shown in Fig. 16. From the above analysis and the flowchart in Fig. 16, the algorithm of ECG recognition can be described as follows.
Step 1: Extract four feature vector types of the diagnostic types 1, 2, 3, and 5 from the 48 heartbeat signal types in the MIT-BIH database.
Step 2: Randomly extract a data set with various diagnostic types and numbers of feature vector types, and divide it into sample, validation, and test sets.
Step 3: Train the BPNN model using the sample set.
Step 4: Verify the model using the validation set. If the average correct recognition rate reaches 99% or the number of training iterations reaches 10, select the optimal model and go to step 5; otherwise, return to step 3.
Step 5: Test the obtained model and output the test results.

Experimental Results and Analysis
Accuracy, sensitivity, and specificity are determined to evaluate the performance of the improved BPNN algorithm in classifying and recognizing the ECG signals. The specific definitions are as follows.
(1) Accuracy is the ratio of the total number of diseased to disease-free samples detected by the algorithm. The greater the algorithm's ability to detect the actual condition of the sample, the higher the accuracy.

TP TN Acc TP FN FP TN
(2) Sensitivity indicates the ability of the algorithm to detect the disease. The greater the algorithm's ability to detect such diseases, the higher the sensitivity.

TP Sen
TP FN = + (3) Specificity indicates the ability of the algorithm to detect disease-free specimens. The greater the algorithm's ability to detect disease-free specimens, the better it is.
There are four kinds of classification in this research: TP (samples in this group are correctly classified), FP (samples not truly in this group are incorrectly classified as being in this group), FN (samples truly in this group are incorrectly classified as being in another group), and TN (samples not in this group are correctly classified as not being in this group). Tables 4 to 7 show the results of classifying the ECG using the LIBSVM-3.23 SVM class library, (20) BPNN, CNN, and the algorithm proposed in this paper, respectively. The following conclusions are gained from these tables. (1) The classification effect of normal heartbeat (type 1) is better because the typical ECG and arrhythmia waveforms have notably different morphological characteristics such that the classification effect will be superior. (2) For the classification effect of other arrhythmia types, the sensitivity of other methods of detecting arrhythmia signals of type 5 is relatively low, and the sensitivity of the algorithm in this paper is higher by about 3 to 5% than that of the other algorithm. (3) The algorithms are superior in the order of SVM, BPNN, and CNN algorithms regardless of the accuracy, sensitivity, and specificity in a single class or multiple classes. The results indicate that the algorithm proposed in this paper has higher detection capabilities.   Table 8 shows that the average correct recognition rate of our formula surpasses 99%. The modified formula exhibits a higher correct recognition rate than the straight application of the BPNN. On the other hand, the average correct recognition rate is increased by more than 1%.
We compare the correct recognition rates of ECG signals between our algorithm and other artificial intelligence algorithms, SVM, BPNN, and CNN. The average correct recognition rates of five experiments are detailed in Table 9. It is found that the algorithm proposed in our study offers higher recognition rates than SVM, BPNN, and CNN.

Conclusions
We presented a novel method of classifying ECG arrhythmia signals for each patient individually. The 8-layer bior3.5 wavelet was effectively employed to eliminate baseline drift and remove high-frequency noise. The improved BPNN can classify the ECG signals with a high correct recognition rate. We can draw the following conclusions from comparisons with the other three methods.
We achieved exceptional recognition outcomes and also obtained different classification performance statistics utilizing ECG samples from the MIT-BIH arrhythmia data source. The average recognition rate of our method is higher than those of SVM, BPNN, and CNN, especially for the recognition of type 5, for which the rate is increased by more than 1-3 percentage points. The results have greater value as reference data for the clinical diagnosis of ECG signals.
Our techniques can be expanded to classify many more types and has shown satisfactory recognition results. Our proposed technique requires a small collection of representative datasets as the attribute set. It utilizes the enhanced BPNN as the classifier using GA, consequently considerably enhancing the recognition performance.
The future works will focus on three tasks. (1) Validate our proposed method using other ECG databases and actual ECG signals.
(2) Enlist other medical companies to boost the sample size as well as to perform type recognition in a greater variety of other heart rhythms. (3) Use the proposed methodology in telemedicine applications, arrhythmia monitoring systems, cardiac pacemakers, remote patient monitoring, and intensive care units as an auxiliary system.