A DR-RLS method and system for ECG filtering
The DR-RLS method is used to reuse data within a specific interval, adjust the α(n) range and the number of data reuses, solve the overshoot problem of the RLS algorithm in ECG filtering, improve the filtering performance and reduce the computational complexity.
Patent Information
- Application Number
- CN202310329952.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-30
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-03-30
AI Technical Summary
The traditional RLS algorithm has an overshoot phenomenon in the initial stage of ECG filtering, which affects the filtering quality.
The data reuse recursive least squares (DR-RLS) method is used to optimize the filter performance by reusing data in a specific interval, adjusting the range of α(n) to (0.1, 0.98), avoiding the area near the R wave, using the number of data reuses N=4, combining the forgetting factor λ and the Kalman gain vector.
The overshoot phenomenon of the RLS algorithm is effectively suppressed, the filtering performance is improved, the computational complexity is reduced, the characteristic waveform of the ECG signal is maintained, and the signal-to-noise ratio and correlation coefficient are improved.
Smart Images

Figure CN116269418B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical signal processing, and in particular to a DR-RLS method and system suitable for ECG filtering. Background Art
[0002] Electrocardiograms (ECGs) have become an important source of information for the diagnosis and prevention of cardiovascular diseases (CVDs). They can help patients identify the type of disease and prevent various sudden cardiac illnesses. Various diseases, including myocarditis and myocardial infarction, can be monitored by ECGs [1-4]. ECG signals are bioelectric signals that carry a wealth of pathological information. Therefore, when various cardiovascular diseases occur, patients' ECGs will show various abnormal characteristics.
[0003] Adaptive filters [5] are widely used in different fields such as recognition, signal separation, and denoising. They do not need to know the spectral characteristics of the noise and are more suitable for eliminating MA noise that overlaps with the ECG signal component spectrum. Seol et al. [6] have proven that RLS adaptive filtering has a better filtering effect in wearable device ECG filtering. However, the RLS algorithm also has defects, such as Figure 1 As shown in Figure 2, simulations have verified that RLS adaptive filtering will experience an overshoot after L iterations in the initial stage [7], which will destroy the output waveform of the filter and the estimated trace tr of the inverse covariance matrix of the input signal will also change dramatically.
[0004] The traditional adaptive filter application structure uses a pure signal as the reference signal. However, in practical situations such as ECG acquisition, since a pure signal cannot be obtained, various filter structures based on the RLS algorithm have evolved. Adaptive filters with this type of structure are often more practical and have been widely used [8][9]
[10] . However, different structures will cause the filter to exhibit different characteristics.
[0005] References
[0006] [1] M.Adam, SLOh, VKSudarshan et al., "Automated characterization of cardiovascular diseases using relative wavelet nonlinear features extracted from ECG signals," Computer Methods and Programs in Biomedicine, vol.161, pp.133-143, Jul, 2018.
[0007] [2]C.K.Jha,and M.H.Kolekar,“Electrocardiogram Data Compression Techniques for Cardiac Healthcare Systems:A Methodological Review,”Irbm,vol.43,no.3,pp.217-228,Jun,2022.
[0008] [3]P.Li,Y.Hu,and Z.-P.Liu,“Prediction of cardiovascular diseases byin tegrating multi-modal features with machine learning methods,”BiomedicalSigna l Processing and Control,vol.66,Apr,2021.
[0009] [4]L.Xie,Z.Li,Y.Zhou et al.,“Computational Diagnostic TechniquesforElectrocardiogram Signal Analysis,”Sensors,vol.20,no.21,Nov,2020.
[0010] [5]B.Widrow,J.R.Glover,J.M.McCool et al.,“Adaptive noise cancelling:Principles and applications,”Proceedings of the IEEE,vol.63,no.12,pp.1692-1716,1975.
[0011] [6]T.R.Seol,S.H.Lee,and J.H.Lee,“A Wearable ElectrocardiogramMonitoring System Robust to Motion Artifacts,”IDEC Journal of Integrated Circuits and Systems,vol.7,no.1,pp.1-5,2021,2021.
[0012] [7] Ma Guodong, Yan Shutian, He Chengzhu et al., “Adaptive filtering and simulation analysis based on LMS algorithm and RLS algorithm,” Electronic Design Engineering, vol. 22, no. 06, pp. 43-45+49, 2014.
[0013] [8]WCLee,Y.Yang,TCKe et al., "Adaptive reduction of motion artifact in a portable ECG system."
[0014] [9] L.Xu, C.Rabotti, YJZhang et al., "Motion-Artifact Reduction in Capacitive Heart-Rate Measurements by Adaptive Filtering," Ieee Transactions on Instrumentation and Measurement, vol.68, no.10, pp.4085-4093, Oct, 2019.
[0015]
[10] J.Ding, Y.Tang, R.Chang et al., "Reduction in the Motion Artifact sin Noncontact ECG Measurements Using a Novel Designed Electrode Structur e," Sensors (Basel, Switzerland), vol.23, no.2, 2023Jan, 2023.
[0016]
[11] J.Benesty, and Y.Huang, "Adaptive signal processing: applications toreal-world problems," 2003.
[0017]
[12] C.Paleologu, J.Benesty, and S.Ciochina, "Data-Reuse Recursive Least-Squares Algorithms," Ieee Signal Processing Letters, vol.29, pp.752-756, 2022. Summary of the Invention
[0018] The present invention addresses the deficiencies of the prior art and provides a DR-RLS method and system suitable for ECG filtering.
[0019] In order to achieve the above object of the invention, the technical solution adopted by the present invention is as follows:
[0020] A DR-RLS method suitable for ECG filtering includes the following steps:
[0021] S1: Load data and perform Z-score normalization;
[0022] S2: Use the findpeak function to find the number of samples corresponding to each R wave, and let the horizontal coordinate of the sample where the i-th R wave is located be Rlocs(i);
[0023] S3: Perform the first iteration loop from the filter tap number L to Rlocs(2)-20 samples, that is, the samples from the beginning to the second R wave. In the first iteration loop, it is necessary to determine whether the digital signal α(n)∈(0.1,0.98) and the number of samples are not near the R wave. If so, set the data reuse number N to 4, otherwise to 1.
[0024] S4: Let the initial value n = L, where n is the number of samples iterated to; perform the following calculation:
[0025]
[0026]
[0027]
[0028] e1(n)=d(n)-y(n)
[0029] α(n)=1-X T (n)k(n)
[0030] β(n)=[1-α N (n)] / [1-a(n)]
[0031] Where λ is the forgetting factor, 0<λ≤1. T (n-1) represents the filter impulse response obtained from the previous sample. The input digital signal x(n) is the nth sample. The number of filter taps is L. Let (n) = [x(n)x(n-1)…x(n-L+1)] T ;h(n) filter impulse response; Represents the estimated value of the expected signal; e1(n) is the prior error; is the estimated value of the filter pair N(n), d(n) is the nth sample of the collected noisy ECG signal, k(n) is the Kalman gain vector, is the estimate of the inverse covariance matrix of the input signal, N(n) represents the noise in the ECG signal;
[0032] h(n)=h(n-1)+k(n)e1(n)β(n)
[0033] e N (n) = e1(n)α N-1 (n)
[0034] S5: Determine whether n is less than or equal to Rlocs(2)-20; if yes, then n=n+1 and return to S4; otherwise, execute S6;
[0035] S6: When the iteration reaches Rlocs(2)-19th sample, the second iteration loop begins, inputting the nth sample x(n) of the reference signal and the nth sample d(n) of the noisy ECG signal. The number of data reuses in this loop is N=1.
[0036] S7: Calculate the following formula;
[0037]
[0038]
[0039]
[0040] e1(n)=d(n)-y(n)
[0041] h(n)=h(n-1)+k(n)e1(n)
[0042] e N (n) = e1(n)
[0043] Among them, e N (n) is the filtering result of the algorithm with data reuse number N.
[0044] S8: Determine whether n is less than or equal to 3000; if yes, n=n+1 and return to S7, otherwise execute S10;
[0045] S10: Output filtered ECG signal e N (n).
[0046] The present invention also discloses an ECG filtering system, which can be used to implement the above-mentioned DR-RLS method, specifically comprising: a data acquisition module, an ECG filtering module, and a result output module;
[0047] Data acquisition module, used to obtain ECG signal data and transmit it to the ECG filtering module
[0048] The ECG filtering module is used to obtain ECG signal data and perform the above-mentioned DR-RLS method to filter the ECG signal, and transmit the result to the result output module.
[0049] The result output module is used to display the filtered results.
[0050] The present invention also discloses a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned DR-RLS method when executing the program.
[0051] The present invention also discloses a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the DR-RLS method is implemented.
[0052] Compared with the prior art, the advantages of the present invention are:
[0053] It can solve the problem that the traditional RLS algorithm affects the filtering quality due to the overshoot phenomenon in the initial stage of the filter structure; the filtering performance is excellent and the computational cost is extremely low. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 The RLS adaptive filtering diagram is verified by simulation; (a) the change of the prior error of the filter output; (b) the change of the trace of the autocorrelation matrix of the input signal.
[0055] Figure 2 These are commonly used structures of adaptive filters in embodiments of the present invention; (a) an adaptive filter structure using a pure signal as a reference signal, and (b) an adaptive filter structure commonly used in actual denoising applications.
[0056] Figure 3 Figures of the MIT-BIH ECG signal, motion artifact, and composite signal from an embodiment of the present invention. (a) ECG signal from the MIT-BIH Arrhythmia Database (mitdb); (b) Motion Artifact (MA) noise from the MIT-BIH Noise Stress Test Database (nstdb); (c) Composite signal of the ECG signal and motion artifact, simulating a noisy ECG signal.
[0057] Figure 4 Schematic diagram of the change in the number of iterations in an embodiment of the present invention; (a) The curve of α changing with the increase in the number of iterations. (b) The corresponding sample diagram when α(n)∈(0.1,0.98).
[0058] Figure 5 1 is a schematic diagram of an ECG waveform according to an embodiment of the present invention.
[0059] Figure 6 This is the division of sections a, b, and c in the embodiment of the present invention.
[0060] Figure 7 Figure 1 is an RLS filtering waveform diagram of an embodiment of the present invention; (a) The waveform after RLS filtering compared to a pure ECG signal. (b) The waveform after DR-RLS filtering of the entire interval compared to a pure ECG signal. (c) The waveform after DR-RLS filtering of interval a compared to a pure ECG signal. (d) The waveform after DR-RLS filtering of interval b compared to a pure ECG signal. (e) The waveform after DR-RLS filtering of interval c compared to a pure ECG signal.
[0061] Figure 8 This is an embodiment of the present invention Figure 7 A local magnified image of 1000 samples; (a) Figure 7 (a) A partial enlarged view of the first 1000 samples, (b) Figure 7 (b) Local zoom of the first 1000 samples, (c) Figure 7 Partial magnification of samples from 800 to 1500 in (a), (d) Figure 7 (b) Local magnification of samples 800 to 1500.
[0062] Figure 9 Schematic diagram of the electrocardiogram signal and MA value according to an embodiment of the present invention; (a) electrocardiogram signal from mitdb, (b) actual MA and estimated MA value when N=8, (c) actual MA and estimated MA value when N=1.
[0063] Figure 10 This is an enlarged view of the filtering results of an embodiment of the present invention, (a) is an enlarged view of the filtering results of section a when the number of data reuses is 1, 2, 4, and 8 respectively, and (b) is an enlarged view of the filtering results of section b when the number of data reuses is 1, 2, 4, and 8 respectively.
[0064] Figure 11 Figure 1 shows the changing trends of evaluation parameters as data is reused, according to an embodiment of the present invention. (a) The changing trends of evaluation parameters as data is reused, for interval a; (b) The changing trends of evaluation parameters as data is reused, for interval b; (c) The changing trends of evaluation parameters as data is reused, for interval c; (d) The changing trends of evaluation parameters as data is reused, for the entire interval.
[0065] Figure 12 FIG. 4 is a flow chart of a DR-RLS method for ECG filtering according to an embodiment of the present invention.
[0066] Figure 13This is an embodiment of the present invention. (a) The waveform after RLS filtering compared to a pure ECG signal; (b) Changes in the autocorrelation matrix of the input signal. (c) A partial zoom of the first 1000 samples in (a). (d) A partial zoom of the first 1000 samples in (b).
[0067] Figure 14 This is the change trend of evaluation parameters such as signal-to-noise ratio improvement, R, and Pearson correlation coefficient with the number of data reuses in the embodiment of the present invention.
[0068] Figure 15 This is a comparison chart of the additional computational complexity caused by the DR-RLS method proposed in an embodiment of the present invention and the computational complexity of the RLS algorithm. DETAILED DESCRIPTION
[0069] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and examples.
[0070] Principles of the DR-RLS Method
[0071] Like other adaptive filters, RLS filters require a reference signal. Assume that the input digital signal x(n) is the nth sample and the number of filter taps is L, X(n) = [x(n)x(n-1)…x(n-L+1)] T It is a one-dimensional vector containing the most recent L samples. The RLS algorithm
[11] defines the Kalman gain vector and the estimate of the inverse covariance matrix of the input signal as as follows:
[0072]
[0073]
[0074] Where λ is the forgetting factor (0<λ≤1). T (n-1) represents the filter impulse response obtained from the previous sample, represents the estimate of the expected signal. We get:
[0075]
[0076] Using e(n) to represent the prior error, combined with (1), we can deduce the filter impulse response corresponding to the nth sample:
[0077] e(n) = d(n)-y(n) (4)
[0078] h(n)=h(n-1)+k(n)e(n) (5)
[0079] In the traditional RLS algorithm, x(n) and d(n) are used only once in each iteration, and e(n) and h(n) are updated only once. However, the DR-RLS proposed by Paleologu et al.
[12] repeats the h(n) update process N times (N≥1) on a sample. The formula for obtaining k (k=1,2,…,N) data reuses in this embodiment is:
[0080] e k (n) = d(n) -h T k-1 (n)X(n) (6)
[0081] h k (n) = h k-1 (n)+ k(n)e k (n) (7)
[0082] The kth calculation in the above method is recursive based on the k-1th calculation. Therefore, in order to obtain the result of N data reuse, it is necessary to first calculate the results of k=1, 2, ..., N-1. Paleologu et al.
[12] derived this process to obtain a calculation method with less computational effort:
[0083] h(n)=h(n-1)+k(n)e(n)β(n) (8)
[0084] e N (n) =e1(n)α N-1 (n) (9)
[0085] Where α(n)=1-X T (n)k(n),β(n)=[1-α N (n)] / [1-α(n)]. This approach greatly simplifies the computational complexity without changing the filter calculation results.
[0086] The common structures of adaptive filters that can be used for this method are Figure 2 There are two types (a) and (b), two structures d(n), x(n), and e N (n) has different meanings. E(n) is the pure ECG signal, and N(n) represents the noise in the ECG signal. Figure 2 The structure in (a) uses E(n) as the reference signal. However, in practical applications, it is impossible to collect pure ECG signals without noise. Therefore, Figure 2 The filter structure in (b) is exactly the filter structure explored in this embodiment. In this case, the collected noisy ECG signal E(n)+N(n)=d(n) is used as the main input signal, and the reference signal r(n) that is highly correlated with the noise signal N(n) is input into the lower branch. is the estimated value of the noise signal N(n). It is worth noting that this embodiment uses e N (n) is the filter output signal instead of e1(n), which creates conditions for suppressing the overshoot phenomenon of RLS.
[0087] In the DR-RLS algorithm, it is noted that The values of and k(n) depend only on x(n) and are not affected by the data reuse process. This means that we can choose intervals that use data reuse, which is similar to reusing data samples from a certain interval N times and using samples from other intervals only once (equivalent to ordinary RLS).
[0088] Improved DR-RLS method for ECG measurement
[0089] In the simulation of this embodiment, the record100ECG signal ( Figure 3 (a)) and motion artifact (MA) noise in the MIT-BIH Noise Stress Test Database (nstdb) ( Figure 3 (b)) to conduct simulation analysis to explore the effect of data reuse in different segments of the ECG waveform. Figure 2 The filter structure in (b) is as follows: let the MA noise be the reference signal r(n), the composite signal of the MA noise and ECG signal ( Figure 3 (c)) is d(n). In this embodiment, to achieve the best filtering effect, the number of filter taps L is set to 30, and the forgetting factor λ=1.
[0090] The evaluation parameters used in this embodiment for filtering quality are PEARSON correlation coefficient, improvement of signal-to-noise ratio (SNR) and goodness of fit R 2 .
[0091] 1. The calculation formula of PEARSON correlation coefficient is:
[0092]
[0093] Where X is the theoretically pure ECG signal, Y represents the ECG signal after filtering, μ represents the mean, E represents the expected value, and σ represents the variance.
[0094] 2. R square (R 2 ) is calculated as
[0095]
[0096] Where X is the theoretically pure ECG signal and Y represents the ECG signal after filtering.
[0097] 3. The calculation formula for the improvement of signal-to-noise ratio (SNR) is
[0098]
[0099] Where s(n) is the clean ECG, s′(n) is the noisy ECG signal before filtering, It is the filtered ECG signal, which can be understood as the improvement of SNR brought by the filtering process.
[0100] We discuss the influence of α(n) on the DR process and propose a method to determine the effective interval of DR.
[0101] (n) = 1 - X T (n)k(n) It can be seen that the value of α(n) also depends only on x(n), so its value will not be affected by the DR process, but it is the key factor affecting the DR process.
[0102] The study of α(n) is interesting. Figure 4 In (a), the initial value of α(n) is 0, after which it enters a short rising phase and finally reaches near 1.
[0103] Here we analyze two cases: α(n) approaches 1 and approaches 0.
[0104] 1. When α(n) approaches 1
[0105] From (6), we can see that when k = 1, we get:
[0106] e1(n) = d(n) -h T 0 (n )X(n) (10)
[0107] The N+1th DR yields:
[0108] e N+1 (n) = d(n) -h T N (n)X(n) (11)
[0109] From (9), we can see that if α(n) approaches 1, e N+1 (n)≈e N (n)≈…≈e2(n)≈e1(n).
[0110] Substituting (10) and (11) we can get: h T 0(n)≈h T N (n). At this time, the DR operation is almost invalid and cannot significantly change the filter impulse response.
[0111] 2. When α approaches 0
[0112] We can get β(n)=[1-α N (n)] / [1-α(n)]≈1. From (8), we get h(n)≈h(n-1)+k(n)e1(n). The filter impulse response is similar to the RLS algorithm. At this time, DR is considered to be invalid. At the same time, it should be considered that, from (9), when α approaches 0, e N (n) will inevitably be compressed to around 0, especially when the number of reuses N is large, but this will not affect the subsequent iterative process.
[0113] In summary, and after multiple experimental verifications, it is believed that the data reuse operation in the corresponding interval when α(n)∈(0.1,0.98) is effective. DR operations outside this range are invalid to avoid more computational costs. Figure 4 (b) It can be seen that the valid interval for α(n)∈(0.1,0.98) mainly exists in the two intervals of [64,836] and [1485,2130].
[0114] Here we first give a brief introduction to ECG signals. Figure 5 , according to the time sequence, it can be divided into P wave, PR segment, QRS complex, ST segment and T wave[3]. Among them, the QRS complex is the potential change generated during the depolarization of ventricular myocardial cells, including the R wave with the largest amplitude in the ECG[4]. In order to explore the application value of the DR-RLS method proposed by Paleologu et al. for ECG denoising. This example analyzes four situations: using DR for the entire interval and using DR for segments a, b, and c.
[0115] respectively Figure 6 The three intervals shown in Figure 1 use data reuse to observe its impact on the waveform.
[0116] a interval: select the P, PR, T, and ST segments after the RLS filter overshoot occurs and use data reuse. Let a interval be [130,377].
[0117] b interval: The b interval where the R wave is located is selected for data reuse. The b interval is defined as [378,423] samples.
[0118] c-interval: We select the c-interval where α(n)∈(0.1,0.98) does not hold and use data reuse. The c-interval is defined as [836,1485] samples.
[0119] Depend on Figure 7(c), (d), and (e) show that using DR-RLS on segments a, b, and c does not destroy the iterative process of RLS. The filtering results all show the characteristics of ECG, verifying the feasibility of using different data reuse times N in different segments. Figure 7 However, the RLS filter in (a) has a large error in the initial stage due to its own overshoot phenomenon. Figure 7 In (b), the data reuse method is used for the entire [1,3000] interval, and N = 8, which makes the filtering effect worse than the RLS algorithm. This means that simply using the data reuse method for the entire interval not only consumes a lot of calculations, but is also not conducive to the filtering process of the filter.
[0120] from Figure 8 (b) The local magnification of the first 1000 samples shows that in the initial stage of DR, α(n) is too close to 0, causing the DR-RLS filter curve to appear as a straight line approaching 0. When the iteration reaches the interval [64,865] and enters the valid interval, DR destroys the R wave waveform but suppresses overshoot in the non-R wave interval.
[0121] To this end, the filter is introduced to estimate the MA To analyze the reasons. Figure 9 As can be seen in (b), In the DR effective range, blindly using data multiplexing will cause the lower branch of the filter to be too dependent on the input of the upper branch, making the signal components of the upper and lower branches too similar.
[0122] The essence of the RLS filter is to update the filter coefficients at the previous time index so that the absolute value of e1(n) at the next time index is as small as possible. The essence of data reuse is to repeat this process. When the data of a time index is reused for the kth time, (6)(7)(9) has:
[0123] e k (n) = d(n) - h T k-1 (n)X(n)=e1(n)α k-1 (n)
[0124] h k (n) = h k-1 (n)+k(n)e k (n)
[0125] The obtained h will be used to estimate the noise in the next time index, and the formula is as follows.
[0126]
[0127] Because a(n)<1. As the number of data reuse increases, d(n) and h T k-1 The values of (n)X(n) will become closer and closer. As k increases, y(n) will begin to contain the signal components in d(n). In the RLS algorithm, e(n) is obtained by subtracting the expected signal from the estimated value of the noise signal in the lower branch. In this process, the R peak, the main feature of the ECG, will be greatly destroyed, causing the filter to lose its filtering performance. Figure 9 As shown in (c), this problem does not occur in ordinary RLS filters.
[0128] from Figure 8 (d) The enlarged image of the sample shows that in the interval [836, 1485], even data reuse near the R wave does not destroy the waveform, showing a filtering effect similar to RLS in 8(c), indicating that the DR operation is ineffective. This proves the correctness of the data reuse interval validity analysis.
[0129] Table 1 Changes in evaluation parameters caused by using the DR method for segment a
[0130]
[0131] Depend on Figure 11 (a) As can be seen, for segment a, with the increase of data reuse times, various evaluation parameters have been improved, and at the same time, the local amplification Figure 10 (a) It can be seen that the DR of segment a successfully suppresses the waveform distortion of segment a overshoot, and the suppression effect becomes more and more obvious as N increases. However, after N>5, the filter effect decreases. This is because N is too large, which leads to e N (n) is too close to 0. Too large a value of N will result in more calculations, so the value of N should be moderate.
[0132] like Figure 11 As shown in (b), the reuse of data in interval b leads to a decrease in the evaluation parameter, and the larger the value of N is, the greater the decrease is. Figure 10 (b) It can be seen that the DR process in segment b where the R wave is located destroys the R peak waveform, and this destruction is continuous. The filter in the subsequent interval also shows significant distortion. Figure 11 (d) The DR of the entire section also leads to a decrease in the filtering effect. Figure 11 (c) The DR performance of the filter in the invalid interval c is approximately unchanged, which further verifies the correctness of the selection of the valid interval.
[0133] In summary, in graph filter applications, using this method on R-peak waveforms results in an R-peak waveform in the noise estimate, severely degrading filter performance. However, using data reuse in non-R intervals suppresses overshoot in these intervals. When a(n)∈(0.1,0.98) is not achieved, and data reuse is ineffective, the data reuse process does not significantly improve the filtering effect. Even worse, when a(n)<0.1, the waveform approaches zero, rendering it meaningless.
[0134] Based on the above conclusions, this embodiment proposes a method for reusing data in segments that meet the following conditions:
[0135] Since the overshoot phenomenon occurs when the number of iterations reaches the filter order 30, that is, after the 60th sample. Since a(n) rises from 0 to 1 at the beginning of the iteration, and the effective segment is set to (0.1, 0.98) in this embodiment, it means that α(n) will definitely generate a DR effective segment in the initial stage. This effective segment can cover the segment where the overshoot occurs. Therefore, we only need to reuse data in the segments that meet these three conditions.
[0136] 1Avoid R peak
[0137] After 2 filter order iteration samples, that is, the starting stage after 60 samples.
[0138] 3α(n)∈(0.1,0.98)
[0139] To minimize the computational complexity, we only selected the segments before the second R peak and used DR for the segments that met the above three conditions.
[0140] The flow chart of the DR method proposed in this embodiment is as follows: Figure 12 First, we load the data and perform Z-score normalization. Then we find the number of samples where each R wave is located. We set the horizontal coordinate of the sample where the i-th R wave is located to Rlocs(i). Then we perform the first iteration loop from L+1 to Rlocs(2)-20, that is, the samples in the interval before the second R wave. In the first loop, we need to determine whether α(n)∈(0.1,0.98) and the number of samples is not near the R wave. If so, we set the number of data reuses to 4, otherwise to 1, and then perform calculations (8) and (9). When the iteration reaches the Rlocs(2)-19th sample, we start the second iteration loop. During this loop, N=1, which is equivalent to the ordinary RLS algorithm. The advantage of this method is that it reduces the number of time indexes used in DR, the amount of calculation is smaller, and at the same time avoids data reuse for samples in the interval where the R wave is located.
[0141] Filtering effect verification
[0142] The DR-RLS method proposed in this embodiment is used to filter the ECG signal. Figure 13 (a) and (c) show that although the RLS algorithm performs well, it can be seen that it has obvious distortion caused by overshoot in the initial stage. Figure 13 (b) and (d) Compared with the common RLS filtering, the DR-RLS method proposed in this embodiment reduces the waveform distortion caused by overshoot in the initial stage.
[0143] From Table 2 and the trend Figure 14 It can be seen that all three evaluation parameters of the method proposed in this embodiment are higher than those of the traditional RLS algorithm. When N = 1, which represents the standard RLS algorithm, the evaluation parameters initially increase with N. When N = 2, i.e., when data reuse is used, the filtering quality improves significantly. However, when N exceeds 5, the performance begins to decline, indicating that a reasonable choice of the number of reuses can lead to even better performance for this method.
[0144] Table 2 Changes in evaluation parameters caused by the number of DR-RLS data reuses N
[0145]
[0146]
[0147] Computational cost analysis
[0148] From the simulation experiments, it can be seen that the improvement brought by the method of the present invention is obvious, but the additional amount of calculation is also a factor that must be considered.
[0149] For the DR method used in this embodiment, the additional operations generated in each time index are L-1 addition operations, 3 subtraction operations, L+2N-1 multiplication operations, and 1 division operation. The additional operation amount is on the order of O(L). In contrast, the RLS itself generates 3L operations in each time index. 2 -1 addition operation, L 2 +1 subtraction, 4L 2 +3L multiplication operations, L 2 +1 division operation, the amount of RLS itself is O(L 2 ) order of magnitude.
[0150] exist Figure 13In the application, there are a total of 3,000 samples. After monitoring the reuse count data in MATLAB, we know that the ECG denoising method proposed in this embodiment only reuses data for 280 samples. The default filter order is L = 30, and the RLS algorithm starts iterating from the L+1th sample. When the number of reuses of each time index is N = 4, the additional computational load generated by the DR method proposed in this embodiment is 8,120 addition operations, 840 subtraction operations, 10,360 multiplication operations, and 280 division operations. In comparison, the total computational load generated by the ordinary RLS algorithm itself without data reuse is 8,016,030 addition operations, 2,675,970 subtraction operations, 10,959,300 multiplication operations, and 2,675,970 division operations.
[0151] from Figure 15 It can be seen from the figure that the additional operations generated by the DR method proposed in this embodiment are tiny, and are two or more orders of magnitude lower than those of the RLS algorithm.
[0152] This embodiment proposes an adaptive filter structure (such as Figure 2 The DR-RLS application method in (b)) further explores the potential of DR-RLS and provides a solution to the problem that the traditional RLS algorithm affects the filtering quality due to the overshoot phenomenon in the initial stage of the filter structure. At the same time, this embodiment introduces the discussion of the parameter α(n) and proposes the concept of DR effective range. In combination with the waveform characteristics of ECG, a DR-RLS method suitable for ECG filtering is proposed. After simulation and comparison with the traditional RLS algorithm, its filtering performance improvement is proved. At the same time, it inherits the characteristic of extremely low computational cost of the data reuse method proposed by Paleologu et al., and the additional operations generated compared with the RLS algorithm are negligible.
[0153] In yet another embodiment of the present invention, an ECG filtering system is provided. The system can be used to implement the above-mentioned DR-RLS method, and specifically includes: a data acquisition module, an ECG filtering module, and a result output module;
[0154] Data acquisition module, used to obtain ECG signal data and transmit it to the ECG filtering module
[0155] The ECG filtering module is used to obtain ECG signal data and perform the above-mentioned DR-RLS method to filter the ECG signal, and transmit the result to the result output module.
[0156] The result output module is used to display the filtered results.
[0157] In another embodiment of the present invention, a terminal device is provided, which includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function; the processor described in the embodiment of the present invention can be used for the operation of the DR-RLS method, including the following steps:
[0158] Step 1: Obtain ECG signal data and transmit it to the ECG filtering module;
[0159] Step 2: Execute the DR-RLS method to filter the ECG signal and transmit the result to the result output module;
[0160] Step 3: Display the filtered results.
[0161] The DR-RLS method comprises the following steps:
[0162] S1: Load data and perform Z-score normalization,
[0163] S2: Use the findpeak function to find the number of samples corresponding to each R wave, and let the horizontal coordinate of the sample where the i-th R wave is located be Rlocs(i);
[0164] S3: Perform the first iteration loop from the filter tap number L to Rlocs(2)-20 samples, that is, the samples from the beginning to the second R wave. In the first iteration loop, it is necessary to determine whether the digital signal α(n)∈(0.1,0.98) and the number of samples are not near the R wave. If so, set the data reuse number N to 4, otherwise to 1.
[0165] S4: Let the initial value n = L, where n is the number of samples iterated to; perform the following calculation:
[0166]
[0167]
[0168]
[0169] e1(n)=d(n)-y(n)
[0170] α(n)=1-X T (n)k(n)
[0171] β(n)=[1-α N (n)] / [1-α(n)]
[0172] Where λ is the forgetting factor, 0<λ≤1. T (n-1) represents the filter impulse response obtained from the previous sample. The input digital signal x(n) is the nth sample. The number of filter taps is L. Let (n) = [x(n)x(n-1)…x(n-L+1)] T ;h(n) filter impulse response; Represents the estimated value of the expected signal; e1(n) is the prior error; is the estimated value of the filter pair N(n), d(n) is the nth sample of the collected noisy ECG signal, according to the definition of the RLS algorithm
[11] , k(n) is the Kalman gain vector, is the estimate of the inverse covariance matrix of the input signal, N(n) represents the noise in the ECG signal;
[0173] h(n)=h(n-1)+k(n)e1(n)β(n)
[0174] e N (n) = e1(n)α N-1 (n)
[0175] S5: Determine whether n is less than or equal to Rlocs(2)-20; if yes, then n=n+1 and return to S4; otherwise, execute S6;
[0176] S6: When the iteration reaches Rlocs(2)-19th sample, the second iteration loop begins, inputting the nth sample x(n) of the reference signal and the nth sample d(n) of the noisy ECG signal. The number of data reuses in this loop is N=1.
[0177] S7: Calculate the following formula;
[0178]
[0179]
[0180]
[0181] e1(n)=d(n)-y(n)
[0182] h(n)=h(n-1)+k(n)e1(n)
[0183] e N (n) = e1(n)
[0184] Among them, e N (n) is the filtering result of the algorithm with data reuse number N.
[0185] S8: Determine whether n is less than or equal to 3000; if yes, n=n+1 and return to S7, otherwise execute S10;
[0186] S10: Output filtered ECG signal e N (n).
[0187] In another embodiment of the present invention, the present invention further provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a terminal device for storing programs and data. It is understandable that the computer-readable storage medium here can include both the built-in storage medium in the terminal device and, of course, the extended storage medium supported by the terminal device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space. These instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory.
[0188] The processor may load and execute one or more instructions stored in a computer-readable storage medium to implement the corresponding steps of the DR-RLS method in the above embodiment. The processor may load and execute the following steps:
[0189] Step 1: Obtain ECG signal data and transmit it to the ECG filtering module;
[0190] Step 2: Execute the DR-RLS method to filter the ECG signal and transmit the result to the result output module;
[0191] Step 3: Display the filtered results.
[0192] The DR-RLS method comprises the following steps:
[0193] S1: Load data and perform Z-score normalization,
[0194] S2: Use the findpeak function to find the number of samples corresponding to each R wave, and let the horizontal coordinate of the sample where the i-th R wave is located be Rlocs(i);
[0195] S3: Perform the first iteration loop from the filter tap number L to Rlocs(2)-20 samples, that is, the samples from the beginning to the second R wave. In the first iteration loop, it is necessary to determine whether the digital signal α(n)∈(0.1,0.98) and the number of samples are not near the R wave. If so, set the data reuse number N to 4, otherwise to 1.
[0196] S4: Let the initial value n = L, where n is the number of samples iterated to; perform the following calculation:
[0197]
[0198]
[0199]
[0200] e1(n)=d(n)-y(n)
[0201] α(n)=1-X T (n)k(n)
[0202] β(n)=[1-α N (n)] / [1-a(n)]
[0203] Where λ is the forgetting factor, 0<λ≤1. T (n-1) represents the filter impulse response obtained from the previous sample. The input digital signal x(n) is the nth sample. The number of filter taps is L. Let (n) = [x(n)x(n-1)…x(n-L+1)] T ;h(n) filter impulse response; Represents the estimated value of the expected signal; e1(n) is the prior error; is the estimated value of the filter pair N(n), d(n) is the nth sample of the collected noisy ECG signal, according to the definition of the RLS algorithm
[11] , k(n) is the Kalman gain vector, is the estimate of the inverse covariance matrix of the input signal, N(n) represents the noise in the ECG signal;
[0204] h(n)=h(n-1)+k(n)e1(n)β(n)
[0205] e N (n) = e1(n)αN-1 (n)
[0206] S5: Determine whether n is less than or equal to Rlocs(2)-20; if yes, then n=n+1 and return to S4; otherwise, execute S6;
[0207] S6: When the iteration reaches Rlocs(2)-19th sample, the second iteration loop begins, inputting the nth sample x(n) of the reference signal and the nth sample d(n) of the noisy ECG signal. The number of data reuses in this loop is N=1.
[0208] S7: Calculate the following formula;
[0209]
[0210]
[0211]
[0212] e1(n)=d(n)-y(n)
[0213] h(n)=h(n-1)+k(n)e1(n)
[0214] e N (n) = e1(n)
[0215] Among them, e N (n) is the filtering result of the algorithm with data reuse number N.
[0216] S8: Determine whether n is less than or equal to 3000; if yes, n=n+1 and return to S7, otherwise execute S10;
[0217] S10: Output filtered ECG signal e N (n).
[0218] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0219] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0220] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0221] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0222] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the implementation methods of the present invention, and it should be understood that the scope of protection of the present invention is not limited to such specific descriptions and embodiments. Those skilled in the art can make various other specific variations and combinations based on the technical teachings disclosed in the present invention without departing from the essence of the present invention, and such variations and combinations are still within the scope of protection of the present invention.
Claims
1. A DR-RLS method suitable for ECG filtering, characterized in that: The following steps are involved: S1: Load data and perform Z-score normalization; S2: Use the findpeak function to find the number of samples corresponding to each R wave, and let the horizontal coordinate of the sample where the i-th R wave is located be Rlocs(i); S3: Perform the first iteration loop from the filter tap number L to Rlocs(2)-20 samples, that is, the samples from the beginning to the second R wave. In the first iteration loop, it is necessary to determine whether the digital signal α(n)∈(0.1,0.98) and the number of samples are not near the R wave. If so, set the data reuse number N to 4, otherwise to 1. S4: Let the initial value n = L, where n is the number of samples iterated to; perform the following calculation: e1(n)=d(n)-y(n) α(n)=1-X T (n)k(n) β(n)=[1-α N (n)] / [1-α(n)] Where λ is the forgetting factor, 0<λ≤1; h T (n-1) represents the filter impulse response obtained from the previous sample. The input digital signal x(n) is the nth sample. The number of filter taps is L. Let X(n) = [x(n)x(n-1)…x(n-L+1)] T ;h(n) filter impulse response; Represents the estimated value of the expected signal; e1(n) is the prior error; d(n) is the nth sample of the collected noisy ECG signal, k(n) is the Kalman gain vector, is the estimate of the inverse covariance matrix of the input signal; h(n)=h(n-1)+k(n)e1(n)β(n) the N (n)=e1(n)α N-1 (n) S5: Determine whether n is less than or equal to Rlocs(2)-20; if yes, then n=n+1 and return to S4; otherwise, execute S6; S6: When the iteration reaches Rlocs(2)-19th sample, the second iteration loop begins, inputting the nth sample x(n) of the reference signal and the nth sample d(n) of the noisy ECG signal. The number of data reuses in this loop is N=1. S7: Calculate the following formula; e1(n)=d(n)-y(n) h(n)=h(n-1)+k(n)e1(n) have been N (n)=e1(n) Among them, e N (n) is the filtering result of the algorithm with data reuse number N; S8: Determine whether n is less than or equal to 3000; if yes, n=n+1 and return to S7, otherwise execute S10; S10: Output filtered ECG signal e N (n).
2. An ECG filtering system, characterized in that: The system can be used to implement the DR-RLS method of claim 1, specifically comprising: a data acquisition module, an ECG filtering module, and a result output module; Data acquisition module, used to obtain ECG signal data and transmit it to the ECG filtering module An ECG filtering module is used to obtain ECG signal data and perform the DR-RLS method on the ECG signal, and transmit the result to the result output module; The result output module is used to display the filtered results.
3. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the DR-RLS method according to claim 1 is implemented when the processor executes the program.
4. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the program is executed by a processor, the DR-RLS method according to claim 1 is implemented.
Citation Information
Patent Citations
Biochip analysis method based on active contour model and cell neural network
CN103236065A
Fetus electrocardiosignal extracting method and device
CN105640545A