An Efficient ECG Denoising Method Based on Empirical Mode Decomposition, Sample Entropy, and Improved Threshold Function

College of Computer and Communication Engineering, Changsha University of Science and Technology, 410114, China Hunan Provincial Key Laboratory of Intelligent Processing of Big Data on Transportation, Changsha University of Science and Technology, Changsha, 410114 Hunan, China School of Computer Science and Engineering, Hunan University of Science and Technology, Xiangtan 411004, China Changsha Social Work College, Changsha 410004, China


Introduction
ECG signals are widely used in the diagnosis of heart disease and are commonly regarded as the most important tool for heart disease diagnosis in clinical practice [1]. Therefore, the analysis and processing of ECG signals is of great significance for heart disease detection. However, various types of noise are introduced during the acquisition of ECG signals; these include baseline drift caused by the patient's breath, electromyogram noise caused by the contraction and movement of human muscles, motion artifacts arising due to electrode movement [2,3], channel noise caused by white Gaussian noise introduced during channel transmission, power line interference, and other types of noise pollution. All these types of noise may cause distortion of the ECG waveform, which obscures the tiny features that are most important for diagnosis [4]. Accordingly, various denoising methods have been proposed to maximize the extraction of useful information from the ECG.
Researchers have studied a number of such methods, such as directly designing an IIR or FIR filter [5,6]; however, the amplitude and frequency of the ECG signal obtained by this method are easily distorted, and the noise removal effect is also less than ideal. Huang et al. devised a signal analysis approach based on the time scale of the signal itself and decomposed the signal into a series of intrinsic mode functions (IMFs), which is regarded as empirical mode decomposition (EMD) [7]. Donoho proposed a general threshold method based on discrete wavelet transform (DWT) [8], while [9] proposed a new method that removes ECG signal noise based on both EMD and DWT. Moreover, [10] presents a power line interference removal method based on empirical wavelet transform and adaptive filtering, while in [11], a new method for removing noise from ECG signals was proposed based on EMD, constrained least squares (CLS), and DWT.
EMD is an adaptive and efficient decomposition method capable of decomposing any complex signal into finite intrinsic mode functions. It is very suitable for processing nonlinear and nonstationary signals, such as ECG signals [12]. One of the key elements of EMD-based denoising is to determine the noise IMF. Traditional EMD denoising often directly discards the first IMF to achieve the removal of high-frequency noise; however, this method not only discards some important information but also does not completely denoise the signal. Therefore, the question of how to more accurately determine the order of IMF which needs to be denoised remains an active one.
Another signal denoising method in widespread use is threshold denoising. The traditional soft and hard threshold functions invented by Donoho and Johnstone [13,14] are the most commonly used threshold denoising approaches. However, these two functions have some defects in theory that affect the denoising performance. The traditional hard threshold function in the mean square error sense is better than the soft threshold method, because the principle of the hard threshold method involves setting a fixed threshold; however, coefficients higher than the threshold value remain unchanged, while coefficients lower than the threshold value are set to zero. While this processing method can completely retain the information larger than the threshold value, the resulting signal will exhibit additional oscillations and jump points and will not have the smoothness of the original signal. For its part, the soft threshold method proposes to shrink the coefficients that exceed the threshold value and set all coefficients less than the threshold value to zero. The effect after processing is as follows: the coefficients near the threshold value are continuous, and the signal after denoising is smooth, but due to the compression of the signal, some errors will occur, which will affect the degree of approximation between the denoised signal and the original signal.
Accordingly, an improved threshold denoising function is presented in the present work, which improves on the existing EMD-based denoising methods. By calculating the sample entropy of each IMF after the decomposition of EMD, it is possible to judge the IMF order that needs to be denoised, after which the new threshold function denoising is carried out for these IMFs. The main contributions are as follows: (1) Determine the IMF order that needs to be denoised by calculating the sample entropy value of the IMF after EMD (2) A new threshold denoising function is proposed, which overcomes the large difference between the coefficients processed by the traditional soft threshold function and the coefficient before processing and the shortcomings of the traditional hard threshold function being not continuous (3) Further smoothing the signal after denoising The rest of this work is organized as follows. In Section 2, the empirical mode decomposition and sample entropy are introduced. Section 3 then introduces the steps of the algorithm proposed in this work. Section 4 presents the experimental results along with their qualitative and quantitative comparative analyses. Finally, Section 5 summarizes the methods and results of this paper.

Background Knowledge
2.1. Empirical Mode Decomposition. EMD is a new signal analysis method proposed by Huang et al. [7]. EMD is an adaptive and efficient decomposition method capable of decomposing any complex signal into a finite number of intrinsic mode functions and has many advantages when it comes to the processing of nonlinear and nonstationary signals.
EMD is actually a method of signal decomposition, which is consistent with the core idea of Fourier transform and wavelet transform, and involves the decomposition of the signal into the superposition of each independent component. However, EMD does not need the basis function but instead decomposes the signal through its own time scale, meaning that it has self-adaptability. Since EMD does not need a basis function, it is suitable for any type of signal and especially for the decomposition of nonlinear and nonstationary signals.
The purpose of EMD is to decompose the signal into a finite number of intrinsic mode functions (IMFs). The instantaneous frequency at any point of the intrinsic mode function is meaningful. Huang et al. considered that any signal is composed of several intrinsic mode functions. IMF is a function that satisfies the following two conditions: (1) The numbers of zeros and poles in the whole data segment are equal or differ by one at most (2) At each time point, the mean value of the envelope determined by the local maximum value and the envelope determined by the local minimum value is zero The steps in the screening process are as follows:  (1)-(4) with r 1 ðtÞ as the new data until all IMFs have been extracted. The filtering process is terminated when the nth residual signal r n ðtÞ satisfies a given termination condition (usually making r n ðtÞ a monotone function). Therefore, the original data SðtÞ can be represented as the sum of the decomposed IMF and obtained r n ðtÞ: where n is the number of IMFs and c i ðtÞ is the ithorder IMF, while r n ðtÞ is the residual signal.

Sample Entropy.
Sample entropy is a method used to measure the complexity of a time series. It is an improvement of approximate entropy. In this study, sample entropy is used to determine the noisy IMF order. The detailed calculation method of sample entropy is as follows. Given the time series X = fx 1 , x 2 , x 3 ,⋯,xng with length N , the entropy calculation process of the sample is as follows:  (4): (6) The sample entropy of the time series is thus defined as As the actual signal cannot approach infinity, we estimate the sample entropy as follows: In this paper, we take m = 2 and r = 0:25 * stdðXÞ, where stdðXÞ is defined as the standard deviation of the initial data X.

Proposed Methods
In this paper, the EMD of ECG signals was firstly carried out in order to obtain multiple IMF components. In the next step, the sample entropy of each IMF was used to determine the IMF components requiring denoising; the new and improved threshold denoising function developed in this article was then used to process these IMFs, after which the signal was reconstructed to obtain the denoised ECG signals. Figure 1 presents the flow chart of the algorithm proposed in this paper, which will be explained in more detail in the following sections.
3.1. EMD of the Signal. First, the ECG signal is decomposed via EMD to obtain multiple IMF components. The decomposed IMFs have the following two characteristics: (1) the mean time scale of the IMF increases with the increase of the IMF order; and (2) the time scale contained in each IMF varies over time (i.e., is not the same throughout). The fundamental principle of noise reduction using EMD involves discarding the part of the IMF that contains noise, then using the sum of the other IMFs to form the denoised signal. Although many methods have been proposed to identify noisy IMF [15], when these are directly applied to ECG denoising, the performance achieved is unsatisfactory. Therefore, there is significant room for improvement regarding how to select IMFs with noise, how to denoise IMFs with noise, and how to improve the quality of the denoised signal.
3.2. Judging IMF Components with Noise. The calculation of sample entropy is independent of the length of the sequence; only short data is needed to get a robust estimate. This 3 Wireless Communications and Mobile Computing approach can be used for mixed signals composed of random components and deterministic components; moreover, the analysis effect obtained is superior to that of simple statistical parameters such as mean, variance, and standard deviation [16,17]. The more complex the sequence, the higher the sample entropy and the lower the self-similarity of the sequence, while, by contrast, the higher the self-similarity of the sequences, the lower the sample entropy [18]. Based on this theory, we judge the noisy IMF component by going through the following steps: (1) First, the first-order IMF was taken as the noise series X and its sample entropy was calculated, where the order of IMF was m = 1 (2) Let m = m + 1, after which the mth IMF and noise sequence X are reconstructed. The reconstructed sequence is regarded as a new noise sequence X, and its sample entropy is calculated (3) If the sample entropy of the noise sequence increases, continue to repeat step (2); if the sample entropy decreases, the judgment is stopped. We regard the IMF before the current order m as the noisy IMF; that is, IMF k ðk = 1, ⋯, mÞ is the noise IMF As the set noise sequence becomes more and more complex, its sample entropy will gradually increase [19]. Subsequently, if IMFs continue to be added, more useful signals will also be included; this will result in the noise being overwhelmed by the useful signals, meaning that the sample entropy of the noise sequence will be reduced.

New Threshold Function Denoising and Signal Reconstruction
3.3.1. Threshold Denoising for Noisy IMFs. After the noisy IMFs are determined, the next step is to perform threshold denoising on these IMFs. In this paper, improvements are made to the traditional soft and hard threshold methods and a novel, superior threshold denoising function is proposed.
Recall that the principle of the hard threshold method involves setting a fixed threshold value, such that coefficients larger than the threshold value remain unchanged, while coefficients smaller than the threshold value are set to zero; this processing method enables information larger than the threshold value to be retained but produces additional oscillations and jump points in the signal so that it lacks the smoothness of the original. Moreover, the soft threshold method proposes shrinking coefficients larger than the threshold value and setting coefficients smaller than the threshold value to zero. The coefficients around the threshold are therefore continuous, while the resulting signal is smooth after denoising; however, some errors will also arise due to the compression of the signal, which will affect the degree of approximation between the denoised signal and the original signal. In order to preserve the original signal to the greatest extent possible, a new threshold processing method is proposed as follows: Here, d is the coefficient that requires threshold processing, T is the threshold, D is the coefficient after threshold processing, λ is the adjustment factor, and λ is used to control the size of D. When As can be seen from the above, when the absolute value of the coefficient continues to increase, the coefficient after the threshold value treatment will be closer to the coefficient before treatment; this overcomes the problem of the large difference between the coefficients before and after traditional soft threshold function treatment. When the absolute value of the coefficient approaches the threshold value, the coefficient after treatment is close to 0; this indicates that the threshold processing function is continuous at the threshold point, which improves the discontinuity of the traditional hard threshold function. Figure 2 presents a comparison between the proposed improved threshold function and the traditional soft and hard threshold functions (for simplicity's sake, only the first quadrant image is drawn in this figure). Here, the threshold value is set to 3, while λ is 50. As can be seen from the figure, the hard threshold function is nonsequence at the threshold point, and there is a constant difference between D after the soft threshold function processing and the coefficient d before the processing. The improved threshold function is continuous at the threshold point; moreover, as the coefficient d continues to increase, the coefficient D after the e signal was decomposed by EMD to obtain IMF components of each order   Wireless Communications and Mobile Computing threshold continues to be close to d, which eliminates the problem of difference in the soft threshold context. The threshold selection in this paper uses a fixed threshold. Generally speaking, the fixed threshold value is T = σ ffiffiffiffiffiffiffiffiffiffiffiffiffiffi ffi 2 log N p , where σ is the standard deviation of the whole noise and N is the signal length. Therefore, the T obtained by this method is of a fixed size. The IMF coefficients of each layer are different, but the threshold T of each layer is the same, meaning that the denoising effect obtained is not good. Therefore, in order to ensure that the threshold is adaptively adjusted depending on the different decomposition levels, this paper adopts the following hierarchical threshold selection method; the formula is as follows: Here, T is the threshold value, N is the number of samples, i is the current order of IMF, and σ is the standard deviation of noise. Moreover, in order to select different thresholds according to the IMF coefficients of different layers, the noise standard deviation is calculated according to the IMF coefficients of each order: IMFi, k represents the coefficient of the ith-order IMF, while medianðÞ is the median calculation.

Signal Reconstruction.
Finally, the processed IMF and the untreated IMF as well as the residual are reconstructed to obtain the denoised ECG.

Signal Smoothing
Processing. After the above denoising processing is complete, some noise often remains in the signal. Accordingly, to further eliminate noise, we smooth the reconstructed signal [20]. First, we calculate the maximum value (lmax) in the signal minimum value and the minimum value (upmin) in the maximum value. The signal in this part needs to be smoothed. The reconstructed signal starts from the second point: (1) i = 2

Results and Discussion
In this chapter, we conduct several experiments to prove the denoising feasibility of the proposed method. In order to demonstrate the denoising effect more persuasively, we conducted experiments on the MIT-BIH arrhythmia database [21]. The signal length in this database is 650,000 samples, with a sampling rate of 360 Hz and a resolution of 11 BPS. All experiments in this paper are carried out on MATLAB 2018. The method is evaluated both qualitatively and quantitatively to prove its superiority. In this experiment, after comprehensive empirical testing, we set the adjustment factor λ of the improved threshold function to 500.

Qualitative Evaluation.
In order to verify the proposed algorithm's robustness to different types of noise, we randomly selected signals with different numbers from the MIT-BIH database, then added three different forms of analog noise to these signals, specifically white Gaussian noise, EMG noise, and power line interference. The EMG signal noise is simulated by generating random noise, while the power line interference is simulated by adding a 50 Hz sinusoidal signal. We can clearly see that while the denoising signal reduces most of the noise, the ectopic complexes still exist; thus, it can be concluded that during the denoising process, the method still retains the morphological characteristics of the original signal, which contain important diagnostic information.
We next added the EMG noise to the signal no. 113 record; here, we simulate the EMG interference by adding random noise (where μ = 0 and σ = 0:15). As shown in Figure 4, the algorithm has good robustness for the removal of EMG noise. Figure 5 adds 20 dB white Gaussian noise to the signal no. 122 record and uses the proposed algorithm to conduct denoising. As can be seen from the figure, this algorithm has a good denoising effect for white Gaussian noise, while the denoised signal is relatively smooth and exhibits less distortion.

Quantitative Evaluation.
In this paper, the performance of the denoising signal and the quality of the reconstructed signal are analyzed by improving SNR (SNR imp ) and mean square error (MSE). SNR imp and MSE are evaluation parameters widely used in the signal denoising context [22,23]. The signal-to-noise ratio (SNR), which refers to the ratio of signal to noise, can quantify the signal quality from the perspective of energy; moreover, improving signal-to-noise ratio (SNR imp ) refers to the increase of SNR following signal denoising. Generally speaking, a high SNR indicates that the signal contains less noise. MSE is a measure that reflects the degree of difference between the original signal and the denoised signal. A lower MSE value indicates that the denoised signal is better able to retain the details of the original signal.
The formula for SNR imp is defined as follows:

Wireless Communications and Mobile Computing
The formula for MSE is as follows: Here, xðiÞ represents the original clean signal, yðiÞ is the signal after adding noise to the original signal, sðiÞ is the signal after denoising, and N is the signal length. Table 1 presents the improved SNR results of ECG signals with 20 dB white Gaussian noise added. We chose the ECG signals numbered 100, 104, 105, 106, 115, and 215 because these were used in Reference [24]. In practical application, the algorithm presented in this paper is effective for all ECG data signals in the database. The denoising results are further compared with the EMD soft threshold [25], wavelet soft threshold [26], and EMD wavelet [27]. It can be observed from Table 1 that the algorithm presented in this paper has a high SNR imp for different ECG signals when the specific input SNR is 20 dB, so it can be seen that this algorithm can remove more noise. Under the condition of the     high-input signal-to-noise ratio (20 dB), this demonstrates the robustness of this method in terms of its ability to improve signal quality by reducing noise. Furthermore, Table 2 shows the mean square error results of ECG signals with 20 dB white Gaussian noise added. As can be clearly seen from the figure, the algorithm proposed in this paper has a lower MSE after denoising; thus, following denoising via the proposed method, the resultant signal retains more details of (and can thus better estimate) the original signal. Table 3 lists the improved SNR under a wide range of input SNR. We conducted multiple experiments on the signals numbered 100, 104, 105, 106, 115, and 215 and took the average values of all the signals as the results in order to make the experimental data more objective. As can be intuitively seen from the table, compared with the EMD soft threshold, wavelet soft threshold, and EMD wavelet, the method proposed in this paper achieves a higher SNR improvement in any input SNR, and for a lower input SNR, this method can also produce a higher SNR improvement. Figure 6 illustrates the mean square error of the denoised ECG signal when the input signal-to-noise ratio is 6~20 dB. As shown in the figure, at each input signal-to-noise ratio level, the mean square error of this method is smaller than other methods, revealing that the denoising algorithm can estimate the original ECG signal with minimal error. There-fore, the proposed method is better than other schemes at reducing both ECG signal noise and signal distortion.
In addition, we compare the proposed method with NLM [28] and CEEMDAN [29]. To fully prove the usability of the algorithm, we carried out experiments on all signals in MIT-BIH. The SNR improvement values obtained by different algorithms when the input SNR is 10 dB are listed in Table 4. It can be seen from the table that the improved SNR of the algorithm proposed in this paper is the highest for all signals; since SNR imp refers to the increase of SNR following signal denoising, a high SNR indicates that the signal contains less noise indicating that this algorithm can remove more noise and, accordingly, that this method achieves the best denoising effect.
In order to compare the denoising effect of several algorithms more intuitively, we selected the signals with data numbers of 100, 101, 103, 105, 106, 115, and 220 from the MIT-BIH database, added 10 dB white Gaussian noise, and denoised them. Figures 7 and 8 present a comparison of the SNR imp and MSE values of different methods following denoising (these signals were chosen for our experiments because they were also selected in Reference [28]). In a practical application scenario, the algorithm presented in this paper can be seen to be effective for all ECG data signals in the database. It can be further observed from Figures 7 and 8 that the method proposed in this paper not only improves the SNR but also has the lowest MSE after denoising, since a lower MSE value indicates that the denoised signal is better able to retain the details of the original signal, which proves the advantages of this method in terms of reducing ECG signal noise and signal distortion.

Conclusion
This paper proposes an effective ECG denoising method based on EMD, sample entropy, and improved threshold function. The main purpose of this work is to combine EMD and sample entropy in order to determine the order of IMFs that need to be denoised, as well as to denoise these IMFs with the threshold function proposed in this paper. While traditional EMD denoising often discards the first IMF directly in order to remove high-frequency noise, this approach not only results in some important information being discarded but also does not completely denoise the signal. In this paper, different types of noise are added to prove the robustness of the proposed denoising method. At the same time, the effectiveness of the proposed method is evaluated by means of improving SNR and MSE. The technique is compared with ECG denoising methods based on the EMD soft threshold [25], wavelet soft threshold [26], EMD wavelet [27], NLM [28], and CEEMDAN [29]. From the simulation study and detailed analysis, it can be seen that the proposed ECG denoising method is better than the existing technology. In-depth qualitative and quantitative analyses reveal that the proposed method can better reduce the noise of ECG signals while also retaining more details of the original signal, meaning that it is a good ECG signal denoising method. In the future work, we can further feature extraction of ECG signals and research on the computer-based automatic diagnosis system. Moreover, many video/image processing methods [30][31][32][33][34] will be adopted to denoise ECG signals. We will also try to apply deep learning [35][36][37][38][39][40] and network optimization [41][42][43] methods to process ECG signals. Furthermore, we will use the big data processing approaches [44][45][46][47][48] to process a large number of ECG signals.

Data Availability
The software code and data used to support the findings of this study are available from the corresponding author upon request.