Abstract
BACKGROUND:
Traditional least mean square algorithm (LMS) tends to converge faster and thus the larger the steady-state error of the algorithm.
OBJECTIVE:
In order to solve this issue, an improved adaptive normalized least mean square (NLMS) ECG signal denoising algorithm is proposed through utilizing the NLMS and the least mean square algorithm with added momentum term (MLMS).
METHODS:
The algorithm firstly performs LMS adaptive filtering on the original ECG signal. Then, the algorithm uses the relative error of the prior error signal and the posterior error signal before and after filtering to adaptively determine the iteration step factor. Finally, the expected error is set to determine whether the denoising meets the expected requirements. This method is applied to the MIT-BIH ECG database established by the Massachusetts Institute of Technology.
RESULTS:
Experimental results have shown that the proposed algorithm can achieve good denoising for the target signal, and the average signal to noise ratio (SNR) of the proposed method is 17.6016, the RMSE is only 0.0334, and the average smoothness index R is only 0.0325.
CONCLUSION:
The proposed algorithm effectively removes the original ECG signal noise, and improves the smoothness of the signal the denoising efficiency.
Introduction
The electrocardiogram is produced by the myocardium. It can be measured and acquired on the surface of the human skin. When the heart is abnormal, the heart cannot pump blood to the heart and provide enough blood to enter the body and brain. Since an electrocardiogram is a graphical record of electrical pulses produced by the heart, it is necessary to check the electrical activity of the heart when chest pain (such as a heart attack, shortness of breath, rapid heartbeat, high blood pressure, high cholesterol) occurs. Electrocardiogram (Electrocardiogram, ECG) signal is very sensitive, and different types of noise and interference will destroy the ECG signal. The main noises of ECG signals include electromyogram (EMG) interference, baseline drift and power frequency interference, which can lead to incorrect diagnosis of heart diseases. Therefore, it is a very critical issue to how to eliminate these noises and interferences from ECG signals.
Least Mean Square Algorithm (Least Mean Square, LMS) is an adaptive algorithm with a very simple principle and a very wide range of applications [1, 2]. This algorithm was first proposed by Widrow and Hoff in 1960. In the case of unknown input signal and expected signal characteristics, the weight coefficient at any time can be obtained by the proportional terms of the weight coefficient and the mean square error coefficient at the previous time. Because the algorithm is simple in principle, less computational complexity and strong stability, it is widely used in signal processing [3, 4, 5]. However, the convergence rate of the algorithm is inversely proportional to the steady-state error, which is the main problem of the LMS algorithm [6, 7, 8]. On the other hand, the overall convergence rate of the LMS algorithm is slow, which greatly affects the performance of the system. In order to overcome these problems, various improvements on the basis of the algorithm is presented. Among them, the normalized least mean square algorithm is one of the improvement schemes. This algorithm introduces a variable step factor to improve the relationship between convergence rate and stability error. However, the actual effect is not very satisfactory. Adjustment factors and correction coefficients is introduced based on the NLMS algorithm to improve the relationship between convergence rate and stability error [2]. However, the selection of the correction coefficient has become a problem for the algorithm, which is not adaptive.
In this paper, an improved adaptive NLMS denoising method for ECG signal was proposed, which improves the relationship between the convergence rate and stability, and enhances the adaptive ability of the algorithm, compared with the traditional algorithm. First, the original ECG signal is filtered by the adaptive LMS algorithm. Then the relative noise error of the ECG signal before and after filtering, and the iteration step factor of the algorithm is obtained. Finally, the expected error is set to determine whether the denoising meets the expected requirements. If not met, the LMS filtering process is performed again. Otherwise, the denoised ECG signals are obtained and outputted. Experimental results show that the denoising effect of the algorithm is superior to the traditional algorithm. The signal-to-noise ratio is higher, and the texture edges and characteristic waveforms of the original ECG signal are well preserved.
The rest of the paper is structured as follows. Section 2 presents the LMS and NLMS algorithms. In Section 3, the proposed adaptive algorithm for ECG signals is described in detail. Experimental results are shown and discussed in Section 4. Finally, Section 5 outlines the conclusions.
LMS and NLMS algorithms
LMS algorithm
Adaptive filtering is a technology that can automatically adjust performance to perform digital signal processing according to the characteristics of different signals. In recent years, adaptive filtering technology has been widely concerned and continuously developed. Adaptive filtering technology is currently widely used in communications, military, automation control, image and signal processing and other fields [9, 10, 11, 12]. The basic schematic diagram of an adaptive filter is shown in Fig. 1.
The LMS algorithm is an adaptive filtering standard algorithm. This algorithm is a gradient estimation method. That is, we do not need to understand the characteristics of the sampled signal and the expected output of the algorithm at the early stage of the algorithm. The weight vector of the previous moment plus a multiple of the negative mean square error gradient is equal to the weight vector of the current moment. The advantage of the least mean square algorithm is that the principle is relatively simple, the stability is strong, and the calculation efficiency is high [13]. The basic steps of the LMS algorithm are as follows:
Set variables and parameters as shown in Table 1. List of LMS algorithm parameter variables
Basic schematic diagram of the adaptive filter.
Initialization, assign value to
Input samples
Determine whether the output meets the conditions. If it meets, the algorithm terminates; if not, the algorithm returns to the previous step after updating
Next, we selected a pure ECG signal, and then added a randomly generated noise signal to the pure ECG signal. The ECG signals after LMS filtering are obtained as shown in Fig. 2.
LMS filter results in ECG signal.
It can be regarded as a special LMS algorithm through the analysis of the NLMS algorithm [14, 15]. The basic principle of the NLMS algorithm can be considered as normalizing the step size using the power of the tap input signal vector, which can speed up and improve the stability of the algorithm. At the same time, the iterative update of the algorithm is to remove the estimated power value of the sampled signal. Therefore, it can also effectively remove the increase in uncorrelated nuisance noise caused by the sampled signal being too large.
Structurally, both the NLMS filter and the LMS filter are transversal filters. The difference lies in the mechanism of the weight controller. The design criterion of NLMS filter is constrained optimization problem. Namely, the weight vector of the filter should change in the smallest way from one iteration to the next iteration, and subject to the constraints imposed by the new filter output. The basic steps of the NLMS algorithm are as follows:
Set
The value
where The NLMS algorithm replaces the consistent step factor with a variable step factor based on the LMS algorithm. And iteration equation is as follow.
Where
Similarly, we select a pure ECG signal, and then add a randomly generated Gaussian white noise signal to the pure ECG signal. The ECG signals after NLMS filtering are obtained as shown in Fig. 3.
NLMS filter results in ECG signal.
The step size of the traditional LMS algorithm is constant, and there is a contradiction between the convergence rate and the steady-state error. When the step size is small, the steady-state error of the algorithm is small, and the convergence rate of the algorithm is slow. When the step size is large, the algorithm is easy to get out of adjustment and poor stability although it has a fast convergence rate [16, 17, 18]. The NLMS algorithm is improved on the basis of the LMS algorithm. It is obtained by normalizing the step factor using the 2 norm of the input vector [19, 20]. However, the NLMS algorithm has the disadvantages that the steady-state error cannot be controlled and the multi-step step-down algorithm is too practicable. In order to solve these problems, a novel improved adaptive NLMS algorithm is proposed for ECG signals on the basis of the LMS and NLMS algorithms, utilizing combining their advantages and introducing momentum terms. Then the algorithm is applied to the denoising of the ECG signal, which overcomes the shortcomings of the original algorithm.
Improved LMS algorithm
In improved LMS algorithm, the step iteration factor
The weight vector is updated as:
Where
Where
The main idea of the algorithm is to use the last iteration error coefficient to determine the next iteration step size. The absolute value of
A dynamic factor is introduced in this paper to further improve the steady-state error and speed of the algorithm. The error mean square value of the prior error and the posterior error is used to adaptively determine the variable step size. First, the original ECG signal is filtered by the adaptive LMS algorithm. And then the relative noise error of the ECG signal before and after filtering is obtained, and the iteration step factor of the algorithm is adaptively acquired. Finally, the expected error is set to determine whether the denoising meets the expected requirements. If the requirements are not met, the LMS filtering process of the first step is performed again. Otherwise, the denoised ECG signals to be obtained are output. The steps of the algorithm are as follows.
The weight vector is modified as:
Where, the value of
The step iteration can be obtained based on Eq. (13), that is:
Where
The selection of the step
Where the choice of
The flowchart of the improved adaptive NLMS algorithm for denoising ECG signals is shown in Fig. 4.
Flowchart of the improved adaptive NLMS algorithm for denoising ECG signals.
Improved adaptive NLMS filter results.
The algorithm in this paper is performed on the pure ECG signal after adding a period of random noise. The simulation results are shown in Fig. 5.
From Fig. 5, we can see that the noise signal is well removed after using the proposed algorithm in this paper. The remaining signal basically retains all the features of the original signal, compared with LMS and NLMS algorithms. The proposed algorithm has obvious advantages over the other two algorithms.
In this paper, the algorithm experiment hardware environment is a common desktop computer, which is mainly configured as intel i5, 3.6 GHz, and 32 GB memory. The software environment is Windows 7 x 64, and the simulation running tool is MATLAB 2016a.
Evaluation metrics
Since the current ECG signal denoising field has not formed a unified evaluation, the proposed algorithm uses root mean square error (RMSE), signal to noise ratio (SNR) and smoothness index (R) three objective values to evaluate the performance of denoise the ECG signal. The specific calculation method is as follows:
Where
In order to verify that the proposed improved NLMS algorithm is superior to the previous LMS, NLMS and improved LMS algorithms in denoising performance, seven sets of ECG signals are selected in the MIT-BIH ECG database established by the Massachusetts Institute of Technology. We compare the proposed algorithm in this paper with the LMS algorithm, NLMS algorithm and improved LMS algorithm on the above three evaluation indexes. The experimental results are shown in Table 2.
Comparison of RMSE and SNR of four algorithms in different ECG signals
Comparison of RMSE and SNR of four algorithms in different ECG signals
It can be seen from the comparison results in Table 2 that the proposed algorithm has the highest the signal to noise ratio on Data No. 122 and Data No. 234, reaching 18.9632 and 18.8534 respectively. On average, the proposed algorithm is 33%, 15%, and 5% higher than the LMS, NLMS, and improved LMS algorithms in SNR. Compared with the LMS, NLMS and improved LMS algorithms in the root mean square error, the proposed algorithm is reduced by 31.1%, 5.1%, and 3.2% on average. Combining the two evaluation indexes of RMSE and SNR in different ECG signals, the proposed algorithm can achieve better denoising effect than others. This happens because the proposed algorithm adds a normalization step to the LMS algorithm to make the algorithm’s step size flexible. Meanwhile, the algorithm in this paper is improved on the basis of the NLMS algorithm, and a new step iteration factor selection method is introduced to make the algorithm flexible and simple, and the calculation is more convenient. To intuitively see the advantages of this algorithm and the remaining three algorithms in RMSE and SNR on different ECG signals by the various algorithms, Fig. 6 shows the comparison results of LMS, NLMS, improve LMS, and the algorithm in this paper.
Comparison of the four algorithms in different ECG signals. (a) RMSE and (b) SNR.
In order to further verify the validity of the proposed algorithm, evaluation index R is selected to compare LMS, NLMS, improve LMS algorithms with the proposed algorithm in different ECG signals, which can reflect the smoothness of the denoising signals. The experimental results of the smoothness index R in different ECG signals are listed in Table 3 and shown in Fig. 7.
Comparison of smoothness index R for four algorithms in different ECG signals
Comparison of the four algorithms in the smoothness index R for different ECG signals.
Original ECG signal.
ECG signal after denoising.
It can be seen from the comparison results in Table 3 that the proposed algorithm has the better performance in smoothness index R for different ECG signals. On average, the proposed algorithm is 34.2%, 25%, and 16.3% lower than the LMS, NLMS, and improved LMS algorithms in R. In particular, the proposed algorithm is not much different in SNR and RMSE compared with improve LMS (SNR is only higher than 5%, and RMSE is only reduced by 3.2%), but it is significantly better than the improved LMS in smoothness index R. These indicate that the proposed algorithm has a better denoising effect on various different ECG signals. Figure 7 shows the intuitive comparison results of LMS, NLMS, improve LMS, and the proposed algorithm in the smoothness index R, which can better see the advantages of our algorithm compared to other algorithms.
Combining the three evaluation indexes of RMSE, SNR and R in different ECG signals, the proposed algorithm can perform better in denoising ECG signal and provide an effective basis for ECG signal denoising.
To further visualize the denoising effect of the algorithm in this paper, the proposed algorithm is applied to the ECG signal Data No. 100 in the MIT-BIH ECG database for visual analysis. The original ECG is shown in Fig. 8.
The original ECG signal is denoised using the improved adaptive NLMS algorithm in this paper. The denoised waveform is shown in Fig. 9.
From the comparison results of Figs 8 and 9, we can clearly see that the edge of the signal waveform texture after denoising becomes smoother. Moreover, the effective characteristics of the original signal are well preserved. These subjective results also show that the proposed algorithm has a good denoising effect.
Conclusions
In this paper, an improved adaptive NLMS algorithm is used to effectively solve the contradiction between the convergence rate and the steady-state error of the traditional algorithm. By analyzing the theoretical basis for the time-varying step factor with the input signal, a new method is proposed for acquiring adaptive iterative step factor. Then the adjustment factor and the relative error between the prior error signal and the posterior error signal are introduced to adaptively determine the iteration step factor. Finally, this algorithm is applied to the different ECG signals. Experimental results show that the proposed algorithm can effectively remove a variety of noise signals in the ECG signal, and RSME, SNR and smoothness index R are significantly improved compared with other algorithms. Meanwhile, the proposed algorithm also retains the characteristics of the original signal waveform, and improves the signal to noise ratio of the signal and the smoothness of the signal waveform.
Footnotes
Acknowledgments
This work was supported by the Natural Science Foundation of the Anhui Higher Education Institutions of China (Grant No. KJ2019A0162), the Natural Science Foundation of Anhui Province, China (Grant No. 1708085MF154), and the Open Research Fund of Anhui Key Laboratory of Detection Technology and Energy Saving Devices, Anhui Polytechnic University (Grant No. DTESD2020B02).
Conflict of interest
None to report.
