Denoising Ambulatory Electrocardiogram Signal Using Interval-Dependent Thresholds-based Stationary Wavelet Transform

— Noise contamination in electrocardiogram (ECG) monitoring systems can lead to errors in analysis and diagnosis, resulting in a high false alarm rate (FAR). Various studies have been conducted to reduce or eliminate noise in ECG signals. However, some noise characteristics overlap with the frequency range of ECG signals, which occur randomly and are transient. This results in shape alteration and amplitude reduction in P and R waves. The author proposed a framework for eliminating noise in ECG signals using the stationary wavelet transform method and interval-dependent thresholds (IDT) based on the change point detection method to address these challenges. The proposed framework decomposes the input electrocardiogram (ECG) signal at a specific level using the Stationary Wavelet Transform method, resulting in detail and approximation coefficients. Interval detection focuses on the initial detailed coefficient, d1, chosen due to its significant content of noise coefficients, especially high-frequency noise. Subsequently, threshold values are computed for each interval. Hard and soft thresholding processes are then applied individually to each interval. Finally, reconstruction occurs using the inverse stationary wavelet transform method on the threshold coefficient outcomes. Two measurement matrices, root mean square error (RMSE) and percentage root mean squared difference (PRD), were used to measure the performance of the proposed framework. In addition, the proposed framework was compared to stationary wavelet transform (SWT) and discrete wavelet transform (DWT). The test results showed that the proposed method outperforms DWT and SWT. The proposed framework obtained an average increase in RMSE scores of 18% and 45% compared to the SWT and DWT methods, respectively, and PRD values of 17% and 37% compared to the SWT and DWT methods, respectively. So, using IDT in the stationary wavelet transform method can improve the denoising performance. With the development of this new framework for denoising ECG signals, we hope it can become an alternative method for other researchers to utilize in denoising ECG signals.


I. INTRODUCTION
In 2016, the World Health Organization (WHO) reported that cardiovascular disease (CVD) emerged as the leading cause of global mortality [1].WHO indicated that approximately 17.9 million individuals, constituting about 31% of global fatalities, succumb to CVD annually.A significant majority, exceeding 75%, of CVD-related deaths occur in lower-middle-income countries, including those within the Asian region.Indonesia, specifically, experiences heart disease as the primary contributor to mortality.WHO's 2016 data underscores that 35% of the nation's total deaths, amounting to 1.8 million people, are attributed to heart disease.
A primary instrument for identifying heart disorders is the electrocardiogram (ECG), which captures the heart's electrical activity.These ECG readings offer crucial clinical insights into the heart's health.Examining the ECG waveform is vital in the early detection of cardiac illnesses.The ECG waveform includes critical waves such as the P wave, QRS complex, T wave, and U wave.Fig. 1 illustrates the typical reference points and the clinical characteristics of the ECG waveform.
Generally, ECG signals have a frequency range of 0.05 Hz to 150 Hz and a resulting potential of 0.05 mV -40 mV [2].This small frequency range causes the ECG signal to be susceptible to noise.The noise usually occurs during the acquisition and transmission process, so the analyzed ECG signal data is not the original data, but ECG signal data contaminated with noise.together with their clinical features [3] Several types of noise commonly cause ECG signal contamination, including Power Line Interference (PLI), Baseline Wander (BW), Muscle Artifact (MA), Electrode Motion (EM), and instrumentation noise [4].BW has rising and falling waves and is not consistently on the isoline or zero line.This makes it difficult to detect the peak of the R wave precisely because the T wave may have a height that exceeds the R wave so that we can detect it as an R wave.BW has a frequency that varies between 0.15 -0.3 Hz.PLI is noise caused by the power line, which causes the signal rhythm to rise and fall and harmonize, which we modeled as sinusoidal and sinusoidal combinations.The characteristics of this type of noise are at a frequency of 50/60 Hz with harmonics and an amplitude of 50% from the peak-to-peak amplitude of the ECG signal.MA is noise caused by the electrical activity of the body muscles.The standard deviation of this type of noise is 10% of the peak-to-peak ECG amplitude with a duration of 50 ms and a frequency from 20 Hz to 10 kHz.EM is the most troublesome noise because it can mimic the appearance of an ectopic beat and cannot be removed easily using a simple filter, like other types of noise [5], [6], [7], [8].These changes usually occur due to shaking or movement from the patients.This noise occurs for 100-500 ms, and the resulting amplitude is 500% of the ECG amplitude.Therefore, this study focused on the EM denoising.The frequency content of this noise often overlaps with the frequency of the ECG signal.Moreover, the noise also resembles the ECG signal's morphology.When the ECG signal is contaminated with this noise, it is almost impossible to carry out morphological and spectral analysis of the ECG signal.
Research indicates that current ECG analysis systems often yield imprecise and unreliable readings, resulting in a high frequency of false alarms [5], [6], [7], [8].These false alarms are not only disruptive for healthcare professionals and patients, but they can also lead to misdiagnosis.The prevalence of these false alarms significantly undermines the real-time effectiveness of ECG monitoring systems.The root cause of this issue can be attributed to two primary factors.Firstly, the presence of noise and artifacts in the ECG's isoelectric line leads to the misinterpretation of these interferences as normal or abnormal heartbeats.Secondly, the contamination of ECG signals with noise or artifacts results in erroneous classification due to the inaccurate assessment of the ECG's feature parameters.To enhance the accuracy of analysis and diagnosis, it is crucial to either eliminate or sufficiently filter out the noise present in ECG signals.
Research on noise removal is not new.However, even though researchers have carried out this research for a long time, the problem of noise in the ECG signal still needs to be fully resolved.This is due to the high challenges in solving noise problems in ECG signals.Several recent studies have continued to emerge by proposing new methods or modifying previous methods to overcome their limitations.So various new techniques are developed to eliminate or reduce noise.Those methods are based on adaptive Fourier decomposition, Fourier transform, wavelet transform empirical mode decomposition, stationary wavelet transform, and hybrid.
Several studies, such as [9], [10], and [11], have used the Adaptive Fourier Decomposition (AFD) method to eliminate noise in ECG signals.The study referenced as [9] utilized the AFD technique as an alternative to the conventional Fourier decomposition approach, which transforms a signal from its time-domain representation into a frequency-domain format.In this research, signal decomposition is based on energy distribution.This method is suitable for separating ECG signals and noise whose frequencies overlap but have different energy distributions.Research conducted by [10] proposed the use of AFD for denoising and R peak detection at the same time.In the study, the R peak and noise reduction were carried out by extracting the R wave from the energy domain using AFD and determining the location of the R peak based on the critical parameter components.One of the difficulties of this method is determining the R wave from the decomposed signal in the energy domain of the decomposed ECG noise signal.Research [11] aimed at reducing motion artifacts in mobile ECG applications.In this investigation, a procedure involving a series of three progressive adaptive noise filters was adopted.These filters are founded on the minimal mean square error principle and utilize a technique for estimating noise references.The limitation of this method is the need for a reference noise in the denoising process so that if the reference noise used cannot represent the original noise, it can reduce the denoising results.
In a DWT-based study, research by [12] removed motion artifact noise in ECG signals using the DWT method and independent component analysis (ICA).The DWT method decomposes the signal, while the ICA method detects whether the coefficient is noise.In the noise coefficient area, the HPF method with a cutoff of 5 Hz is used.Then the reconstructed signal is subjected to LFP with a cutoff frequency of 50 Hz to eliminate high-frequency noise.The authors performed denoising using the DWT method.They tested the mother wavelet parameters, decomposition level, algorithm thresholding, and best thresholding selection to eliminate BW, EMG, and PLI noise.
The subsequent study uses Empirical Mode Decomposition (EMD).One of the advantages of this method is that signal decomposition is running in the time domain, so it does not require transformation to another domain [13].Several studies have developed denoising methods based on EMD, such as in studies [14], [15], [16].Study [14] combines the EMD with Riemann-Liouville (RL) fractional integral filtering and Savitzky-Golay (SG) filtering.The IMF performs filtering with the result of EMD decomposition to remove high and low-frequency noise.RL filters the high-frequency, and SG filters the low-frequency.The SG method immediately applies to the IMF, which contains low-frequency noise.Furthermore, the IMF, which does not contain low-frequency noise, will be re-detected to find out whether high-frequency noise is present.IMF detected as high-frequency noise will use the RL filtering method.The disadvantage of this method is its slow computation time due to several stages of detection on the IMF and several stages of filtering.Research [15] combines multiple EMDs to eliminate noise called Ensemble Empirical Mode Decomposition (EEMD).EEMD aims to decompose the signal adaptively.At the same time, Kurtosis criteria guide the selection of IMF with noise.The selected IMF will conduct thresholding.
The following study [16] is almost similar to the previous research.To reduce computation time, only the first three IMFs are used.However, this becomes a weakness because only the first three IMFs accumulate the noise.This method also requires information on the R-peak position, making it unsuitable for real-time applications.The study [17] refers to combining multiple EMD to eliminate noise as Ensemble Empirical Mode Decomposition (EEMD).Unlike the regular EMD method that eliminates the first intrinsic mode function (IMF1), assuming it has a high noise concentration, this method applies soft thresholding based on wavelets to the EMD decomposition results.Then it improves the signal using the ASMF method.The drawback of this method is its high time complexity since it uses multiple methods.
Apart from methods based on AFD, DWT and EMD, there are other studies based on SWT method, such as in research [4], [18], [19], [20].Nagai's research [18] removed motion artifact noise using the SWT method.The SWT method decomposes ECG signals because it has a time-invariant wavelet transform property.Furthermore, on the detail coefficient, QRS complex detection is carried out based on the power of the detail coefficient.The coefficient detail (D1-D), which contains the QRS complex, is zero for T waves detected from the detail coefficient D5-D7.Based on the test results, the median correlation coefficient increased from 0.61 to 0.84.Then in a follow-up study [19], Nagai used energy and periodicity to detect the QRS complex.It can increase the median value of the correlation coefficient to 0.88.The study [20] compared several methods, namely SWT, DWT, EMD, EEMD, and CEEMDAN, to eliminate adaptive white Gaussian noise (AWGN).The test results showed that the SWT method is superior to the other four methods.In comparison, research [4] compared the low pass filter (LPF), SWT, DWT, EMD, and Fourier decomposition method (FDM) methods.The SWT method is also superior to other methods based on the test results.
Recent research by [21] proposed a hybrid approach to eliminate noise in ECG signals.The ECG signal is decomposed with a series of decomposers, such as EMD, EEMD, DWT, and SWT, and the decomposed signal is subjected to the NLM method to eliminate noise.Then the decomposed signal filtered by the NLM method is reconstructed to get a clean ECG signal.The test results showed that the EEMD and NLM hybrid methods are superior to other methods, with the highest SRN value of 13.95 dB.This section describes the test.First, we describe the dataset used.Then, we describe the evaluation matrix used to measure the performance of the proposed framework.Finally, we describe the implementation environment of the proposed framework.
In general, the proposed methods perform well in reducing noise and artifacts with different morphological and spectral characteristics from the morphology and spectral characteristics of the ECG signal.However, the evaluation shows that eliminating baseline wander can distort the ST segment.This is due to the attenuation of the low-frequency component of the ECG signal [22].
The method most widely used to remove noise in ECG signals is a wavelet transform-based method [4], [23].The wavelet transform-based approach eliminates the noise coefficients while retaining the ECG signal information coefficients.Donoho [24] is the first to introduce this approach called wavelet shrinkage.In this technique, the selection of the threshold value is crucial.Therefore, Donoho and Johnston [25] have proposed thresholding schemes, namely minimax and universal thresholding.Among these two schemes, universal thresholding is the most widely used for denoising.Universal thresholding generates a fixed threshold value.However, in practice, the variance of the noise signal varies.Therefore, different variance values exist for various time intervals, so the threshold values must differ for each time interval in the signal [26].
To resolve these problems, several researchers [26], [27], [28], [29], [30] apply interval-dependent thresholds (IDT).In research [26], white Gaussian noise was removed from the sine signal.In this study, the threshold value calculation on the universal thresholding rule considers the variance value of the noise as a constant value for different time intervals.The study [27] found that dividing the gamma-ray signal into three intervals is possible.Among the three intervals, 1 and 3 have high frequency, while the second part has low-frequency noise.Detailed descriptions include each calculated interval's mean, standard deviation, and other details.Research [28] performed noise cancellation on measured transient signals.
Instead of using a fixed threshold value for each level, researchers use different threshold values for each level and interval.Based on the test results, the proposed method performs better than the multivariate denoising technique.Research [29] required proper noise cancellation to achieve accurate navigational information regarding position, speed, acceleration, and direction.Based on this, the researchers propose an algorithm to help accurately calculate position, speed, or distance using signals obtained from the MEMS inertial navigation system.Research [30] proposed developing a wavelet package-based method for signal denoising.Several changes were made to the wavelet package denoising method using node-dependent noise estimation and IDT.
Based on these studies, the IDT approach can improve the performance of the wavelet transform-based denoising method.Regardless of the success, the number of intervals and each interval's starting and ending points are fixed.The number of intervals and each interval's starting and ending points are obtained based on the observations.It is difficult to do with the ECG signal's noise, which appears randomly and transiently.This means that each interval's fluid from the starting to the ending points indicates that the whole gammaray signal is a fixed interval.
So, this research proposes a framework for eliminating noise in ECG signals using the stationary wavelet transform method and interval-dependent thresholds based on the change point detection method.In the proposed framework, the input ECG signal is decomposed at a certain level using the SWT method in detail and approximation coefficients.Interval detection is carried out on the first detailed coefficient d1.This is because, in detail, coefficient d1 contains most noise coefficients, especially high-frequency noise.So, the interval of noise occurrence is easy to detect in the detailed coefficient d1.Then, the threshold value is calculated for each interval to obtain several threshold values.This differs from the standard SWT method, which produces only a threshold value.Next, the thresholding process is carried out at each interval using hard and soft thresholding.Finally, reconstruction is carried out on the thresholding coefficient results using the inverse stationary wavelet transform method.The main contributions of this research are as follows:  A new framework is proposed to eliminate the noise of muscle artifacts in ambulatory ECG signals using the stationary wavelet method with interval-dependent thresholds, which are detected adaptively using the CUSUM method. A change point detection algorithm is implemented to efficiently and effectively detect intervals of electrode motion artifacts so that a threshold value can be calculated adaptively. The proposed method is capable of suppressing QRScomplex-like electrode motion artifacts.The remainder of this article is organized as follows.Section 2 explains various related studies regarding noise removal in ECG signals.Then the proposed method to overcome the shortcomings of existing process is described in section 3. The proposed method is tested, the results and analysis are presented in chapter 3. Finally, the conclusions and future work are explained in section 4.

II. MATERIALS AND METHOD
Overall, the proposed framework consists of a signal decomposition process, detection of change points to determine the interval's starting and ending points, calculation of the variance noise estimation sigma, calculation of the threshold value, thresholding, and signal reconstruction.Fig. 2 shows the block diagram of the proposed framework.Fig. 3 SWT 4 levels decomposition of a signal using the Mallat algorithm [12].h is an HP filter, and g is an LP filter.
states the approximation coefficient and states the detail coefficient

A. Decomposition
SWT bears a resemblance to the discrete wavelet transform, involving the application of high and low-pass filters to the input signal at each decomposition level.However, in SWT, both the high and low-pass filter outputs undergo subsampling and decimation [23].The input signal has a length , where N is a multiple of 2 (where 2 for some integer ).The low-pass and high-pass filters are denoted as ℎ and .During the initial stage of SWT, the convolution of the input signal with ℎ yields the approximate coefficient, while convolution with results in the detail coefficient, as outlined in equations 1 and 2. * (1) Due to the absence of subsampling, the lengths of the approximation coefficient and the detail coefficient are equivalent to the length of the input signal, denoted as N.In the subsequent stage, the approximation coefficient is employed to generate and by convoluting them with modified versions of the high-pass filter and low-pass filter ℎ .This iterative process persists until it reaches the targeted decomposition level, as illustrated in equations 3 and 4. *

B. Change Point Detection
It has been explained that the occurrence of noise is random and transient.It causes a different noise variance throughout the ECG signal.This phenomenon is called non-homogeneous variance noise [31].The strategy to overcome this situation is to track changes in the variance of the noise signal and perform IDT.A uniform statistical property, such as the mean or variance, characterizes an interval.This study applied the change point detection method by Mark Levielle [32], [33].In determining two intervals, select a point ! a signal with length and divide the signal into two segments, namely , , … , " and " , " , … , # as shown in Fig. 4. For every point within a segment, assess the extent of variance of the characteristic from the average.Sum up these variances for all points.Accumulate the variances from each segment to compute the aggregate amount of the overall residual error $.Adjust the position of the dividing point until the aggregate amount of the residual error $ is at its lowest.Equation 5illustrates calculation of the total residual error value $ with one changing point.
We can generalize these results to include other statistics as shown in equation 6.
Minimizing the total residual error value is the same as maximizing the log likelihood.If the variance value changes, the average value remains, and the function uses equation 7.

C. Interval Dependent Thresholding
The steps of denoising algorithm using hard or soft thresholding are as follows.In the first step, the wavelet transform decomposes the input ECG signal into a detail coefficient and an approximate coefficient of level.Based on the results of the detection of the point of change, if, for example, a interval, then the calculation of the variance 7 ?.The popular variance noise estimation 7 ?was proposed by Donoho and Johnstone [34].In the calculation, the variance noise estimation 7 ?value is obtained based on the median absolute deviation from the first level coefficient detail.In calculating the variance noise estimation 7 ?value, the denominator value is a scale factor whose value depends on the (, distribution which is estimated to be around 0.6745 for normally distributed data as shown in equation 8, (, is the detail coefficient on the interval and level.The threshold value F is calculated using equation 9: F (, is the threshold value at the interval and the level.is number of samples.Then for thresholding calculations for both hard and soft thresholding shown in equations 10 and 11, respectively, the value of H (, is the detail coefficient of thresholding results at the interval and the level.

D. Reconstruction
To recover the original signal, the threshold wavelet coefficients undergo the inverse wavelet transformation.The formula for reconstructing a single-level wavelet transform is provided in equation 12 [35], where ′ and ℎ′ represent the double bases of and ℎ, respectively. ,3

III. RESULTS AND DISCUSSION
This section explains testing and analysis of test results.First, we describe the dataset used, the evaluation matrix used to measure the performance, implementation environment, and test results.

A. Datasets
The type of data used is secondary data.The ECG dataset for testing uses a benchmark database, which helps perform denoising performance measurements.The first database is the MIT-BIH Arrhythmia Database (MITDB) [36], which comprises 48 records from 47 subjects with a 360 Hz sampling rate and 11 Bit resolution.The second is the MIT-BIH Noise Stress Test Database (NSTDB) [37] which produces the data from recordings 118 and 119 from the MIT-BIH Arrhythmia Database by adding 'motion noise' at different noise levels.This database consists of 12 ECG recordings for 30 minutes each.In addition, there are also 3 noise signals with a duration of 30 minutes each.We obtained noiseless ECG signals from two clean signal recordings from the MITDB database (Records 118 and 119).Each recording is segmented every 10 seconds, so there are 360 segments.Total segments for all records 360 * 12 = 4320 segments.The noise levels that contaminate the clean ECG signal are -6 dB, 0 dB, 6 dB, 12 dB, and 24 dB.

B. Test Parameter Setting
The test settings carried out in this study are the same as testing the noise removal method based on the wavelet transform method.The parameters that affect the performance of the wavelet transform-based noise reduction method are the type of mother wavelet, decomposition level, thresholding schema, and thresholding selection.Table I shows the value of each parameter used in the test.

C. Test Design
The first test is to use different types of mother wavelets and decomposition levels.The second test is the number of charging points, and the third test compares with other current state-of-the-art methods, namely SWT [4] and other standard methods used for denoising, namely DWT [12].
1) Testing the type of mother wavelet and decomposition level.This test aims to see the effect of choosing the mother wavelet and decomposition level.Calculating the RMSE and PRD values measures the effect.Meanwhile, the values of other parameters, namely threshold scheme, threshold selection, and the number of change points, are fixed: hard, sqtwolog, and one respectively.
2) Testing the number of intervals.The third test aims to see the effect of the number of intervals on the wavelet coefficient.The parameters from test 1, which have the best PRD and RMSE values, are used.

3) Comparison of the performance of the usual framework.
The fourth test compared the proposed method with the stateof-the-art denoising method on ECG signals, namely the stationary wavelet transforms.In addition, the proposed method is also compared with a widely used method for noise removal, namely the discrete wavelet transforms.

D. Implementation Environment
The previous stage is designing and implementing the denoising framework in the MATLAB programming language using digital signal processing libraries such as the signal processing toolbox and wavelet toolbox.The noise reduction framework's implementation uses hardware and software, as Table II shows.

E. Performance Measurement
There are two performance measurement parameters commonly used by researchers ( [9], [17]) to assess the performance of noise reduction methods: root mean square error (RMSE) and percent root mean square difference (PRD).The RMSE measures the variance between the denoised and noise-free signals and the PRD parameter to measure the quality of the signal recovery.The RMSE equation and The PRD equation are in 13 and 14 successively.
In equations 13 and 14, J represents the noise-free ECG recording, and ?J represents the denoised signal.

F. Test Results for Mother Wavelet Types and Degree of Decomposition
In this first test, five types of mother wavelets were used, namely haar, db, coif, sym, and bior.In total, there are 40 types of mother wavelets.Meanwhile, the decomposition level ranges from 2 to 6.The signal used in this first test is the 118e12 signal, with 360 segments for 10 seconds each.This test aims to determine the mother wavelet type and the optimal decomposition level for denoising the ECG signal.Fig. 6 shows the average RMSE value for the mother wavelet and decomposition level.As shown in the figure, mother wavelet bior3.1 and decomposition level 3 have the optimum RMSE average value.Fig. 7 shows the average PRD values for mother wavelets and decomposition levels.The figure shows that the mother wavelet bior3.1 and decomposition level 3 yield the optimum average PRD value.Based on this test, we selected mother wavelet bior3.1 and decomposition level 3 for further testing.

G. Results of Testing the Number of Intervals
The optimum number of intervals for all signal segments is examined again in this test.It is due to the onset of random and transient noise.The number of intervals used in this test ranges from 2 to 5.This test determines the optimum number of intervals for all test signal segments.Table III shows the test results using intervals ranging from 2 to 5. Based on this table, the algorithm generally obtains the best value at 2 intervals.The average RMSE value shows the best results at 2 intervals obtained at 9 recordings and interval 4 obtained at 1 recording.In contrast to the average PRD value, interval 2 obtained the best results on 9 recordings, interval 3 on 2 recordings and interval 4 on 1 recording.Based on this, the number of intervals used is 2 intervals.So, most of the test signals have 2 different intervals.

Fig. 1
Fig. 1 Standard fiducial points of ECG signals (P, Q, R, S, T, and U wave)together with their clinical features[3]

Fig. 4
Fig. 4 Calculation of the total residual error on a signal with 1 change point, namely

Fig. 5
Fig. 5 illustrates the outcomes of change point detection at two intervals and three intervals.The figure indicates that the intersection points in the two-interval case occur at sample 1500.In contrast, for the three-interval scenario, the change points are identified at sample 730 and sample 1500.Notably, an additional change point emerges in the first interval in Fig. 5 (a).This is attributed to the presence of two distinct areas with varying variance values within the first interval.

Fig. 5
Fig. 5 Example of detection results on detail coefficient > a. 2 intervals and b. 3 intervals

Fig. 6
Fig. 6 Average RMSE values for different mother wavelets and decomposition levels

TABLE I LIST
OF TEST PARAMETERS AND THEIR VALUE

TABLE III TEST
RESULTS OF CHANGE POINT NUMBERS ON RMSE AND PRD VALUE