ECG signal denoising using discrete wavelet transform: A comparative analysis of threshold values and functions

The electrocardiogram signal ( ECG ) is a bio-signal used to determine cardiac health. However, different types of noise that commonly accompany these signals can hide valuable information for diagnosing disorders. The paper presents an experimental study to remove the noise in ECG signals using the Discrete Wavelet Transform ( DWT ) theory and a set of thresholds filters for efficient noise filtering. For the assessment process, we used ECG records from MIT-BIH Arrhythmia database ( MITDB ) and standardized noise signals (muscle activity and electrode-skin contact) database from the Noise Stress Test database. In addition to the ECG signals a white Gaussian noise present in electrical type signals was added. Furthermore, as a first step we considered baseline wander and power line interference reduction. The metrics used are the Signal-to-Noise Ratio ( SNR ), the Root Mean Squared Error ( RMSE ), the Percent Root mean square Difference ( PRD )


INTRODUCTION
The electrocardiogram monitors the electrical activity of the heart. The signal is a non-stationary biosignal, and its amplitude is in the millivolts order (1-10 mV) with an activity in a low-frequency range (0.5 -50) Hz. It is well known that ECG signals are commonly accompanied by different types of noise hindering the accuracy of ECG analysis (Alfaouri & Daqrouq, 2008). Several studies presented methods for minimizing the noise in ECG signals. Sörnmo & Laguna (2005) proposed some techniques for Power Line Interference (PLI) cancellation, such as linear and nonlinear filters, estimation-subtraction techniques and band-stop filters. Singh, Kumar, & Kumar (2014) denoised the ECG signal employing Discrete Wavelet (DWT), consisting of a set of threshold filters for PLI and BW interferences, and wideband stochastic noise. As metrics, they used the Mean Squared Error (MSE), SNR, and PRD, and better results were obtained applying the Daubechies and Symlet Mother Wavelet Transforms (MWT). Awal, Mostafa, Ahmad, & Rash (2014) used the DWT and the modified S-median thresholding technique, and as metrics the MITDB (Moody & Mark, 2001), MSE, RMSE, the improved SNR, and PRD. Results were good in the presence of Gaussian and color noise using a soft threshold, and results were moderate in the presence of wandering baseline line, artefact motion, and electrode movement. Overall, the ECG denoising process is a complex task due to the diversity of noises present in ECG signals, the low SNR values, the morphological changes in the ECG signals, different types of arrhythmias and the measurement in medical emergency conditions (Alfaouri & Daqrouq, 2008;Tompkins, 2000).
This work presents an experimental study on ECG signal denoising using the MITDB from Physionet (Goldberger et al., 2000). The filtering threshold is composed by a function and a value (Donoho, 1995). A set of experiments was conducted using a DWT with the MWTs (Daubechies and Symlet wavelets), a set of standard filtering threshold values (see Table 1), and threshold functions (see Table2). To the ECG records we added the noises muscles activity ("ma") and electrode-skin contact ("em") from the NSTDB (Moody & Mark, 2001), and the additive white Gaussian noise ("wn"), using appropriate software. SNR, MSE, RMSE, PRD and the Euclidian norm, also known as the L2Norm, were used as metrics. In the Materials and Method Section we presented the database, the Wavelet theory, the threshold functions and values, while the results and their performance using threshold benchmarks are presented and discussed in the Results and Discussions Section. Finally, the main findings are summarized in the Conclusions Section.

Databases
From MITDB, 10 ECG signals were analyzed in the experimental phase, namely 100, 102, 103, 105, 106, 117, 118, 121, 123 and 202. Their main characteristics are respectively a duration of 30 minutes, a sampling frequency of 360 Hz, an 11 bits resolution and a 680,000 samples length. In all cases the signals were modified with three types of noise, "ma", "em" and "wn", at SNR = 10 dB. Figure 1 shows the original ECG103 signal and the noise signals "ma", "em" and "wn", while Figure 2 depicts the ECG103 record with the three types of noises and their visual effects of signal deformation over the ECG signal.  Figure 2. ECG103 record segment with considered noises at a SNR of 10 dB: (a) "ma", (b) "em", and (c) "wn".
The inverse discrete wavelet transform (IDWT) is given by: where A is a constant that do not depend of x[n], and IDWT is the reconstructed signal (Addison, 2005).

Wavelet threshold theory
Wavelet denoising involves threshold filtering in which coefficients below a specific threshold value are set to zero. Two aspects must be considered, the threshold value ( ) and the threshold function (Wj). Table 1 shows some threshold functions, where Wj are the coefficients at decomposition j level; the α value is a real number which can be adjusted freely and depend on the results reached on the denoising process. Table 2 shows some of the threshold values (λ), where N is the signal length and some parameters are in the characteristics column. For the s-median threshold value, the parameter b value is defined by a set of values that vary according to the noise to be minimized (-113, -120, -122 and -86 for "wn", "ma", "em" and composite noises respectively; Awal et al., 2014).  (Donoho, 1995) Wj Figure 4 shows the general scheme of the analysis, in which it is shown that the ECG signals from MITDB pass through a preprocessing stage (PLI and BW minimization). The noises "ma", "em" and "wn" were added to partial ECG records. Then, DWT transformed the ECG signal into components being the result of passing the signal through respectively low and high pass filters in a decomposition stage. Thereafter, we selected the MWT and the depth level we want to arrive to minimize the noise frequencies. Ultimately, we tested the different threshold sets (function and values), and finally, the IDWT (re-composition stage) was applied to rebuild the total ECG signal.  (Donoho, 1995) λ j = σ j �2 log( ) σ j = median(|Wj|)/06745 Minimaxi (Donoho, 1995) λ  From the general scheme, we know the original signal x[n] and the noise signal q[n], variables expressed by the next expression.

xn[n] = x[n] + q[n]
( where x n[n] is the noise signal. Considering these variables, Table 3 shows the metric parameters used to measure the quality of the noise reduction. where xd[n] is the signal without noise.

Denoising process
Generally, the most common sources of noise are PLI, BW interference, motion artifacts, electrical and muscles activity ("ma"); instability of electrode-skin contact ("em") and white noise ("wn") (Tompkins, 2000;Georgieva & Tcheshmedjiev 2013). In our analysis noise was treated separately for PLI and BW as extrinsic noises, and the "ma", "em" and "wn" noises were treated as intrinsic noise. Table 4 shows the ECG proposed signal denoising algorithms. Table 4. ECG signal denoising process algorithm Step Description 1 The ECG signals are obtained from MITDB 2 PLI Identification (by using Fast Fourier Transform, FFT), BW interference identification by base line wandering. The "ma", "em" and "wn" identified as an ECG signal with distortions around its characteristics (see Fig. 1). 3 Apply the DWT and a selected MWT at corresponding level, to obtain the cA and cD coefficients. For PLI we minimized the cD coefficients at 2 nd level. For BW we minimized the cA coefficient at 8 th level. For the intrinsic noise, we minimized the cA coefficients at 7 th and 8 th levels and the cD coefficients at all levels. 4 Use a set of thresholds (function and value) to obtain the filtering coefficient. 5 Use the IDWT to obtain the denoised signal xd[n]. 6 Apply the metrics to find results. 7 Back to step 4 to select a new filter; repeat this until to complete the threshold set. 8 Back to step 3 to select a new MWT, repeat this until completing the MWT set. 9 Tabulate the data. 10 Choose the better results. Figure 5 shows the PLI minimization stage (PLI marked in red ellipse, middle signal), and its minimizing results (marked in red ellipse, lower signal). The best result obtained, was applying Symlet 8 at 2 nd level (MWT) and the process suggested in Table 4. Figure 6 shows a benchmarking between the threshold (value/function) set, sqtwolog/hard (sqt/h); minimaxi/hard (min/h); Georgeiva/hard (Geo/h) and sqtwolog/semisoft (sqt/semi). The results show that the threshold pair (min/h) has the higher SNR value (Figure 6a). Figure 6b depicts

BW minimization
BW interference is a low frequency signal, less than 1 Hz (Sörnmo & Laguna, 2005). Figure 7 shows the baseline wandering (red line) over the ECG103 register. We experimented with Daubechies and Symlet, mother wavelets. The best results were obtained was using the Symlet 8 at 8 th level and the process suggested in Table 4.  Figure 8a shows the BW minimization for the ECG103 record considering the use of a threshold set. The best result was obtained using the sqtwolog/soft combination (top figure); the red ellipse over the ECG signals shows the BW presence when we used the other threshold combinations. Figure 8b shows the benchmarking process for BW minimization of ECG 100, 102, 103, 105, 106, 202, 117, 118 119, 122 and 123 records (x axis). The L2N was respectively determined for the original signal and for the denoised signal obtained after application of the threshold combination. When the threshold with sqtwolog value and soft function were used (minimum distance, red signal) yielded the best results.
(a) (b) Figure 8. ECG103 BW minimization by using a threshold set, from top to bottom: sqtwolog/soft, minimaxi/soft, Georgeiva/soft and sqtwolog/semisoft (red ellipse shows BW interference). Figure 9a shows the ECG103 denoising results when we added ma noise at SNR=10 dB. We can see the signal morphology comparison between the denoising signals, where the best result was for the sqtwolog/hard threshold. These results in the bar Figure 9b shows the benchmarking where the SNR (highest), RMSE and PRD (lower) values when we used the sqtwolog/hard threshold.

Intrinsic noise minimization
(a) (b) Figure 9. ECG103 ma denoising using a set of thresholds: (a) signal comparison; and (b) metric benchmarking (normalized values). Figure 10a shows the ECG103 denoising results when the em noise was added at SNR=10 dB. This figure enables comparison of the signal morphology, and at naked eyes no substantial changes are observable. In the bar chart (Figure 10b), the benchmarking shows the SNR (heighted value) and the RMSE and PRD (lower values) for sqtwolog/hard threshold combination. For smedian/hard Revista semestral de la DIUC 113 https://doi.org/10.18537/mskn.09.01.10 combination, the morphology signal appears clearer. In generally terms we could said that all threshold combinations could help the process of removing this type of noise.
(a) (b) Figure 10. ECG103 em denoising using a set of thresholds: (a) signal comparison; (b) metric benchmarking. Figure 11a shows the ECG103 denoising results for wn noise at SNR = 10 dB. We can see the signal morphology comparison, where the first three combination methods (sqtwolog/hard, minimaxi/hard and Georgeiva/hard) could favorably assist in trimming noises. In the bar chart (Figure 11b), the benchmarking shows the SNR (highest values) for minimaxi/hard combination, and the RMSE and PRD (lower values) for sqtwolog/hard combination, and according the morphology of the signal the Georgeiva/hard combination give a clear signal. We could conclude that the three before mentioned approaches could be used to remove or minimized the considered types of noise.

CONCLUSIONS
The experimental study presented herein enables choosing the best combination of threshold values and threshold functions from DWT theory for the noise reduction of ECG signals using a proposed algorithm. We used ten ECG signals obtained from the MITDB and the noises from NSTDB, both database from Physionet. The method used treated the denoising process according to the noise characteristics. Extrinsic interferences, as PLI, were minimized using Symlet 8 at the 8 th level with a threshold using sqtwolog / hard combination (value and function), where the detail coefficients of the second level were minimized. BW was minimized using Symlet 8 at 8 th level with a threshold using sqtwolog / hard combination, where the approximation coefficients at the eighth level were minimized. For intrinsic noise minimization, the best results were obtained when we used the same mother wavelet, with a