Electrocardiogram R peak detection method based on nonlinear enhanced wavelet transform and windowing adaptive threshold
Through the nonlinear enhanced wavelet transformation and windowed adaptive threshold ECG R peak detection method, the missed detection and missed detection problems caused by noise and P/T wave interference in the ECG signal are solved, and high-precision detection of QRS wave groups is realized, especially the effective identification of low-amplitude R peaks.
Patent Information
- Application Number
- CN202510762393.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2025-08-08
AI Technical Summary
The existing R-peak detection methods for ECG signal are prone to missed detection and missed detection under noise and P/T wave interference, especially for QRS wave groups with small wavelet coefficient amplitudes.
The ECG R peak detection method based on nonlinear enhanced wavelet transformation and windowed adaptive threshold is adopted. The wavelet coefficient distinction is improved by retaining polarity square operations and sliding window integrals, and the threshold is dynamically adjusted to adapt to the amplitude fluctuations of the QRS wave group, and combined with a secondary backtracking search strategy to improve detection accuracy.
It significantly improves the detection accuracy of the QRS wave group extreme value pair, improves the detection rate of low-amplitude R peaks, reduces noise and P/T wave interference, and realizes accurate detection of the R peak of the ECG signal.
Smart Images

Figure CN120436658A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an electrocardiogram R peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold, and belongs to the technical field of electrocardiogram R peak detection. Background Art
[0002] In the diagnosis of cardiovascular disease, ECG signals can reflect the electrophysiological state of the heart, providing a safe and non-invasive way to monitor and assess a patient's cardiac function. During each cardiac cycle, the electrical excitation generated by the sinoatrial node is transmitted sequentially through the cardiac conduction system to the atria and ventricles, forming an ECG waveform consisting of the P wave, QRS complex, and T wave. The QRS complex is a key waveform in the ECG that reflects ventricular depolarization and contains important information about the heart's electrical activity. Furthermore, as the most prominent waveform in the ECG signal, the QRS complex provides a temporal reference for the entire ECG cycle. Detecting the QRS complex is a prerequisite for detecting other waveforms. Therefore, accurately identifying the QRS complex plays a key role in extracting ECG signal features and automatically diagnosing cardiovascular disease, impacting the early detection and accurate diagnosis of cardiovascular disease.
[0003] The presence of various types of noise and P / T waves with high-frequency characteristics similar to the QRS complex in ECG signals makes QRS complex detection difficult. The key to automated ECG analysis lies in the identification and location of the R peak. Wavelet transform is a common QRS complex identification algorithm. This method extracts the ECG signal's wavelet coefficients through wavelet transform and uses a threshold to select the modulus extreme value pairs of the wavelet coefficients generated by the QRS complex to locate the R peak. Traditional first-order differential wavelet methods are susceptible to interference from P / T waves and noise when identifying R peaks, leading to misidentification. Some ECGs are affected by pathological and physiological factors, and the morphology and characteristics of the QRS complex in the ECG signal may exhibit dynamic changes. The amplitudes of the wavelet coefficients generated by wavelet transform for QRS complexes within the same ECG can vary significantly. For QRS complexes with small wavelet coefficient amplitudes, it is difficult to identify the R peak by searching for the zero crossing point of the modulus extreme value pair, resulting in missed detections. To improve detection accuracy, based on previous research, a R peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive thresholding is proposed. Polarity-preserving squaring and sliding window integration are used to nonlinearly enhance the wavelet coefficients to address misjudgments caused by high-amplitude and high-frequency P / T waves. A windowed adaptive threshold algorithm is proposed to perform windowed segmentation on the ECG to achieve segmented R-peak detection. The QRS wavelet coefficient screening threshold is continuously updated during the detection process to address the problem of missed detection of some QRS complexes with smaller wavelet coefficient amplitudes that do not meet the threshold.
[0004] At present, researchers have proposed a variety of methods for the automatic detection of R peaks in ECG signals, including detection algorithms based on differential thresholds, detection algorithms based on implicit Markov models, detection algorithms based on deep learning technology, and detection algorithms based on wavelet transforms.
[0005] ECG signals are susceptible to various noise interferences during the sampling process. Myoelectric and power frequency interference cause dense oscillations in the ECG signal, and baseline drift can cause sudden changes in the signal voltage or slow waveform transitions, affecting signal clarity and detection accuracy. Before R-peak location, the ECG signal is preprocessed to reduce the impact of noise on location. Avishek Paul et al. proposed a nonlinear filtering technique based on median filtering for ECG signal noise reduction. The advantage of using a nonlinear median filter is that it does not require mathematical transformations, reducing temporal and spatial complexity, and preventing the distortion of the ECG signal caused by mathematical transformations. Varun Gupta et al. applied a 4-14 Hz digital bandpass filter. The 4-14 Hz bandpass filter was selected based on QRS complex spectral energy analysis. The filtered signal not only removes baseline drift and high-frequency noise but also highlights the QRS band, making it easier to identify. Subhadeep Basu and other scholars conducted a systematic study on the application of Butterworth low-pass filters in ECG signal denoising. Compared with the Chebyshev filter, the Butterworth filter has a slightly lower signal-to-noise ratio at the same order, but its passband flatness is more conducive to preserving the key features of the ECG signal.
[0006] For the location of R peak, Pan and Tompkins et al. used the idea of differential threshold, filtering, derivation, and squaring to perform a series of preprocessing operations to increase the contrast between the QRS wave group and other bands or interference, and used the double threshold method to accurately screen out the R peak. This algorithm is simple to calculate and has strong real-time performance, but it is easily affected by noise in the same frequency band of QRS. When using the differential threshold method to detect R peak, Jagdeep Rahul et al. [9] first performed nonlinear amplification on the signal to enhance the R wave peak and suppress the P wave and T wave, thereby reducing false detection. However, this method only processes the signal based on amplitude and does not fully consider the situation where the QRS wave amplitude varies greatly, resulting in performance degradation when detecting low-amplitude R waves or high-variability ECG signals. Li Cuiwei et al. proposed an R peak detection method based on wavelet transform, which uses the time-frequency localization characteristics of wavelets to enhance the high-frequency components of the QRS wave and suppress noise, combines the Lipschitz index of signal singularity to distinguish R waves from noise, and uses dynamic threshold update and redundant modulus maximum elimination strategies to improve detection robustness. However, it involves the calculation of multi-scale Lipschitz exponents, which is computationally intensive. Yu Shang et al. used secondary backtracking to determine missed detection points. If the detected RR interval is too long, the threshold is lowered by half and the search is repeated within this RR interval. This method can effectively correct missed detections, but it is still ineffective for detecting QRS complexes with too small wavelet coefficient amplitudes. Coast proposed a method for analyzing ECG signals using an implicit Markov model. This method calculates the posterior distribution of R wave features based on Bayes' theorem, estimates the distribution of features, and determines the R peak position point by point based on the distribution of features. Liu Kaige et al. proposed a new QRS wave detection model LMAU-Net based on U-Net and local mask attention. This model introduces a novel local mask attention mechanism into the U-Net framework. The original ECG signal is fed into the U-Net model with the attention mechanism to generate a QRS wave region of interest. Then, based on the judgment conditions, the peak point of the QRS complex is located from the region of interest. This method can effectively alleviate the impact of noise and non-QRS waves on detection. However, implicit Markov models and deep learning technologies require the support of data sets, the preliminary preparation is cumbersome, and the computational complexity of the models is large, making them unsuitable for real-time detection.
[0007] In summary, while existing R-peak detection methods have achieved some success, they still face challenges with missed and false detections due to interference from noise, P / T waves, and significant variations in QRS complex morphology within the same ECG. Taking into account the need to suppress noise while adapting to the morphological differences between different QRS complexes within the same ECG, a method for ECG R-peak detection based on a nonlinear enhanced wavelet transform and a windowed adaptive threshold is proposed. This method reduces the interference caused by noise and P / T waves on QRS complex detection by enhancing the discrimination between the QRS complex and other interfering factors. Furthermore, the R-peak detection threshold can be adjusted based on the time-varying characteristics of the wavelet coefficients to address the issue of missed detection of some low-amplitude QRS complexes. Summary of the Invention
[0008] In view of the deficiencies of the prior art, the present invention provides an electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold.
[0009] To address noise and P / T wave interference, a polarity-preserving square enhancement operation and sliding window integration are incorporated into the wavelet transform, resulting in nonlinear enhancement of the wavelet coefficients. This improves the discrimination between the wavelet coefficients generated in the QRS band and those of noise and other bands, reducing the interference of noise and P / T waves on QRS extreme values. Furthermore, to prevent missed detection of QRS complexes with small wavelet coefficient amplitudes, a windowed adaptive threshold algorithm is proposed to perform R-peak segmentation on the ECG using windowed segmentation. During the detection process, the QRS wavelet coefficient screening threshold is continuously updated to address the problem of missed detection of some QRS complexes with small wavelet coefficient amplitudes that do not meet the threshold. To further detect missed and false detection points, a secondary backtracking search strategy is proposed. This strategy halves the detection threshold when the interval between adjacent R peaks is too large, and a new search is conducted between the two R peaks for possible missed detection points. If the interval between adjacent R peaks is too small, the detection points with smaller peak values are eliminated to correct false detections. These improvements ultimately achieve accurate detection of R peaks in the ECG signal.
[0010] Based on the defects of the above wavelet transform method for identifying R peaks in electrocardiograms, a nonlinear enhancement method using polarity-preserving square enhancement operation and sliding window integration is proposed to improve the discrimination between the extreme value pairs generated by the QRS complex and the extreme value pairs of noise or P / T bands. A windowed adaptive threshold method is used to screen the extreme value pairs that meet the conditions to complete R peak detection.
[0011] Explanation of terms:
[0012] Mallat multi-scale wavelet decomposition is a method that decomposes the original signal into different frequency components layer by layer through low-pass and high-pass filters. In traditional algorithms, downsampling after each layer of decomposition will lead to a decrease in time resolution. In this invention, interpolation and expansion are performed instead of decimation during the filtering process to keep the wavelet coefficients of each layer consistent with the length of the original signal.
[0013] Fixed detection intervals (FDI) are intervals where the ECG signal is segmented every 10 seconds and are used for R-peak segment detection.
[0014] The local analysis window (LAW) is a window divided every 2 seconds within the FDI and is used for dynamic adjustment of the R-peak detection threshold.
[0015] The technical solution of the present invention is:
[0016] The electrocardiogram R peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold includes:
[0017] (1) ECG signal data acquisition and preprocessing
[0018] Acquire ECG signals and perform denoising on the ECG signals;
[0019] Further preferably, the electrocardiogram signal comes from the MIT-BIH arrhythmia database.
[0020] (2) R-peak candidate point detection based on nonlinear enhanced wavelet transform
[0021] The preprocessed ECG signal is decomposed into four layers using biorthogonal spline wavelet as basis function, and the decomposed signal is interpolated to restore the wavelet coefficient length to the same as the original signal.
[0022] Among the four scales of wavelet decomposition, the wavelet coefficients at the third scale are selected for analysis to locate the R peak. The wavelet coefficients at the third scale are subjected to a polarity-preserving square operation supplemented by a sliding window integral process. The modulus maxima and minima of the wavelet coefficients at the third scale are extracted, and the modulus maxima and minima that match the QRS wave through threshold screening are paired to form modulus extreme value pairs, with the zero-crossing points being the R peak candidates.
[0023] (3) R-peak positioning based on windowed adaptive threshold
[0024] A fixed interval is used to perform segmented R-peak detection on the ECG signal. Within each fixed detection interval FDI, a local analysis window LAW is divided. The average value of the extreme value to the maximum value within each LAW is used as the standard to set the threshold. The window with the extreme value to the maximum value less than the threshold is defined as a mutation window, and the window with the extreme value to the maximum value greater than the threshold is defined as a normal window.
[0025] If all windows within the FDI are normal, the initial threshold for R-peak detection within the FDI is set to 1 / 3 of the mean of the extreme value to the maximum value within each LAW, and the threshold is dynamically updated during the detection process;
[0026] If the FDI includes a mutation window, the initial threshold of the R-peak detection threshold in the normal window is set to 1 / 3 of the average of the maximum value of the extreme value pairs in each LAW, and the threshold is dynamically updated within the window; the initial threshold in the mutation window is set to 1 / 3 of the maximum value of the extreme value pairs in the window, and the dynamic update mechanism is also used within the window;
[0027] At the same time, the RR interval changes are monitored. When the current RR interval is detected to be more than 1.6 times the average RR interval, the detection threshold is temporarily adjusted to 50% of the original value. When the current RR interval is detected to be less than 0.4 times the average RR interval, the detection points with smaller peak values are eliminated.
[0028] Preferably, according to the present invention, R-peak candidate point detection based on nonlinear enhanced wavelet transform includes:
[0029] According to a preferred embodiment of the present invention, the Mallat multi-scale decomposition of the electrocardiogram signal includes:
[0030] The Mallat decomposition algorithm is used to decompose the ECG signal at multiple scales, and the decomposed signal is subjected to a binary interpolation operation to restore the wavelet coefficient length to be consistent with the original signal, so as to achieve the alignment of the wavelet coefficient and the ECG signal on the time axis. The Mallat decomposition algorithm is used to decompose the ECG signal at multiple scales as shown in formulas (I) and (II).
[0031]
[0032] Where a (j) is the approximate coefficient at the jth scale, where a (0) [n] = x[n], which represents the original one-dimensional discrete ECG signal; n is the discrete time index of the signal at the current scale, indicating the location of the sample point; k is the index variable of the filter kernel;
[0033] d (j)is the detail coefficient at the jth scale, which is the wavelet coefficient used for R-peak positioning; h0 is the coefficient of the quadratic B-spline decomposition low-pass filter [1 / 4 3 / 4 3 / 4 1 / 4]; h1 is the coefficient of the quadratic B-spline decomposition high-pass filter [-1 / 4 3 / 4 3 / 4 -1 / 4].
[0034] Preferably, according to the present invention, a square operation based on preserving polarity is used for the wavelet coefficients on the third scale, supplemented by a sliding window integration process; including:
[0035] (1) Square enhancement processing of the third-scale wavelet coefficients to preserve polarity;
[0036] Extract and retain the positive and negative polarity, the wavelet coefficient polarity is based on the third scale wavelet coefficient d (3) [n] value is determined when d (3) When [n] is greater than zero, the polarity value is 1, d (3) When [n] is less than zero, the polarity value is -1, otherwise its polarity is equal to 0, as shown in formula (III):
[0037]
[0038] In the formula, sign(d (3) ) indicates the polarity of the signal;
[0039] The nonlinear enhancement of wavelet coefficients based on polarity preservation is obtained by squaring the wavelet coefficients while retaining the original wavelet coefficients, as shown in formula (IV):
[0040]
[0041] in, is the enhanced wavelet coefficient, sign(d (3) [n]) is the polarity sign of the original wavelet coefficient, d (3) [n] is the original third-scale wavelet coefficient;
[0042] (2) Improvement of the discrimination of wavelet coefficients based on sliding window integration;
[0043] The enhanced third layer wavelet coefficients Perform sliding integration processing; as shown in formula (V):
[0044]
[0045] Where T is the integration window width, which is half the average width of the QRS complex; N is the number of samples within the integration window width; n represents the discrete time index corresponding to the end moment of the current integration window; Represents the enhanced third layer wavelet coefficients The result after sliding integration processing.
[0046] Preferably, according to the present invention, the threshold-based screening of candidate electrocardiogram R peak points comprises:
[0047] The nonlinear enhanced wavelet coefficients are obtained by sign-preserving squaring and sliding window integration. Nonlinear enhancement of wavelet coefficients The zero crossing point between the maximum and minimum points corresponds to the R peak of the QRS complex;
[0048] Nonlinear enhancement of wavelet coefficients Perform extreme value detection operations, retain the maximum and minimum values, and set the remaining values to 0 to form a set Use threshold The extreme points of the R peak are judged point by point, and the maximum point and the minimum point whose amplitude meets the threshold are paired to form an extreme pair. The zero crossing point of the extreme pair corresponds to the R peak, which is the candidate point of the R peak of the electrocardiogram.
[0049] Preferably, according to the present invention, the detection of a sudden change window in the R peak detection interval of the electrocardiogram includes:
[0050] When dividing the normal window and the mutation window, first, extract the set The maximum and minimum values in each LAW are calculated, and their maximum and minimum values are calculated respectively; then, the mean of the maximum and minimum values of all LAWs in an FDI is calculated; if the maximum or minimum value in a LAW is lower than 1 / 3 of the corresponding mean, the LAW is determined to be a mutation window; otherwise, it is determined to be a normal window.
[0051] More preferably, the calculation formula of the maximum value and the minimum value in each LAW is as shown in formula (6):
[0052]
[0053] Where Max windowk is the maximum value among the extreme values of the wavelet coefficients in the kth LAW; Min windowk is the minimum value among the extreme values within the k-th LAW; l is the window width of each LAW; k = 1, 2, ..., K, where K = 5 represents the total number of LAWs divided within the FDI;
[0054] The 1 / 3 of the mean of the maximum value of the wavelet coefficient extreme value in LAW is used as the window detection positive threshold W u , 1 / 3 of the mean of the minimum value is used as the window detection negative threshold W l , then the calculation of the window detection threshold is shown in formula (7):
[0055]
[0056] Where A u is the mean of the maximum value set of all LAW wavelet coefficients in FDI, as W u The standard of value; A l is the mean of the minimum value set, as T l The standard of value; 1 / 3 is the empirical constant; if the Max windowk <W u or|Min windowk |<|W l |, then the window is a mutation window.
[0057] According to the preferred embodiment of the present invention, if all windows in the FDI are normal windows, the positive and negative thresholds of the R peak screening of the FDI are set to 1 / 3 of the mean of the maximum value and 1 / 3 of the mean of the minimum value of the extreme values of the wavelet coefficients in each LAW, respectively, as shown in formula (8):
[0058]
[0059] Where, T u,1 Indicates the positive threshold for R peak screening, used to detect the maximum value of the QRS wave group modulus; T l,1 Indicates the negative threshold for R peak screening, which is used to detect the minimum value of the QRS wave group mode; 1 / 3 is an empirical constant; T u,1 and T l,1 As the initial threshold for R peak detection, each time an R peak is detected, the threshold is dynamically updated according to the amplitude of the extreme value pair that matches it, as shown in formula (9).
[0060] A u,i+1 =0.875·pos i +0.125·A u ;
[0061] A l,i+1 =0.875·neg i +0.125·A l ;
[0062]
[0063] Where A u,i It is the positive threshold standard adjusted according to the wavelet maximum value corresponding to the i-th R peak; A l,i is the negative threshold standard adjusted according to the wavelet minimum value corresponding to the i-th R peak; pos i is the wavelet maximum corresponding to the i-th R peak; neg i is the wavelet minimum corresponding to the i-th R peak; T u,i is the positive threshold adjusted according to the i-th R peak; T l,i is the negative threshold adjusted according to the i-th R peak; pos1 and neg1 are determined by the initial threshold Tu,0 、T l,0 Obtained through screening;
[0064] If the FDI contains a mutation window, if multiple mutation windows appear continuously, they are merged into one mutation window; if multiple normal windows appear continuously, they are merged into one normal window; in the normal window, the R peak detection threshold is updated according to the dynamic adjustment strategy of formula (9); in the mutation window, the initial R peak screening positive threshold is set to 1 / 3 of the maximum value in the window, and the negative threshold is set to 1 / 3 of the minimum value in the window; in the mutation window, each time an R peak is detected, the threshold for the next R peak detection is adjusted according to its amplitude, as shown in formula (10):
[0065] M u,i+1 =0.875·pos i +0.125·M u ;
[0066] M l,i+1 =0.875·neg i +0.125·M l ;
[0067]
[0068] Where M u,i It is the positive threshold standard adjusted according to the wavelet maximum value corresponding to the i-th R peak in the mutation window; M l,i It is the negative threshold standard adjusted according to the wavelet minimum value corresponding to the i-th R peak in the mutation window; M u and M l are the maximum and minimum values in the mutation window respectively; pos i and neg i are the wavelet maximum and minimum corresponding to the i-th R peak in the mutation window, respectively. pos1 and neg1 are obtained by screening the initial R peak screening threshold of the mutation window; T u,i is the positive threshold adjusted according to the i-th R peak in the mutation window; T l,i is the negative threshold adjusted according to the i-th R peak within the mutation window.
[0069] Preferably, according to the present invention, the electrocardiogram R peak location based on dynamic threshold comprises:
[0070] When locating the R peak, the initial R peak screening threshold is used to filter the peaks within the detection range. The extreme value of is judged point by point. Then r i Points are points that meet the threshold conditions. i After the point, the search is for the first one that meets the threshold and and Point r with opposite signj , 0.11s is the longest duration of the QRS complex; r i and r j The R peak is located in the ECG. The R peak is located in the ECG. The R peak detection threshold is dynamically adjusted based on the window extreme value to update the next R peak screening threshold for the next R peak detection. The R peak missed detection points and false detection points are further detected based on the secondary backtracking search strategy.
[0071] The beneficial effects of the present invention are:
[0072] 1. Based on wavelet transform, the present invention introduces a nonlinear enhancement method of polarity-preserving square operation and sliding window integration, which effectively enhances the discrimination between QRS complex and P / T wave and noise components in wavelet coefficients, and significantly improves the detection reliability of QRS complex extreme value pairs. This method enhances the amplitude of QRS complex wavelet coefficients while retaining their polarity information, and further aggregates features through sliding integration, making the enhanced wavelet coefficients smoother than the original wavelet coefficients, significantly suppressing P / T wave and noise components, thereby improving the detection accuracy of QRS complex extreme value pairs.
[0073] 2. The present invention proposes a windowed adaptive threshold strategy, which distinguishes normal windows from mutation windows according to the changes in the amplitude of the extreme values within each LAW, and sets a dynamic update method for the threshold accordingly, so that the R peak detection threshold can be adaptively adjusted in different types of windows, thereby adapting to the amplitude fluctuations of the QRS complex wavelet coefficients and improving the detection rate of low-amplitude R peaks. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] Figure 1 Schematic diagram of the process of the electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold according to the present invention;
[0075] Figure 2(a) is a schematic diagram of part of the original data of MIT-BIH 109;
[0076] Figure 2(b) is a schematic diagram of the ECG signal after filtering;
[0077] Figure 3 Schematic diagram of the four-layer B-spline wavelet decomposition of MIT-BIH 108 ECG signal;
[0078] Figure 4(a) is a schematic diagram of the original third-scale wavelet coefficients;
[0079] Figure 4(b) is a schematic diagram of the wavelet coefficients after square processing with preserved polarity;
[0080] Figure 5 This is a schematic diagram of the sliding window integration processing principle;
[0081] Figure 6(a) is a schematic diagram of the MIT-BIH 108 ECG signal;
[0082] Figure 6(b) is a schematic diagram of the extreme value distribution of the third layer wavelet coefficients of traditional wavelet decomposition;
[0083] Figure 6(c) is a schematic diagram of the detection results of the traditional method;
[0084] Figure 6(d) is a schematic diagram of the extreme value distribution of the third layer wavelet coefficients of the nonlinear enhanced wavelet;
[0085] Figure 6(e) is a schematic diagram of the detection results of the improved method;
[0086] Figure 7(a) is a schematic diagram of part of the MIT-BIH 104 data;
[0087] Figure 7(b) is a schematic diagram of the extreme value distribution of the third layer wavelet coefficients after nonlinear enhanced wavelet transform;
[0088] Figure 8 Schematic diagram of FID and LAW division;
[0089] Figure 9(a) is a schematic diagram of the division of the mutation window in the extreme value distribution of the third layer wavelet coefficients;
[0090] Figure 9(b) is a schematic diagram of the maximum distribution of each LAW;
[0091] Figure 10(a) is a schematic diagram of the basic method for R peak detection;
[0092] Figure 10(b) is a schematic diagram of R-peak detection based on windowed adaptive threshold;
[0093] Figure 11 This is a schematic diagram of the R peak annotation of the original MIT-BIH dataset;
[0094] Figure 12 Schematic diagram of the correction of R peak annotation for the MIT-BIH dataset;
[0095] Figure 13(a) is a schematic diagram showing the comparison between the R-peak detection results and expert annotations for part of the MIT-BIH 228 dataset;
[0096] Figure 13(b) is a schematic diagram showing the comparison between the R-peak detection results and expert annotations for part of the MIT-BIH 200 dataset. DETAILED DESCRIPTION
[0097] The present invention will be further defined below with reference to the accompanying drawings and embodiments, but is not limited thereto.
[0098] Example 1
[0099] The electrocardiogram R peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold is shown in the following diagram: Figure 1 Shown, including:
[0100] (1) ECG signal data acquisition and preprocessing
[0101] ECG signals are acquired and denoised using a Butterworth bandpass filter. This Butterworth bandpass filter has a smooth frequency response and effectively suppresses noise while preserving the signal's key waveform characteristics. Its optimized frequency band selection reduces the noise component in the wavelet coefficients, effectively suppressing baseline drift, power frequency interference, and myoelectric noise, resulting in a clear ECG signal. A comparison of the original ECG signal and the preprocessed ECG signal is shown in Figures 2(a) and 2(b).
[0102] The ECG signals come from the MIT-BIH Arrhythmia Database, a public dataset jointly created by MIT and Beth Israel Deaconess Medical Center. Each record provides expert annotations of the beat-to-beat rhythm type and R-peak location.
[0103] (2) R-peak candidate point detection based on nonlinear enhanced wavelet transform
[0104] The preprocessed ECG signal is decomposed into four layers using biorthogonal spline wavelet as basis function, and the decomposed signal is interpolated to restore the wavelet coefficient length to the same as the original signal.
[0105] Among the four scales of wavelet decomposition, the energy of the QRS complex is mainly concentrated in the third and fourth scales. Considering that the offset of the zero-point position of the wavelet coefficient corresponding to the signal extreme value increases with the increase of the scale, and the P and T waves occupy more components, the wavelet coefficient analysis on the third scale is selected to locate the R peak; in order to enhance the characteristics of the QRS band, the wavelet coefficients on the third scale are subjected to a square operation based on retaining polarity, supplemented by a sliding window integral process; this nonlinear enhancement strategy amplifies the distinction between the wavelet coefficients generated by the QRS band and the noise and wavelet coefficients of other bands. After the above nonlinear enhancement, the modulus maximum and minimum points of the wavelet coefficients on the third scale are extracted, and the modulus maximum and modulus minimum points that match the QRS wave through threshold screening are paired to form a modulus extreme pair, and the zero-crossing point is the R peak candidate point;
[0106] (3) R-peak positioning based on windowed adaptive threshold
[0107] A fixed interval is used to perform segmented R-peak detection on the ECG signal. Within each fixed detection interval FDI, a local analysis window LAW is divided. The average value of the extreme value to the maximum value within each LAW is used as the standard to set the threshold. The window with the extreme value to the maximum value less than the threshold is defined as a mutation window, and the window with the extreme value to the maximum value greater than the threshold is defined as a normal window.
[0108] If all windows within the FDI are normal, the initial threshold for R-peak detection within the FDI is set to 1 / 3 of the mean of the extreme value to the maximum value within each LAW, and the threshold is dynamically updated during the detection process;
[0109] If the FDI includes a mutation window, the initial threshold of the R-peak detection threshold in the normal window is set to 1 / 3 of the average of the maximum value of the extreme value pairs in each LAW, and the threshold is dynamically updated within the window; the initial threshold in the mutation window is set to 1 / 3 of the maximum value of the extreme value pairs in the window, and the dynamic update mechanism is also used within the window;
[0110] At the same time, the system monitors changes in the RR interval. When the current RR interval is detected to be 1.6 times greater than the average RR interval, the detection threshold is temporarily adjusted to 50% of the original value. When the current RR interval is detected to be less than 0.4 times the average RR interval, detection points with smaller peak values are eliminated. This enhances the ability to identify potential missed R peaks and reduces false and missed detections.
[0111] Example 2
[0112] The difference between the electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold described in Example 1 is that:
[0113] R-peak candidate point detection based on nonlinear enhanced wavelet transform; including:
[0114] When using the first-order derivative of a smoothing function as a basis function for wavelet decomposition of the electrocardiogram (ECG), the R peak is located at the zero crossing of the extreme value pair. However, pseudo-extreme pairs with excessively large amplitudes can easily lead to false R peak detection. To address this issue, a R peak detection method based on nonlinear enhanced wavelet transform is proposed. Based on wavelet decomposition, this method applies a polarity-preserving square enhancement operation and a sliding window integration method to the wavelet coefficients, achieving nonlinear enhancement of the wavelet coefficients. This method improves the discrimination between QRS complex extreme value pairs and noise or P / T band extreme value pairs.
[0115] Mallat multi-scale decomposition of ECG signals; including:
[0116] Wavelet decomposition is a multi-scale time-frequency analysis method that extracts the characteristics of the signal in different frequency bands through filtering and downsampling operations, and can realize the R peak positioning of the ECG signal in the joint time-frequency domain. The Mallat decomposition algorithm is used to perform multi-scale decomposition of the ECG signal, and the decomposed signal is subjected to a binary interpolation operation to restore the length of the wavelet coefficient to the same as the original signal, so as to achieve the alignment of the wavelet coefficient and the ECG signal on the time axis, which is convenient for the positioning of the R peak. The Mallat decomposition algorithm is used to perform multi-scale decomposition of the ECG signal as shown in formulas (I) and (II):
[0117]
[0118] Where a (j) is the approximate coefficient at the jth scale, where a (0) [n] = x[n], which represents the original one-dimensional discrete ECG signal; n is the discrete time index of the signal at the current scale, indicating the position of the sample point; k is the index variable of the filter kernel; binary interpolation is reflected in n-2 j-1 k, that is, the length recovery and alignment are achieved by inserting zeros between the coefficient sampling points during the filtering process.
[0119] Among them, formula (I) extracts low-frequency information as the input of the next layer, and formula (II) is calculated based on the result of formula (I) of the previous layer to extract high-frequency details for R-peak positioning.
[0120] d (j) is the detail coefficient at the jth scale and is the wavelet coefficient used for R-peak location. The wavelet basis selected is the biorthogonal quadratic B-spline wavelet, a widely used and effective method for singularity detection. It has strong regularity and is easy to implement. Its basis function is a smooth function with continuous first-order derivatives. h0 is the low-pass filter coefficient of the quadratic B-spline decomposition [1 / 4 3 / 4 3 / 4 1 / 4]; h1 is the high-pass filter coefficient of the quadratic B-spline decomposition [-1 / 4 3 / 4 3 / 4 -1 / 4].
[0121] The energy of the QRS complex is mainly concentrated in the third and fourth scales of the wavelet coefficients. The Mallat algorithm is used to perform quadratic B-spline wavelet four-layer decomposition on the ECG signal with record number 108 in the MIT-BIH database. The results are as follows: Figure 3 shown. Figure 3 (a) is the first 10 seconds of the MIT-BIH 108 ECG signal data. Figure 3 Figures (b), (c), (d), and (e) are wavelet coefficients of different scales decomposed from ECG data using equations (1) and (2). Each layer of wavelet coefficients is obtained by high-pass filtering the approximate coefficients of the previous layer, and their length is consistent with the original signal. Low-scale wavelet coefficients retain the high-frequency information of the signal, while high-scale wavelet coefficients reflect the low-frequency information of the signal. Since the higher the scale, the greater the offset of the zero point position of the wavelet coefficient corresponding to the extreme value of the signal, and the more components occupied by P / T waves, the wavelet coefficients at the third scale are selected for R peak positioning.
[0122] The wavelet coefficients on the third scale are subjected to a square operation based on preserving polarity, supplemented by a sliding window integration process; including:
[0123] High-amplitude and high-frequency P / T waves or noise in the original signal appear as high-amplitude values in the wavelet coefficients, potentially interfering with accurate R-peak location. To address this issue, a nonlinear enhancement method is proposed that combines polarity-preserving square enhancement with sliding window integration. This method applies nonlinear enhancement to the scaled signal corresponding to the QRS complex, mitigating the impact of high-amplitude interfering wavelet coefficients on detection. To reduce computational complexity, nonlinear enhancement is performed only on the third-scale wavelet coefficients used for R-peak location.
[0124] (1) Square enhancement processing of the third-scale wavelet coefficients to preserve polarity;
[0125] The R peak can be located by determining the zero-crossing point between the maximum and minimum points of the third-scale wavelet coefficients, but high-amplitude P / T waves or noise under pathological conditions may interfere with the location of the R peak. Nonlinear operations such as squaring the wavelet coefficients can effectively amplify the amplitude difference between the R peak and the wavelet coefficients corresponding to the P / T wave or noise. To ensure that the square operation of the wavelet coefficients does not lose its polarity information, it is necessary to first extract and retain the positive and negative polarities. The polarity of the wavelet coefficients is determined according to the third-scale wavelet coefficients d (3) [n] value is determined when d (3) When [n] is greater than zero, the polarity value is 1, d (3) When [n] is less than zero, the polarity value is -1, otherwise its polarity is equal to 0, as shown in formula (III):
[0126]
[0127] In the formula, sign(d (3) ) represents the polarity of the signal; the polarity-preserving operation extracts the polarity of the wavelet coefficients corresponding to the rising and falling edges of the QRS complex, which can maintain the integrity of the extreme value pairs and avoid zero-crossing point positioning errors.
[0128] The nonlinear enhancement of wavelet coefficients based on polarity preservation is obtained by squaring the wavelet coefficients while retaining the original wavelet coefficients, as shown in formula (IV):
[0129]
[0130] in, is the enhanced wavelet coefficient, sign(d (3) [n]) is the polarity sign of the original wavelet coefficient, d (3)[n] represents the original third-scale wavelet coefficients; this operation effectively enhances the characteristics of the QRS complex, amplifying high-amplitude coefficients by squares while suppressing low-amplitude coefficients. This operation selectively enhances the positive maxima and negative minima generated in the wavelet coefficients along the rapidly changing edges of the QRS complex, improving the discrimination between extreme value pairs generated by the QRS complex and those generated by noise or P / T bands. Figures 4(a) and 4(b) compare the third-scale wavelet coefficients of a portion of the MIT-BIH 108 data with those processed with polarity-preserving squares. It can be seen that the original third-scale wavelet coefficients contain significant burrs, which can easily lead to misjudgment in R-wave detection. After the polarity-preserving square enhancement operation, the burrs are effectively suppressed, resulting in a smoother overall coefficient curve, thereby reducing the probability of false detection caused by burrs in the wavelet coefficients due to noise or P / T waves.
[0131] (2) Improvement of the discrimination of wavelet coefficients based on sliding window integration;
[0132] In order to further suppress noise and enhance the distinction between QRS wave and P / T wave wavelet coefficients, the enhanced third layer wavelet coefficients Perform sliding integration processing; by accumulating the wavelet coefficients within the preset integration window, the sliding integration operation of the wavelet coefficients can effectively aggregate the wavelet coefficients generated by the QRS wave to enhance its energy characteristics. As shown in formula (V):
[0133]
[0134] Where T is the integration window width, which is half the average width of the QRS complex, and is 50ms here; N is the number of samples within the integration window width; and n represents the discrete time index corresponding to the end moment of the current integration window. Represents the enhanced third layer wavelet coefficients The result after sliding integration. Integration output Relying on the combined effect of multiple points within the window, when there are high-amplitude wavelet coefficients in the window, the integration result will be significantly improved; on the contrary, if the coefficient amplitude is low, the output will be effectively smoothed. Therefore, the high-amplitude wavelet coefficients generated by the QRS complex will be further enhanced during the integration process, as shown in the schematic diagram. Figure 5 As shown in the figure, the dashed line is the curve obtained by sliding window integration of the wavelet coefficients in Figure 4(b). The amplitude of each point on the curve is the cumulative amplitude of the wavelet coefficients after polarity-preserving square processing within the integration window. This operation further increases the amplitude difference between the QRS wavelet coefficients and the P / T wave coefficients, thereby enhancing the distinguishability of the QRS wave and the P / T wave in the wavelet domain.
[0135] Threshold-based ECG R-peak candidate point screening; including:
[0136] The nonlinear enhanced wavelet coefficients are obtained by sign-preserving squaring and sliding window integration. Nonlinear enhancement of wavelet coefficients The zero crossing point between the maximum and minimum points corresponds to the R peak of the QRS complex;
[0137] To extract the enhanced third layer wavelet coefficients The extreme points in the nonlinear enhanced wavelet coefficients Perform extreme value detection operations, retain the maximum and minimum values, and set the remaining values to 0 to form a set Use threshold The extreme points of the QRS complex are determined point by point, and the maximum and minimum points whose amplitudes meet the threshold are paired to form extreme value pairs. The zero crossing points of the extreme value pairs correspond to R peaks, which are candidate R peak points on the ECG. When the original wavelet locates the R peak in the MIT-BIH 108 ECG data, high-frequency and high-amplitude P waves can lead to false detection. The improved wavelet uses a polarity-preserving square enhancement operation and a sliding window integration method to perform nonlinear enhancement on the scale signal corresponding to the QRS complex, reducing the impact of high-amplitude P wavelet coefficients on the detection results. Figure 6(a) shows a portion of the MIT-BIH 108 data, Figure 6(b) shows the extreme value distribution of the third-layer wavelet coefficients of the MIT-BIH 108 ECG signal after traditional wavelet decomposition, Figure 6(c) shows the detection results of the traditional method, Figure 6(d) shows the extreme value distribution of the third-layer wavelet coefficients after nonlinear enhanced wavelet decomposition, and Figure 6(e) shows the detection results of the improved method. Figures 6(b) and 6(d) show that the nonlinear enhancement process increases the amplitude difference between the QRS complex mode extreme value pair and the P wave mode extreme value pair, and has a stronger discrimination ability than the traditional wavelet decomposition method. Figures 6(c) and 6(e) show that the traditional wavelet transform may misdetect the peak point when detecting the R peak, mistakenly detecting the P peak as the R peak point, while the nonlinear enhancement wavelet transform avoids the misdetection when detecting the R peak.
[0138] Affected by pathological and physiological factors, the morphology and characteristics of the QRS complex in ECG signals may exhibit dynamic changes, such as morphological variations and amplitude fluctuations. Figure 7(a) shows a portion of MIT-BIH 104 data, showing significant changes in the morphology of the QRS complex in the middle portion. Figure 7(b) shows the extreme value distribution of the third-layer wavelet coefficients of the MIT-BIH 104 ECG signal after nonlinear enhanced wavelet transform, showing significant differences between the modulus extreme value pair amplitudes of the QRS complex. These dynamic changes in the QRS complex result in significant differences between the decomposed wavelet coefficients and the extreme value pair amplitudes of the QRS matching. When locating the R peak, using a fixed threshold may not accurately screen the QRS peak. Adaptive thresholding can dynamically adjust the threshold based on information such as the identified QRS complex extreme value pair amplitude and the RR interval to adapt to these changes. However, relying solely on the extreme value pair amplitude to adjust the threshold, or performing a secondary backtracking search by halving the threshold, is still ineffective in detecting QRS complexes with smaller modulus extreme value pair amplitudes. To address these issues, a windowed adaptive threshold-based ECG R-peak detection method is proposed. This method dynamically adjusts the R-peak detection threshold by introducing a window mechanism. The windows are divided into normal windows and sudden change windows based on the degree of amplitude decrease of the extreme value pairs between each window. When a sudden change window is detected, the R-peak detection threshold for that window is adjusted to improve the detection capability of low-amplitude QRS complex modulus extreme value pairs. Furthermore, by combining a threshold adjustment method based on the amplitude of modulus extreme value pairs with a secondary backtracking search strategy, the R-peak detection threshold is further updated to better adapt to fluctuations in the amplitude of QRS complex modulus extreme value pairs and reduce the risk of missed detection.
[0139] Detection of sudden change windows in the electrocardiogram R peak detection interval; including:
[0140] To facilitate the implementation of the dynamic adjustment strategy of the ECG R peak detection threshold based on the window mechanism and better adapt to the local temporal variation characteristics of the QRS complex, the ECG signal is processed as an FDI every 10 seconds. According to statistical data, the longest RR cycle is about 1.5 seconds. Therefore, the FDI is set to a LAW of 2 seconds to ensure that each LAW contains at least one R peak. The division of FDI and LAW is as follows Figure 8 shown.
[0141] Under normal circumstances, the QRS complex morphology in the ECG signal varies minimally, and the amplitude differences between extreme pairs of wavelet coefficients within the FDI are relatively small. However, under the influence of pathological and physiological factors, the QRS complex morphology and amplitude characteristics may vary significantly, manifesting as large differences in the amplitudes of extreme pairs within the FDI. QRS extreme pairs are screened by setting an amplitude threshold. Extreme pairs with larger amplitudes do not affect the location of the R-peak, while extreme pairs with smaller amplitudes may be missed due to not meeting the threshold. Based on the above-described possibility of R-peak missed detection, a method is proposed to classify the FDI LAWs into normal windows and sudden change windows. LAWs within the FDI with no significant QRS complex changes, or with changes but with larger amplitudes of their corresponding extreme pairs, are defined as normal windows; LAWs with smaller amplitude extreme pairs are defined as sudden change windows. Normal windows and sudden change windows are classified based on the window detection threshold.
[0142] When dividing the normal window and the mutation window, first, extract the set The maximum and minimum values in each LAW are calculated, and their maximum and minimum values are calculated respectively; then, the mean of the maximum and minimum values of all LAWs in an FDI is calculated; if the maximum or minimum value in a LAW is lower than 1 / 3 of the corresponding mean, the LAW is determined to be a mutation window; otherwise, it is determined to be a normal window.
[0143] The calculation formula of the maximum value and minimum value in each LAW is shown in formula (6):
[0144]
[0145] In the formula, Ma windowk is the maximum value among the extreme values of the wavelet coefficients in the kth LAW; Min windowk is the minimum value among the extreme values within the k-th LAW; l is the window width of each LAW; k = 1, 2, ..., K, where K = 5 represents the total number of LAWs divided within the FDI;
[0146] The 1 / 3 of the mean of the maximum value of the wavelet coefficient extreme value in LAW is used as the window detection positive threshold W u , 1 / 3 of the mean of the minimum value is used as the window detection negative threshold W l , then the calculation of the window detection threshold is shown in formula (7):
[0147]
[0148]
[0149] Where A u is the mean of the maximum value set of all LAW wavelet coefficients in FDI, as Wu The standard of value; A l is the mean of the minimum value set, as T l The standard of value; 1 / 3 is the empirical constant; if the Max windowk <W u or|Min windowk |<|W l |, then the window is a mutation window. Figure 9(a) shows the division of the mutation window in the third-layer wavelet coefficient extreme value distribution of the first 10 seconds of the MIT-BIH 104 ECG signal. ③ and ④ LAWs are mutation windows, and ①, ②, and ③ are normal windows. Figure 9(b) shows the maximum value distribution curve of each LAW in (a). The vertical dashed line is the LAW boundary, the horizontal dashed line is the window detection threshold, and the red circle represents the location of the maximum value within each LAW. Because ③ and ④ are mutation windows, the maximum values of these two windows are below the horizontal dashed line.
[0150] The ECG signal is transformed using a wavelet transform to obtain the corresponding wavelet coefficients. R-peak detection is achieved by screening the modulus extreme value pairs corresponding to the QRS complex within the third-scale coefficients. To address the problem of missed detection of QRS complexes with small wavelet coefficient amplitudes, a dynamic adjustment strategy for the R-peak detection threshold based on a windowing mechanism is proposed. This strategy updates the R-peak detection threshold to improve the detection of modulus extreme value pairs of low-amplitude QRS complexes. This method dynamically adjusts the R-peak detection threshold based on the type of LAW within the FDI.
[0151] If all windows in FDI are normal windows, the positive and negative thresholds of the R-peak screening of FDI are set to 1 / 3 of the mean of the maximum and minimum values of the extreme values of the wavelet coefficients in each LAW, respectively, as shown in formula (8):
[0152]
[0153] Where, T u,1 Indicates the positive threshold for R peak screening, used to detect the maximum value of the QRS wave group modulus; T l,1 Indicates the negative threshold for R peak screening, which is used to detect the minimum value of the QRS wave group mode; 1 / 3 is an empirical constant; T u,1 and T l,1 As the initial threshold for R peak detection, each time an R peak is detected, the threshold is dynamically updated according to the amplitude of the extreme value pair that matches it, as shown in formula (9).
[0154] A u,i+1 =0.875·pos i +0.125·A u ;
[0155] A l,i+1 =0.875·neg i +0.125·Al ;
[0156]
[0157] Where A u,i It is the positive threshold standard adjusted according to the wavelet maximum value corresponding to the i-th R peak; A l,i is the negative threshold standard adjusted according to the wavelet minimum value corresponding to the i-th R peak; pos i is the wavelet maximum corresponding to the i-th R peak; neg i is the wavelet minimum corresponding to the i-th R peak; T u,i is the positive threshold adjusted according to the i-th R peak; T l,i is the negative threshold adjusted according to the i-th R peak; pos1 and neg1 are determined by the initial threshold T u,0 、T l,0 Obtained through screening;
[0158] If the FDI contains a mutation window, if multiple mutation windows appear continuously, they are merged into one mutation window; if multiple normal windows appear continuously, they are merged into one normal window; in the normal window, the R peak detection threshold is updated according to the dynamic adjustment strategy of formula (9); in the mutation window, the initial R peak screening positive threshold is set to 1 / 3 of the maximum value in the window, and the negative threshold is set to 1 / 3 of the minimum value in the window; in the mutation window, each time an R peak is detected, the threshold for the next R peak detection is adjusted according to its amplitude, as shown in formula (10):
[0159] M u,i+1 =0.875·pos i +0.125·M u ;
[0160] M l,i+1 =0.875·neg i +0.125·M l ;
[0161]
[0162] Where M u,i It is the positive threshold standard adjusted according to the wavelet maximum value corresponding to the i-th R peak in the mutation window; M l,i It is the negative threshold standard adjusted according to the wavelet minimum value corresponding to the i-th R peak in the mutation window; M u and M l are the maximum and minimum values in the mutation window respectively; pos i and neg i are the wavelet maximum and minimum corresponding to the i-th R peak in the mutation window, respectively. pos1 and neg1 are obtained by screening the initial R peak screening threshold of the mutation window; T u,iis the positive threshold adjusted according to the i-th R peak in the mutation window; T l,i is the negative threshold adjusted according to the i-th R peak within the mutation window.
[0163] ECG R peak location based on dynamic threshold; including:
[0164] When locating the R peak, the initial R peak screening threshold is used to filter the peaks within the detection range. The extreme value of is judged point by point. Then r i Points are points that meet the threshold conditions. i After the point, the search is for the first one that meets the threshold and and Point r with opposite sign j , 0.11s is the longest duration of the QRS complex; r i and r j It is a pair of modulus extreme value pairs, and the zero crossing point corresponds to the R peak position, realizing the electrocardiogram R peak positioning; according to the dynamic adjustment strategy of the R peak detection threshold based on the window extreme value, the next R peak screening threshold is updated to perform the next R peak detection.
[0165] To further detect missed and false detection points, a secondary backtracking search strategy is proposed, using four adjacent R peaks as an analysis unit to detect missed R peaks. Each new analysis unit is composed of the last three peaks of the previous analysis unit plus the newly detected peak. When detecting missed R peaks, the RR interval between two adjacent peaks is compared with the average RR interval of the analysis unit. If the distance between the two peaks is greater than 1.6 times the average RR interval, it proves that there is a missed detection. At this time, the threshold amplitude is set to half of the original threshold and the search is repeated between the two R peaks. If the distance between the adjacent peaks is less than 0.4 times the average RR interval, it proves that there is a false detection. The point with the smaller peak is deleted, and the R peak and RR interval are recalculated to determine missed and false detections. Figure 10(a) shows the result of detecting R peaks in the detection interval using 1 / 3 of the maximum value as the screening threshold, and Figure 10(b) shows the R peak detection result based on the windowed adaptive threshold. Figures 10(a) and 10(b) show that when a fixed threshold of 1 / 3 of the maximum value is used to detect R peaks, the QRS morphology changes within the detection interval, leading to missed detection of R peaks in the middle portion. However, the windowed adaptive threshold method dynamically adjusts the threshold based on the window type, effectively adapting to QRS complex fluctuations and avoiding missed detections.
[0166] The algorithm proposed in this paper was verified in the MATHLAB simulation software based on the public database MIT-BIH. The R-peak detection algorithm based on nonlinear enhanced wavelet transform and windowed adaptive threshold was implemented and verified in the MIT-BIH database. The accuracy (Acc) was used as the algorithm evaluation index, which directly reflects the probability of the algorithm correctly identifying the waveform in actual application. Its calculation formula is as follows:
[0167]
[0168] Where Acc is the accuracy of R-peak detection; TP is the number of correct detections; FP is the number of false detections; and FN is the number of missed detections.
[0169] There are some errors in the R peak annotation of the original dataset of MIT-BIH Arrhythmia Database, such as Figure 11 As shown. The cardiology experts of Qingdao University Medical College in the research team revised it, as shown in the following figure. Figure 12 shown.
[0170] The proposed R-peak detection algorithm based on nonlinear wavelet transform was used to detect R-peaks in the ECG records of the database. Figure 13(a) shows the comparison of R-peak detection results with expert annotations for a portion of the MIT-BIH 228 dataset, and Figure 13(b) shows the comparison of R-peak detection results with expert annotations for a portion of the MIT-BIH 200 dataset. The detection results were compared with the corrected annotations. The R-peak detection results are shown in Table 1.
[0171] Table 1
[0172]
[0173]
[0174]
[0175] The R-peak detection accuracy of the algorithm proposed in the present invention is 99.733%, which is superior to the traditional wavelet transform method. It can effectively overcome the challenges brought by noise, P / T wave interference and QRS wave morphology variation when detecting R-peak.
Claims
1. An electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold, characterized in that: include: (1) ECG signal data acquisition and preprocessing Acquire ECG signals and perform denoising on the ECG signals; (2) R-peak candidate point detection based on nonlinear enhanced wavelet transform The preprocessed ECG signal is decomposed into four layers using biorthogonal spline wavelet as basis function, and the decomposed signal is interpolated to restore the wavelet coefficient length to the same as the original signal. Among the four scales of wavelet decomposition, the wavelet coefficients at the third scale are selected for analysis to locate the R peak. The wavelet coefficients at the third scale are subjected to a polarity-preserving square operation supplemented by a sliding window integral process. The modulus maxima and minima of the wavelet coefficients at the third scale are extracted, and the modulus maxima and minima that match the QRS wave through threshold screening are paired to form modulus extreme value pairs, with the zero-crossing points being the R peak candidates. (3) R-peak positioning based on windowed adaptive threshold A fixed interval is used to perform segmented R peak detection on the ECG signal. In each fixed detection interval FDI, a local analysis window LAW is divided, and the average value of the extreme value to the maximum value in each LAW is used as the standard to set the threshold. The window with the extreme value less than the threshold is defined as a mutation window, and the window with the extreme value greater than the threshold is defined as a normal window; If all windows within the FDI are normal, the initial threshold for R-peak detection within the FDI is set to 1 / 3 of the mean of the extreme value to the maximum value within each LAW, and the threshold is dynamically updated during the detection process; If the FDI includes a mutation window, the initial threshold of the R-peak detection threshold in the normal window is set to 1 / 3 of the average of the maximum value of the extreme value pairs in each LAW, and the threshold is dynamically updated within the window; the initial threshold in the mutation window is set to 1 / 3 of the maximum value of the extreme value pairs in the window, and the dynamic update mechanism is also used within the window; At the same time, the changes in the RR interval are monitored. When the current RR interval is detected to be 1.6 times higher than the average RR interval, the detection threshold is temporarily adjusted to 50% of the original value. When the current RR interval is detected to be lower than 0.4 times the average RR interval, the detection points with smaller peak values are eliminated.
2. The electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold according to claim 1, characterized in that: The ECG signals are from the MIT-BIH arrhythmia database.
3. The electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold according to claim 1, characterized in that: R-peak candidate point detection based on nonlinear enhanced wavelet transform; including: Mallat multi-scale decomposition of ECG signals; including: The Mallat decomposition algorithm is used to decompose the ECG signal at multiple scales, and the decomposed signal is subjected to a binary interpolation operation to restore the wavelet coefficient length to be consistent with the original signal, so as to achieve the alignment of the wavelet coefficient and the ECG signal on the time axis. The Mallat decomposition algorithm is used to decompose the ECG signal at multiple scales as shown in formulas (I) and (II). Where a (j) is the approximate coefficient at the jth scale, where a (0) [n] = x[n], which represents the original one-dimensional discrete ECG signal; n is the discrete time index of the signal at the current scale, indicating the location of the sample point; k is the index variable of the filter kernel; d (j) is the detail coefficient at the jth scale, which is the wavelet coefficient used for R-peak positioning; h0 is the coefficient of the quadratic B-spline decomposition low-pass filter [1 / 4 3 / 4 3 / 4 1 / 4]; h1 is the coefficient of the quadratic B-spline decomposition high-pass filter [-1 / 4 3 / 4 3 / 4-1 / 4].
4. The electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold according to claim 1, characterized in that: The wavelet coefficients on the third scale are subjected to a square operation based on preserving polarity, supplemented by a sliding window integration process; including: (1) Square enhancement processing of the third-scale wavelet coefficients to preserve polarity; Extract and retain the positive and negative polarity, the wavelet coefficient polarity is based on the third scale wavelet coefficient d (3) [n] value is determined when d (3) When [n] is greater than zero, the polarity value is 1, d (3) When [n] is less than zero, the polarity value is -1, otherwise its polarity is equal to 0, as shown in formula (III): In the formula, sign(d (3) ) indicates the polarity of the signal; The nonlinear enhancement of wavelet coefficients based on polarity preservation is obtained by squaring the wavelet coefficients while retaining the original wavelet coefficients, as shown in formula (IV): in, is the enhanced wavelet coefficient, sign(d (3) [n]) is the polarity sign of the original wavelet coefficient, d (3) [n] is the original third-scale wavelet coefficient; (2) Improvement of the discrimination of wavelet coefficients based on sliding window integration; The enhanced third layer wavelet coefficients Perform sliding integration processing; as shown in formula (V): Where T is the integration window width, which is half the average width of the QRS complex; N is the number of samples within the integration window width; n represents the discrete time index corresponding to the end moment of the current integration window; Represents the enhanced third layer wavelet coefficients The result after sliding integration processing.
5. The electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold according to claim 1, characterized in that: Threshold-based ECG R-peak candidate point screening; include: The nonlinear enhanced wavelet coefficients are obtained by sign-preserving squaring and sliding window integration. Nonlinear enhancement of wavelet coefficients The zero crossing point between the maximum and minimum points corresponds to the R peak of the QRS complex; Nonlinear enhancement of wavelet coefficients Perform extreme value detection operations, retain the maximum and minimum values, and set the remaining values to 0 to form a set Use threshold The extreme points of the R peak are judged point by point, and the maximum point and the minimum point whose amplitude meets the threshold are paired to form an extreme pair. The zero crossing point of the extreme pair corresponds to the R peak, which is the candidate R peak point of the electrocardiogram.
6. The electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold according to claim 1, characterized in that: Detection of sudden change windows in the electrocardiogram R peak detection interval; including: When dividing the normal window and the mutation window, first, extract the set The maximum and minimum values in each LAW are calculated, and their maximum and minimum values are calculated respectively; then, the mean of the maximum and minimum values of all LAWs in an FDI is calculated; if the maximum or minimum value in a LAW is lower than 1 / 3 of the corresponding mean, the LAW is determined to be a mutation window; otherwise, it is determined to be a normal window.
7. The electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold according to claim 6, characterized in that: The calculation formula of the maximum value and minimum value in each LAW is shown in formula (6): Where Max windowk is the maximum value among the extreme values of the wavelet coefficients in the kth LAW; Min windowk is the minimum value among the extreme values within the k-th LAW; l is the window width of each LAW; k = 1, 2, ..., K, where K = 5 represents the total number of LAWs divided within the FDI; The 1 / 3 of the mean of the maximum value of the wavelet coefficient extreme value in LAW is used as the window detection positive threshold W u , 1 / 3 of the mean of the minimum value is used as the window detection negative threshold W l , then the calculation of the window detection threshold is shown in formula (7): Where A u is the mean of the maximum value set of all LAW wavelet coefficients in FDI, as W u The standard of value; A l is the mean of the minimum value set, as T l The standard of value; 1 / 3 is the empirical constant; if the Max windowk <W u or|Min windowk |<|W l |, then the window is a mutation window.
8. The electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold according to claim 7, characterized in that: If all windows in FDI are normal windows, the positive and negative thresholds of the R-peak screening of FDI are set to 1 / 3 of the mean of the maximum and minimum values of the extreme values of the wavelet coefficients in each LAW, respectively, as shown in formula (8): Where, T u,1 Indicates the positive threshold for R peak screening, used to detect the maximum value of the QRS wave group modulus; T l,1 Indicates the negative threshold for R peak screening, used to detect the minimum value of the QRS wave group mode; 1 / 3 is an empirical constant; T u,1 and T l,1 As the initial threshold for R peak detection, each time an R peak is detected, the threshold is dynamically updated according to the amplitude of the extreme value pair that matches it, as shown in formula (9). A u,i+1 =0.875·pos i +0.125·A u ; A l,i+1 =0.875·neg i +0.125·A l ; Where A u,i It is the positive threshold standard adjusted according to the wavelet maximum value corresponding to the i-th R peak; A l,i is the negative threshold standard adjusted according to the wavelet minimum value corresponding to the i-th R peak; pos i is the wavelet maximum corresponding to the i-th R peak; neg i is the wavelet minimum corresponding to the i-th R peak; T u,i is the positive threshold adjusted according to the i-th R peak; T l,i is the negative threshold adjusted according to the i-th R peak; pos1 and neg1 are determined by the initial threshold T u,0 、T l,0 Obtained through screening; If the FDI contains a mutation window, if multiple mutation windows appear continuously, they are merged into one mutation window; if multiple normal windows appear continuously, they are merged into one normal window; in the normal window, the R peak detection threshold is updated according to the dynamic adjustment strategy of formula (9); in the mutation window, the initial R peak screening positive threshold is set to 1 / 3 of the maximum value in the window, and the negative threshold is set to 1 / 3 of the minimum value in the window; in the mutation window, each time an R peak is detected, the threshold for the next R peak detection is adjusted according to its amplitude, as shown in formula (10): M u,i:1 =0.875·pos i +0.125·M u ; M l,i:1 =0.875·neg i +0.125·M l ; Where M u,i It is the positive threshold standard adjusted according to the wavelet maximum value corresponding to the i-th R peak in the mutation window; M l,i It is the negative threshold standard adjusted according to the wavelet minimum value corresponding to the i-th R peak in the mutation window; M u and M l are the maximum and minimum values in the mutation window respectively; pos i and neg i are the wavelet maximum and minimum corresponding to the i-th R peak in the mutation window, respectively. pos1 and neg1 are obtained by screening the initial R peak screening threshold of the mutation window; T u,i is the positive threshold adjusted according to the i-th R peak in the mutation window; T l,i is the negative threshold adjusted according to the i-th R peak within the mutation window.
9. The electrocardiogram R-peak detection method based on nonlinear enhanced wavelet transform and windowed adaptive threshold according to any one of claims 1 to 8, characterized in that: ECG R-peak location based on dynamic threshold; including: When locating the R peak, the initial R peak screening threshold is used to filter the peaks within the detection range. The extreme value of is judged point by point. Then r i Points are points that meet the threshold conditions. i After the point, the search is for the first one that meets the threshold and and Point r with opposite sign j , 0.11s is the longest duration of the QRS complex; r i and r j It is a pair of modulus extreme value pairs, and the zero crossing point corresponds to the R peak position, realizing the electrocardiogram R peak positioning; according to the dynamic adjustment strategy of the R peak detection threshold based on the window extreme value, the next R peak screening threshold is updated to perform the next R peak detection; The missed detection points and false detection points are further detected according to the secondary backtracking search strategy. The RR interval between two adjacent peaks is compared with the average RR interval. If the distance between the two peaks is greater than 1.6 times the average RR interval, it proves that there is a missed detection. At this time, the threshold amplitude is set to half of the original threshold, and the search is repeated between the two R peak points; if the distance between adjacent peaks is less than 0.4 times the average RR interval, it proves that there is a false detection, and the point with the smaller peak is deleted.