ECG R wave identification method and system based on central difference and adaptive threshold, and storage medium
By adopting central differential and adaptive threshold technology in ECG signal processing, the problem of insufficient real-time, robustness and dynamic response capabilities of R wave detection in the prior art is solved, and an R wave detection method with high accuracy and strong adaptability is realized.
Patent Information
- Application Number
- CN202510373214.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-07-01
AI Technical Summary
The existing R-wave detection methods cannot simultaneously realize real-time detection, high robustness and dynamic response signal fluctuations, especially in noise environments or signal sudden changes, and have limited dynamic response capabilities to RR interval changes.
The ECG R wave identification method based on central differential and adaptive thresholds is adopted to pre-process the original ECG signal, central differential and nonlinear transformation, and the candidate extreme peak set is generated, and the R wave is filtered out through the dynamically updated amplitude threshold and RR interval threshold.
Real-time detection of R waves is realized, the accuracy and robustness of detection are improved, and the detection accuracy of low amplitude and low slope R waves can be dynamically responded to noise fluctuations and heart rate changes, especially in a low signal-to-noise ratio environment, which improves the detection accuracy of low amplitude and low slope R waves.
Smart Images

Figure CN120227041A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to ECG signal recognition, in particular to an R-wave recognition method, system and storage medium for ECG based on central difference and adaptive threshold. Background Art
[0002] Electrocardiogram (ECG) is a non-invasive tool for measuring heart function abnormalities. With the development of medical technology, long-term monitoring systems can record a large amount of electrocardiographic data, such as 24-hour Holter monitoring, or even longer-term monitoring. The analysis of such long-term data is a heavy and time-consuming task for doctors. Therefore, automatic analysis of electrocardiographic signals becomes particularly important.
[0003] The electrocardiogram waveform can be marked with base points (such as P, Q, R, S, T waves). The R wave has a large amplitude and a steep slope, which is particularly crucial in automatic detection. Accurately extracting features from each base point of the electrocardiogram determines the performance of the automatic electrocardiogram analysis system. The accurate detection of the R wave is a basic step for the automatic detection and further analysis of other electrocardiogram base points. However, the electrocardiogram morphology has individual differences, and even the electrocardiograms of the same person at different times will vary. In addition, the electrocardiogram signal is usually interfered by various noises during the acquisition process, such as power line noise, motion artifacts, electromyographic noise, and baseline drift. These factors all increase the difficulty of automatic R-wave detection. Classical methods (such as the Pan-Tompkins algorithm) rely on multiple steps such as filtering, differentiation, and integration, with high computational complexity; the double-slope-based algorithm needs to calculate the signal slope point by point, with limited real-time performance; although wavelet transform has high accuracy, there are problems such as difficulty in selecting the mother wavelet and time-consuming calculation, making it difficult to meet the requirements of real-time monitoring. Most fixed-threshold algorithms have poor robustness in a noisy environment or when the signal mutates, while the traditional adaptive threshold update mechanism has limited dynamic response ability to changes in the RR interval.
[0004] In summary, the existing R-wave detection methods cannot achieve real-time detection, high robustness, and dynamic response to signal fluctuations simultaneously. Summary of the Invention
[0005] Object of the Invention: The object of the present invention is to provide an R-wave recognition method, system and storage medium for ECG based on central difference and adaptive threshold, which has high robustness, can dynamically respond to signal fluctuations, and can detect and recognize the R wave in real time.
[0006] Technical Solution: The R-wave recognition method for ECG based on central difference and adaptive threshold according to the present invention includes the following steps:
[0007] S1. Preprocess the original electrocardiogram signal, and the preprocessing includes power frequency noise elimination, high-frequency electromyographic interference suppression, and low-frequency baseline drift suppression;
[0008] S2. Perform central difference and non - linear transformation on the pre - processed ECG signal;
[0009] S4. Smooth the transformed ECG signal, and search for local maxima within each window through a sliding window to generate a set of candidate extreme peaks;
[0010] S4. Based on the amplitude threshold and RR interval threshold that are dynamically updated according to the magnitude relationship between each candidate extreme peak amplitude and the amplitude threshold, screen the candidate extreme peaks that meet the requirements as R waves.
[0011] Based on the above - mentioned method, by pre - processing the original ECG signal, power frequency noise, high - frequency electromyogram interference, and low - frequency baseline drift are reduced, the interference of noise on the ECG signal is decreased, and the accuracy of the final detection can be improved; the R waves in the ECG signal are symmetric. By selecting an appropriate central radius for central difference, the central difference at the peak of the R wave can be close to zero, and the responses on both sides of the peak are high; and the non - linear processing of taking the absolute value of the central difference converts all signal values into positive values, eliminating the difference between positive and negative R waves. This simplifies the algorithm, does not require special processing for negative R waves, reduces complexity, and improves the real - time performance of this method; in addition, taking the absolute - value transformation of the signal after central difference can create a trough response at the peak of the R wave, and then low - pass filtering converts it into a peak response, thereby enhancing the visibility of the R wave; central difference is different from forward and backward differences. Forward and backward differences only consider adjacent points and ignore the symmetry of the R wave, while central difference uses this symmetry to enhance the signal and can better identify low - amplitude and low - slope R waves.
[0012] After smoothing the transformed ECG signal and then searching for local maxima through a sliding window to generate a set of candidate extreme peaks, that is, a set of alternative R waves, the number of invalid candidate points is reduced, the computational complexity of a single detection is decreased, and the real - time performance of this method is further improved; finally, the amplitude threshold and RR interval threshold are dynamically updated according to the magnitude relationship between the candidate extreme peaks and the amplitude threshold to screen R waves, realizing real - time adaptation to noise fluctuations and heart rate changes. Compared with the fixed - threshold method, the detection accuracy is improved, especially suitable for the analysis of arrhythmia signals, and the detection accuracy of R waves is improved. To sum up, this method has a small computational amount, can perform real - time detection, is less affected by noise, can adapt to noise fluctuations and heart rate changes in real - time, so it can improve the accuracy of R wave detection, especially improve the accuracy of detecting low - amplitude and low - slope R waves, and has high robustness.
[0013] The R - wave recognition system of ECG based on central difference and adaptive threshold according to the present invention includes:
[0014] Signal preprocessing module: used to preprocess the original electrocardiogram (ECG) signal, and the preprocessing includes power frequency noise elimination, high-frequency electromyogram (EMG) interference suppression, and low-frequency baseline drift suppression;
[0015] Signal transformation module: performs central difference and non-linear transformation on the preprocessed ECG signal;
[0016] Candidate extreme peak generation module: used to smooth the transformed ECG signal, and search for local maxima within each window through a sliding window to generate a set of candidate extreme peaks;
[0017] R-wave screening module: used to dynamically update the amplitude threshold and RR interval threshold according to the relationship between the amplitude of each candidate extreme peak and the amplitude threshold, and based on the dynamically updated amplitude threshold and RR interval threshold, screen the candidate extreme peaks that meet the requirements as R-waves.
[0018] The computer-readable storage medium storing one or more programs of the present invention includes one or more programs including instructions, and when the instructions are executed by a computing device, the computing device is caused to execute any one of the above methods.
[0019] Advantageous effects: Compared with the prior art, the present invention has the following remarkable effects: By preprocessing, central difference, and non-linear transformation, power frequency interference, baseline drift, and EMG noise are effectively eliminated, and at the same time, the steep slope feature of the R-wave is enhanced. Especially for low-amplitude and low-slope R-waves, their recognition degree is enhanced, and the problem of high false detection rate of traditional methods under low signal-to-noise ratio is solved; By central difference, non-linear transformation, and sliding window, a set of candidate extreme peaks is selected as the alternative R-wave set, reducing the computational complexity and improving the real-time performance; Then, by dynamically updating the amplitude threshold and RR interval threshold to screen R-waves, the detection accuracy of R-waves is improved. Description of the Drawings
[0020] Figure 1 is a flowchart of the method of the present invention.
[0021] Figure 2 is a detection result diagram of the method of the present invention for signals containing premature beats and normal low-amplitude R-waves.
[0022] Figure 3 is a detection result diagram of the method of the present invention for signals containing RR interval mutations and noisy signals.
[0023] Figure 4 is the detection result of the method of the present invention for signals containing inverted low-amplitude R-waves. Detailed Embodiments
[0024] As shown in the figure, the R-wave recognition method for ECG based on central difference and adaptive threshold of the present invention includes the following steps:
[0025] S1. Preprocess the original electrocardiogram (ECG) signal, where the preprocessing includes power frequency noise elimination, high-frequency electromyogram (EMG) interference suppression, and low-frequency baseline drift suppression;
[0026] In the preprocessing, to reduce power supply interference noise, weaken high-frequency EMG interference, and low-frequency baseline drift, the original ECG signal first passes through a third-order finite impulse response (FIR) 60 Hz notch filter based on a Hamming window to eliminate power line interference (60 Hz power frequency noise); then passes through a 40-order FIR bandpass filter based on a Hamming window to enhance the R wave. The low cut-off frequency of this bandpass filter is 15 Hz, and the high cut-off frequency is 25 Hz to suppress high-frequency EMG noise (>25 Hz) and low-frequency baseline drift (<15 Hz). The signal filtered by the two filters is denoted as X(n).
[0027] S2. Perform central difference and non-linear transformation on the preprocessed ECG signal.
[0028] The formulas for central difference and non-linear transformation are:
[0029] Y(n) = |X(n + w) - X(n - w)|
[0030] where X(n) is the ECG signal at the nth sampling point after preprocessing, that is, the filtered electrocardiogram signal obtained in step S1, Y(n) is the ECG signal after central difference and non-linear transformation processing, and w is the window radius; w can be adaptively selected according to the sampling rate. For example, for a 360 Hz sampling rate, the window span 2w = 20 points (≈55.6 ms), and the window span can be selected with an appropriate length through multiple experiments to cover the typical R wave rising edge time (30 - 60 ms), and experiments verify that its response to R waves with different slopes is optimal.
[0031] There may be inverted R waves in the electrocardiogram signal. Take the absolute value of the central difference result to eliminate the influence of the R wave polarity (positive / negative), unify the signal amplitude to a positive value, and at the same time retain the slope characteristics, thus simplifying the complexity of subsequent processing.
[0032] S3. Smooth the transformed ECG signal and search for local maxima within each window through a sliding window to generate a set of candidate extreme peaks.
[0033] Smooth the transformed ECG signal Y(n) obtained in step S2. Specifically, use a two-stage low-pass filter based on a Hamming window to process Y(n) in sequence: first use the first-stage filter, that is, a 20-order FIR low-pass filter, with a cut-off frequency of 5 Hz to attenuate the residual EMG noise; then use the second-stage filter, that is, a 20-order FIR low-pass filter, with a cut-off frequency of 0.5 Hz to extract the R wave envelope signal Z(n).
[0034] Detect local maximum points in the signal Z(n) through a peak pre-selection algorithm. The peak pre-selection algorithm is as follows: Use a sliding window with a fixed time length to search for local maxima within each window. The time length of the sliding window can be selected as 33 ms, or in different cases, other appropriate lengths can be selected through multiple experiments and verification. Record the amplitude A of the local maximum within each window i and the corresponding time index T i That is, (A i , T i ), and call the local maximum the candidate extreme peak, forming a set of candidate extreme peaks; there is only one unique candidate extreme peak within each window.
[0035] The cut-off frequencies of all filters used in this step and step S1 can be adjusted accordingly according to the frequency bands of each corresponding signal in different cases to filter out the corresponding signals.
[0036] S4. Based on the dynamically updated amplitude threshold and RR interval threshold, screen the candidate extreme peaks that meet the requirements as R waves.
[0037] Dynamically update the amplitude threshold and RR interval threshold in real time. The amplitude threshold needs to be assigned an initial value before updating.
[0038] The amplitude threshold initialization strategy is as follows: The high amplitude threshold T h and the low threshold T l are respectively 0.4 and 0.3 times the maximum amplitude of the original electrocardiogram signal in the first two seconds; in addition to the first two seconds, other time durations can also be selected according to the situation, such as one second, three seconds, or five seconds, etc. The main requirement is that the maximum amplitude within the selected time duration can represent the general amplitude size, and 0.4 and 0.3 can also be adjusted according to the actual situation. The criterion for setting the ratio is that the determined initial value can cover most R waves (the R waves here can be determined based on experience) within the selected initial time period.
[0039] Specifically, it is dynamically updated through the following rules:
[0040] The first case: When the amplitude A of the i-th candidate extreme peak i > the high amplitude threshold T h , update the amplitude threshold and RR interval threshold according to the following formula
[0041]
[0042] T t1 = T low1
[0043] where T l is the low amplitude threshold, and T t1is the RR interval threshold in the first case, Ns is the selected number of candidate extreme peaks before the i-th candidate extreme peak for threshold update, and A j is the amplitude of the j-th candidate extreme peak; T low1 = k6fs, where fs is the sampling frequency; k1, k2, and k6 are set constants.
[0044] In this case, the threshold update mainly increases the high amplitude threshold. Since the amplitude of the i-th candidate extreme peak is large and the image slope is steep, it is inferred that the amplitude of the (i + 1)-th candidate extreme peak has an increasing trend and the distance from the i-th candidate extreme peak has a decreasing trend. Therefore, the high amplitude threshold is increased. And in this case, the amplitude of the i-th extreme peak is greater than the high amplitude threshold, indicating that this peak is relatively large and the possibility of noise is low. Therefore, a relatively fixed RR interval threshold, that is, T t1 can be used for detection without complex processing, reducing the complexity of threshold update; through the above processing to fit the signal fluctuation situation, filtering out candidate extreme peaks with small amplitudes, and screening out the truly qualified candidate extreme peaks as R waves.
[0045] Second case: When T h ≥ A i > T l , update the amplitude threshold and RR interval threshold according to the following formula
[0046]
[0047] T t2 = max(T low2 , k5 * MRI)
[0048] where, T t2 is the RR interval threshold in the second case, and MRI is the average of the RR intervals between all detected true R waves; T low2 = k7fs; k3, k4, and k7 are set constants.
[0049] In this case, the threshold update mainly reduces the high amplitude threshold and increases the RR interval threshold. Since the amplitude of the i-th candidate extreme peak is small and the image slope is gentle, it is inferred that the amplitude of the (i + 1)-th candidate extreme peak has a decreasing trend and the distance from the i-th candidate extreme peak has an increasing trend. Therefore, the high amplitude threshold is reduced and the RR interval threshold is increased to fit the signal fluctuation situation, retaining candidate extreme peaks with small amplitudes and large distances; also, when the amplitude of the candidate extreme peak is less than or equal to the high amplitude threshold and greater than the low amplitude threshold, it indicates that this peak is relatively small and the possibility of noise is high. In this case, the fixed threshold is not sufficient to meet the detection requirements. Therefore, a dynamic threshold is set based on the detected MRI to better process low-amplitude R waves and noise, thereby improving the detection accuracy; at the same time, for T t2A lower limit T is set low2 , to prevent the increase of false detection due to the low dynamic threshold.
[0050] When A i <T h No need to update the threshold.
[0051] In summary, the adaptive multi-threshold consisting of amplitude and RR interval thresholds can effectively avoid noise peaks and improve the detection of low-amplitude and low-slope R waves.
[0052] In this embodiment, Ns=8, k1=0.6, k2=k4=0.3, k3=0.5, k5=0.48, k6=0.24, k7=0.33; these parameters are selected based on experience, and for a new detection environment, appropriate values can also be selected through multiple experimental verifications; fs=360Hz.
[0053] When screening the candidate extreme value peaks in each sliding window, it is necessary to determine whether to update the amplitude threshold and the RR interval threshold according to the above dynamic update rules.
[0054] Screening for R waves involves the following steps
[0055] S4.1. Traverse the candidate extreme value peaks from front to back in chronological order, and take the first candidate extreme value peak that satisfies the amplitude threshold condition as the candidate R wave; the amplitude threshold condition is that the amplitude of the candidate extreme value peak is greater than the amplitude high threshold or less than or equal to the amplitude high threshold and greater than the amplitude low threshold;
[0056] S4.2, determine in sequence whether the candidate extreme value peak after the candidate R wave simultaneously satisfies the conditions that the amplitude satisfies the amplitude threshold, the distance between the candidate R wave and the candidate R wave is less than the RR interval threshold, and the amplitude is greater than the candidate R wave. If so, the candidate R wave is replaced with the candidate extreme value peak. Otherwise, the screening is continued without replacement until a candidate extreme value peak with an amplitude that satisfies the amplitude threshold and the distance between the candidate R wave and the candidate R wave is greater than the RR interval threshold appears. The candidate extreme value peak is taken as the candidate R wave and the candidate R wave before it is confirmed as the real R wave. According to the amplitude threshold condition that is satisfied, the corresponding RR interval threshold is selected. In the process of screening the first two real R waves, the RR interval threshold is taken;
[0057] There are 8 criteria for determining candidate extreme peaks in this step, specifically:
[0058] 1. The amplitude meets the amplitude threshold condition, the interval with the candidate R wave is less than the RR interval threshold, and the amplitude is greater than the candidate R wave;
[0059] 2. The amplitude meets the amplitude threshold condition, the interval with the candidate R wave is less than the RR interval threshold, and the amplitude is less than the candidate R wave;
[0060] 3. The amplitude meets the amplitude threshold condition, the interval from the candidate R wave is greater than the RR interval threshold, and the amplitude is greater than the candidate R wave;
[0061] 4. The amplitude meets the amplitude threshold condition, the interval from the candidate R wave is greater than the RR interval threshold, and the amplitude is less than the candidate R wave;
[0062] 5. The amplitude does not meet the amplitude threshold condition, the interval from the candidate R wave is less than the RR interval threshold, and the amplitude is greater than the candidate R wave;
[0063] 6. The amplitude does not meet the amplitude threshold condition, the interval from the candidate R wave is less than the RR interval threshold, and the amplitude is less than the candidate R wave;
[0064] 7. The amplitude does not meet the amplitude threshold condition, the interval from the candidate R wave is greater than the RR interval threshold, and the amplitude is greater than the candidate R wave;
[0065] 8. The amplitude does not meet the amplitude threshold condition, the interval from the candidate R wave is greater than the RR interval threshold, and the amplitude is less than the candidate R wave;
[0066] The amplitude not meeting the amplitude threshold condition actually means that the amplitude of the candidate extreme peak is less than or equal to the low amplitude threshold.
[0067] When condition 1 is met, replace the candidate R wave with the candidate extreme peak; when any one of conditions 2, 5, 6, 7, or 8 is met, eliminate the candidate extreme peak and continue to determine the next candidate extreme peak; when any one of conditions 3 or 4 is met, take the candidate extreme peak as the new candidate R wave and the previous candidate R wave as the true R wave.
[0068] S4.3. Return to step S4.2 until the screening of all candidate extreme peaks is completed.
[0069] Considering the dynamic update of the amplitude threshold and the RR interval threshold, the 8 conditions mentioned in step S4.3 can be further refined into 12 conditions:
[0070] 1.1. The amplitude is greater than the high amplitude threshold T h , the interval from the candidate R wave is less than T t1 and the amplitude is greater than the candidate R wave;
[0071] 1.2. The amplitude is less than or equal to the high amplitude threshold T h and greater than the low amplitude threshold T l , the interval from the candidate R wave is less than T t2 and the amplitude is greater than the candidate R wave;
[0072] 2.1. The amplitude is greater than the high amplitude threshold T h , the interval from the candidate R wave is less than T t1 and the amplitude is less than the candidate R wave;
[0073] 2.2. The amplitude is less than or equal to the high amplitude threshold T h and greater than the low amplitude threshold T l , the interval from the candidate R wave is less than T t2 and the amplitude is less than the candidate R wave;
[0074] 3.1. The amplitude is greater than the high amplitude threshold T h , the interval from the candidate R wave is greater than T t1 and the amplitude is greater than the candidate R wave;
[0075] 3.2. The amplitude is less than or equal to the high amplitude threshold T h and greater than the low amplitude threshold T l , the interval from the candidate R wave is greater than T t2 and the amplitude is greater than the candidate R wave;
[0076] 4.1. The amplitude is greater than the high amplitude threshold T h , the interval from the candidate R wave is greater than T t1 and the amplitude is less than the candidate R wave;
[0077] 4.2. The amplitude is less than or equal to the high amplitude threshold T h and greater than the low amplitude threshold T l , the interval from the candidate R wave is greater than T t2 and the amplitude is less than the candidate R wave;
[0078] 5. The amplitude does not meet the amplitude threshold condition, the interval from the candidate R wave is less than the RR interval threshold, and the amplitude is greater than the candidate R wave;
[0079] 6. The amplitude does not meet the amplitude threshold condition, the interval from the candidate R wave is less than the RR interval threshold, and the amplitude is less than the candidate R wave;
[0080] 7. The amplitude does not meet the amplitude threshold condition, the interval from the candidate R wave is greater than the RR interval threshold, and the amplitude is greater than the candidate R wave;
[0081] 8. The amplitude does not meet the amplitude threshold condition, the interval from the candidate R wave is greater than the RR interval threshold, and the amplitude is less than the candidate R wave;
[0082] Under conditions 5 - 8, the RR interval threshold is defaulted to T t1 , but in the actual processing process, as long as the amplitude does not meet the amplitude threshold condition, the subsequent two conditions (the distance from the candidate R wave and the amplitude size) do not need to be judged anymore and can be directly excluded and continue to screen backward, and no specific judgment will be made anymore.
[0083] When condition 1.1 or 1.2 is satisfied, replace the candidate R wave with this candidate extreme peak. When any one of conditions 2.1, 2.2, 5, 6, 7, or 8 is satisfied, eliminate this candidate extreme peak and continue to determine the next candidate extreme peak; when any one of conditions 3.1, 3.2, 4.1, or 4.2 is satisfied, use this candidate extreme peak as a new candidate R wave and the previous candidate R wave as the true R wave.
[0084] It should be noted that when determining the first two true R waves, regardless of which amplitude threshold condition the amplitude of the candidate extreme peak satisfies, the corresponding RR interval threshold is T t1 , because at least two true R waves are required to calculate the MRI, and without being able to calculate the MRI, T cannot be calculated t2 , so when determining the first two true R waves, the RR interval threshold can only be T t1 .
[0085] The R wave recognition system of the ECG based on central difference and adaptive threshold according to the present invention includes:
[0086] A signal preprocessing module: used to preprocess the original electrocardiogram signal, and the preprocessing includes power frequency noise elimination, high-frequency electromyogram interference suppression, and low-frequency baseline drift suppression;
[0087] A signal transformation module: performs central difference and non-linear transformation on the preprocessed electrocardiogram signal;
[0088] A candidate extreme peak generation module: used to smooth the transformed electrocardiogram signal and search for local maxima within each window through a sliding window to generate a set of candidate extreme peaks;
[0089] An R wave screening module: used to screen candidate extreme peaks that meet the requirements as R waves based on dynamically updated amplitude thresholds and RR interval thresholds.
[0090] The computer-readable storage medium storing one or more programs according to the present invention includes one or more programs including instructions, and when the instructions are executed by a computing device, the computing device is caused to execute any one of the above methods.
[0091] To verify the effect of the method of the present invention in electrocardiogram R wave recognition, the present invention uses the MIT-BIH arrhythmia database and conducts experiments in the VScode, python3.7 environment on a 2.4GHz Intel i7 CPU. We evaluate the method using sensitivity (Se), positive predictive value (+P), and detection error rate (DER).
[0092]
[0093] Among them, true positive TP is the number of correctly detected R waves, false positive FP is the number of incorrectly detected R waves, and false negative FN is the number of missed R waves.
[0094] By comparing with the annotations in the MIT-BIH Arrhythmia Database, each analysis includes all sampling points (about 30 minutes), and the average time used is 0.5 seconds. The sensitivity, positive predictive value, and detection error rate of the entire MIT-BIH Arrhythmia Database are 99.73%, 99.82%, and 0.46% respectively. It can be seen that the method of the present invention can accurately identify R waves.
[0095] Figure 2-4 The detection results of some representative segments from the MIT-BIH Arrhythmia Database are shown, which are characterized by different morphologies and various noise interferences; each figure contains two sub-figures, where the upper image is the original signal and the lower image is the signal processed by the present method. The red circles are the corresponding positions of the detected R waves in the original signal and the signal processed by the present method.
[0096] Figure 2 The R wave detection results of recording No. 203 data in the MIT-BIH Arrhythmia Database are shown, which include premature ventricular contractions (PVCs) and normal low-amplitude R waves.
[0097] Figure 3 It shows that the algorithm can accurately detect R waves in recording No. 232 data in the MIT-BIH Arrhythmia Database, regardless of sudden changes in the RR interval and noise in the signal.
[0098] Figure 4 The detection results of recording No. 108 data in the MIT-BIH Arrhythmia Database are shown. Recording No. 108 data in the MIT-BIH Arrhythmia Database contains inverted low-amplitude and low-slope R waves.
[0099] From the detection results shown in the above 4 figures, it can be seen that after processing the signal by the present method, the R wave signal can be made more prominent for detection, greatly reducing the detection difficulty and improving the detection accuracy; and the above effects can be achieved under various electrocardiogram morphologies and different types of noise interferences. Therefore, the present method has high detection accuracy and good adaptability and robustness.
Claims
1. A method for recognizing ECG R waves based on central difference and adaptive threshold, characterized in that: The following steps are involved: S1. Preprocessing the original ECG signal, including reducing power frequency noise, high-frequency myoelectric interference and low-frequency baseline drift; S2, performing central difference and nonlinear transformation on the preprocessed ECG signal; S3, smoothing the transformed ECG signal, and searching for the local maximum value in each window through a sliding window to generate a set of candidate extreme value peaks; S4. According to the amplitude threshold and RR interval threshold that are dynamically updated based on the magnitude relationship between the amplitude of each candidate extreme value peak and the amplitude threshold, based on the dynamically updated amplitude threshold and RR interval threshold, the candidate extreme value peaks that meet the requirements are screened as R waves.
2. The identification method according to claim 1, characterized in that: The preprocessing in step S1 reduces power frequency noise through a 3rd order FIR notch filter based on a Hamming window, and enhances the R wave and reduces high frequency electromyographic interference and low frequency baseline drift through a 40th order FIR bandpass filter based on a Hamming window.
3. The identification method according to claim 1, characterized in that: The central difference and nonlinear transformation formula in step S2 is: Y(n)=|X(n+w)-X(nw)| Among them, X(n) is the ECG signal of the nth sampling point after preprocessing, Y(n) is the transformed ECG signal, and w is the window radius.
4. The identification method according to claim 1, characterized in that: In step S3, smoothing is performed by a two-stage low-pass filter based on a Hamming window, wherein the first stage is a 20th-order FIR low-pass filter with a cutoff frequency of 5 Hz; and the second stage is a 20th-order FIR low-pass filter with a cutoff frequency of 0.5 Hz.
5. The identification method according to claim 1, characterized in that: The length of the sliding window in step S3 is 33 milliseconds.
6. The identification method according to claim 1, characterized in that: The amplitude threshold and RR interval threshold in step S4 are dynamically updated according to the following rules: The first case: when the amplitude A of the i-th candidate extreme peak i >Amplitude high threshold T h When , the amplitude threshold and RR interval threshold are updated according to the following formula T t1 =T low1 Among them, T l is the amplitude low threshold, T t1 is the RR interval threshold in the first case, Ns is the number of candidate extreme peaks selected before the i-th candidate extreme peak for threshold update, A j is the amplitude of the jth candidate extreme value peak; T low1 =k6fs, fs is the sampling frequency; k1, k2 and k6 are set constants; The second case: When T h ≥A i >T l When , the amplitude threshold and RR interval threshold are updated according to the following formula T t2 =max(T low2 ,k5*MRI) Among them, T t2 is the RR interval threshold in the second case, and MRI is the average value of the RR intervals between all true R waves detected; T low2 =k7fs; k3, k4 and k7 are set constants.
7. The identification method according to claim 6, characterized in that: The step S4 comprises the following sub-steps S4.
1. Traverse the candidate extreme value peaks from front to back in chronological order, and take the first candidate extreme value peak that satisfies the amplitude threshold condition as the candidate R wave; the amplitude threshold condition is that the amplitude of the candidate extreme value peak is greater than the amplitude high threshold or less than or equal to the amplitude high threshold and greater than the amplitude low threshold; S4.
2. Determine in sequence whether the candidate extreme value peak after the candidate R wave satisfies the conditions of amplitude satisfying the amplitude threshold, spacing with the candidate R wave less than the RR interval threshold, and amplitude greater than the candidate R wave. If so, replace the candidate R wave with the candidate extreme value peak. Otherwise, continue to screen backward without replacement until a candidate extreme value peak with an amplitude satisfying the amplitude threshold and spacing with the candidate R wave greater than the RR interval threshold appears. Take the candidate extreme value peak as the candidate R wave and confirm the candidate R wave before it as the real R wave. Select the corresponding RR interval threshold according to the amplitude threshold condition. In the process of screening the first two real R waves, take the RR interval threshold as T. t1 ; S4.
3. Return to step S4.2 until all candidate extreme value peaks are screened.
8. The identification method according to claim 1, characterized in that: The amplitude threshold in step S4 is determined according to the amplitude of the original ECG signal in the selected initial time period.
9. An ECG R wave recognition system based on central difference and adaptive threshold, characterized in that: The system comprises: Signal preprocessing module: used to preprocess the original ECG signal, including power frequency noise elimination, high-frequency myoelectric interference suppression and low-frequency baseline drift suppression; Signal transformation module: performs central difference and nonlinear transformation on the preprocessed ECG signal; Candidate extreme value peak generation module: used to smooth the transformed ECG signal and search for the local maximum value in each window through a sliding window to generate a set of candidate extreme value peaks; R wave screening module: used to dynamically update the amplitude threshold and RR interval threshold according to the size relationship between the amplitude of each candidate extreme value peak and the amplitude threshold, and screen the candidate extreme value peaks that meet the requirements as R waves based on the dynamically updated amplitude threshold and RR interval threshold.
10. A computer-readable storage medium storing one or more programs, characterized in that: The one or more programs include instructions which, when executed by a computing device, cause the computing device to perform any one of the methods according to claims 1 to 8.