Robust QRS complex detection in noisy electrocardiogram based on underdamped periodic stochastic resonance

: Robust QRS detection is crucial for accurate diagnosis and monitoring of cardiovascular diseases. During the detection process, various types of noise and artifacts in the electrocardiogram (ECG) can degrade the accuracy of algorithm. Previous QRS detectors have employed various filtering methods to minimize the negative impact of noise. However, their performance still significantly deteriorates in large-noise environments. To further enhance the robustness of QRS detectors on noisy electrocardiograms (ECGs), we proposed a QRS detection algorithm based on an underdamped. This method utilizes the period nonlinearity-induced stochastic resonance to enhance QRS complexes while suppressing noise and non-QRS components in the ECG. In contrast to neural network-based algorithms, our proposed algorithm does not rely on large datasets or prior knowledge. Through testing on three widely used ECG datasets, we demonstrated that the proposed algorithm achieves state-of-the-art detection performance. Furthermore, compared to traditional stochastic resonance-based method, our algorithm has increased noise robustness by 25% to 100% across various real-world


Introduction
Electrocardiogram (ECG) is a recording of the cardiac electrical activity and is commonly used to assess cardiovascular function and health [1][2][3].Besides cardiology, ECG is also instrumental in the diagnosis of other medical departments.For instance, changes in ECG can aid in determining the severity of fractures in orthopedic patients [4].ECG is also indispensable for health monitoring of intensive care patients, newborns, and elderly patients [5][6][7].ECG is also critical in diagnosing and predicting the prognosis of diabetic neuropathy [8].As an essential metric of ECG evaluation, both standard and instantaneous heart rates can be obtained by counting the number of QRS complexes on the ECG within a specific time frame [9].QRS complexes indicate the ventricular depolarization process, and their frequency should match the heartbeat frequency.Owing to the critical importance of a reliable clinical decision support system for patient diagnosis and monitoring [10,11], an algorithm that provides robust QRS detection results for the decision system is of utmost significance.However, the accurate automatic detection of QRS complexes is hampered by various forms of noise in practical applications.Based on existing reports [12][13][14], ECG information is primarily affected by three types of noise, namely, electrode motion artifacts, DC drift, and high-frequency noise.Factors such as movement of the body during measurement and external forces applied to the electrodes can cause some low-frequency components, ranging from 0 to 20 Hz, that form electrode motion artifacts [12,14].In the frequency range of 20 to 50 Hz, the electrochemical activity of muscle cells in bones can cause high-frequency noise [12,14], while DC drift noise can be observed at low frequencies between 8 and 50 Hz due to lead and body movement [13].Although many QRS detectors utilizing various traditional filters have been proposed, they often struggle to demonstrate stable robustness against one or two of the aforementioned three types of noise [15][16][17].This indicates that the traditional filters used in previous studies are not entirely successful in removing noise that overlaps with the QRS complex spectrum, posing significant challenges for accurate and automated heart rate detection from noisy ECG in real clinical environments [18].
Recently, a counterintuitive physical phenomenon called stochastic resonance (SR) has attracted the attention of scholars in the field of cardiac signal processing.The SR effect can transfer noise energy, which overlaps with the informative components in terms of spectral content, into the informative components themselves [19].Therefore, it can suppress in-band noise without sacrificing the informative content of ECG signals.Liao et al. first applied overdamped SR to the processing of noisy weak magnetocardiogram and successfully observed all characteristic waveforms in the presence of time-varying noise [20].In the field of electrocardiogram, Güngör et al. initially employed underdamped monostable SR (UMSR) for QRS complex detection [21].Even in the environment with artificially injected noise, the detector based on UMSR robustly localized the QRS complexes.Subsequent studies have also demonstrated the hardware feasibility of the QRS detectors with an SR module [22].In other fields, SR has also been extensively studied, such as signal enhancement [23][24][25], synchronization control [26][27][28], and noisy intelligent computing [29][30][31][32].It is worth noting that noise robustness enhancement brought about by nonlinearity-induced SR with a small number of stable states is generally limited [33].Particularly, in the case of monostable potentials, their lack of potential barrier can result in high output fidelity at the expense of sacrificing output signal-to-noise ratio (SNR) [34].In the context of QRS enhancement, the magnitude of the output amplitude is more important than the signal fidelity, as it directly determines the output SNR [20,22].
To further enhance the noise robustness, we propose an underdamped periodic SR (UPSR) module in this study to improve the performance of QRS detector under large noise environment.Compared to the traditional UMSR, the UPSR used in our proposed algorithm has infinite number of potential wells, which leads to a large noise margin for maintaining optimal performance.In comparison to neural network-based QRS detectors [35,36], the proposed method does not require a large amount of training data and complex network structures.By testing on three publicly available datasets, we demonstrate that our proposed method has superior performance and robustness in QRS complex detection compared to traditional methods.According to function difference, the entire process of our proposed method can be divided into two parts: the noise suppression part and the QRS localization part.Among them, the UPSR module serves as the core of the noise suppression part, and its mathematical expression is as follows:

UPSR module in QRS detector
where (), , and () are the nonlinear potential function, damping factor, and the trajectory of the UPSR output, respectively. is the standard deviation, also known as noise intensity, of the noise term () . 0 is a constant used to normalize the potential height according to the normalized amplitude of the input ().Owing to the opposite direction of (), () ′ can be considered as the damping force provided by the periodic nonlinearity.The damping factor  is used for tunning different damping effects for different parts of ECG.Specifically,  0 * 10, where  0 is a constant, is set for the section outside the QRS complex, while  0 /100 is set for the QRS complex.A larger value of  is used to suppress disturbances outside the target effective information, thus preventing noise spikes from being falsely identified as QRS complexes.Conversely, a smaller value of  is employed to reduce the damping effect of the UPSR module on QRS complexes, thereby reducing the occurrence of missed QRS complexes.Besides, the damping of the UPSR module can also be indirectly controlled by adjusting the shape of () through the modification of  , as illustrated in Figure 1b.By optimizing , we can configure different damping effects for ECG signals from different patients and recording conditions.Because the proposed QRS detection process is nonlinear, it inevitably causes changes in the morphology of the ECG. Figure 2 illustrates the morphological changes at different stages when applying the proposed algorithm to the ECG in the MIT-BIH Arrhythmia dataset.Firstly, as shown in Figure 2a,b, bandpass filters with cutoff frequencies of 0.05 and 100 Hz are used to remove out-ofband information without affecting the ECG morphology primarily concentrated within the passband.Secondly, the SR module suppresses noise and information outside the QRS complex.During this process, some high-frequency baseline variations are introduced, as shown in Figure 2c.To eliminate these high-frequency variations, a high-pass filter with a cutoff frequency of 10 Hz is applied.Finally, by applying a threshold, we can locate the QRS complexes, as shown in Figure 2d.

Numerical solver and optimizer
The SR function requires the use of numerical methods to solve it due to its complex nature.The Runge-Kutta fourth-order algorithm is commonly employed for solving such functions because of its accuracy and stability [37].For solving a Eq. ( 1), the solving process of Runge-Kutta fourth-order algorithm satisfies the following formula [38]: where [] and [] are discretized from and () , respectively.ℎ , which can provide a balance between accuracy and computational efficiency, is the calculation step size of the numerical solver.For the coefficients  1 ~8 and the entire solution process, Algorithm 1 described the detailed information for them.For the proposed QRS detector, the parameters to be optimized are concentrated in Algorithm 1 (, ℎ,  0 , ,  0 ).In our study, the parameter ranges for , ℎ,  0 , , and  0 are set to (0, 10], (0, 10], (0, 10], (0, 100], and (0, 10], respectively.For such a multi-parameter nonlinear dynamic module, it is challenging to determine the optimal parameters through empirical methods.Therefore, we employed an open-source Ant Lion Optimizer (ALO) toolbox to automate the parameter optimization process [39].This choice is motivated by the excellent performance of the ALO in optimizing the dynamics of SR-related systems [40,41].In the ALO algorithm, antlions grow by capturing ants, representing the potential optimal solutions reached by the algorithm.The ants represent variables that can be altered through random search.They are initially normalized using the following equation: where   and   are the maximum and minimum of random walk for  -th variable, respectively. represents -th iteration. and  are the upper and lower bound of random variable respectively, and they can be updated using information of antlion positions as follows: =    +    10   (7) where ,  and  represent the antlion position, convergence constant and the maximum iteration, respectively.During the iteration, the right sides of the Eqs.( 6) and ( 7) decrease gradually, leading to a closer distance between the antlion and ant.The antlion also updates its position to actively predate ants according to the average of random walk around each particular antlion and the antlion closest to the objective.
In the case of the QRS detector, a higher amplitude of QRS complexes indicates that they are more easily detectable.Therefore, the objective function of the optimizer is defined as follows: where  is the opposite of QRS complex SNR.The calculation of Eq. ( 8) involved 100 randomly chosen segments comprising the noise interval and QRS complex.Each segment for the QRS complex, centered around the identified R peak (referred to as   ), lasted for 100 ms.Additionally, 100 one-second noise intervals are arbitrarily selected from the ECG section outside the QRS complex for calculating the standard deviation.

QRS localization and evaluation
After undergoing all filtering processes, the QRS localization module applies a detection threshold to perform binary conversion of the ECG.In this study, the threshold was set to a constant value of 0.1.Consequently, points above 0.1 and below 0.1 are transformed into 1 and 0, respectively.For each segment with a value of 1, the center is defined as the position of the QRS complex, denoted as   .To verify the accuracy of QRS complex localization, the annotations in the dataset can be examined to determine the true positions of the QRS complexes, denoted as   .According to ANSI/AAMI EC38, EC57, and previous studies [42][43][44][45], it is considered valid if the distance between   and   is within 150 ms.Through the aforementioned comparison process, several basic statistical measures such as true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN) can be obtained.Subsequently, following commonly used evaluation metrics can be calculated based on the acquired statistical information:

Datasets
As widely used test datasets for QRS detectors, MIT-BIH Arrythmia [12], European ST-T (EDB) [46], and MIT-BIH Noise Stress Test (NST) [47] datasets were selected for this study, and their detailed information is provided in Table 1.The MIT-BIH Arrythmia dataset is collected from patients with cardiac arrhythmia, while the EDB dataset is collected from patients with myocardial ischemia.The collection of the MIT-BIH NST dataset primarily serves for analyzing ECG acquisition challenges under different noise conditions.To demonstrate the superior performance and noise robustness of our proposed algorithm, the testing was divided into two categories.The first category involved testing directly on the original dataset without injecting additional noise.The second category involved subjecting the proposed algorithm to noise stress testing by injecting additional noise.The process of injecting additional noise satisfies the following formula: where   () is the raw ECG signal in the dataset.() is the real-word noise sequence recorded in the MIT/BIH NST dataset.The three previously mentioned types of noise, namely muscle artifact (MA), baseline wander (BW), and electrode motion (EM) artifacts, were individually recorded in the MIT/BIH NST dataset.In this study, we considered the individual injection of the aforementioned three types of noise as well as the combined injection of all types of noise, resulting in four different scenarios.Even without injecting noise, the selected databases for ECG contain noise contamination from the acquisition process.Therefore, we compared the performance of the proposed algorithm with other state-of-the-art QRS detectors without injecting additional noise.Tables 2-4 respectively present the comparative results of different QRS detectors on datasets MIT-BIH Arrhythmia, EDB, and MIT-BIH NST.It is clear that both algorithms based on the SR effect outperform the other algorithms.This can be attributed to the SR-induced suppression of in-band noise.Additionally, the performance based on UMSR and UPSR shows no significant difference.This is because the SR-induced gain increases within a certain range with an increase in noise intensity, while the noise intensity in the original databases is relatively weak, resulting in a relatively weak SR effect.

Performance on MIT-BIH Arrhythmia database with injecting noise
Owing to the superior noise robustness of the UMSR-based QRS detector that has been demonstrated in previous studies compared to traditional algorithms such as Elgendi and Pan-Tomkins [21], we selected it as the comparative baseline for noise robustness testing in this work.Taking the MIT-BIH Arrhythmia dataset as an example, Figure 3a illustrates the sensitivity variation of the UMSR-based and UPSR-based QRS detectors when MA noise is injected.When the MA noise intensity  is relatively low, both SR modules achieve a sensitivity of 99.95% for the QRS detector.As  increases, the sensitivity of the UMSR-based QRS detector starts to decrease at  > 0.1, while the sensitivity of the UPSR-based QRS detector begins to decrease at  > 0.2.Similarly, as shown in Figures 3b,c, the predictivity and F1-score of the UPSR-based QRS detector exhibit a higher  value at the point of decrease compared to the UMSR-based QRS detector.This indicates that UPSR provides stronger robustness against MA noise for the QRS detector compared to traditional UMSR.As discussed in Section 3.2, the noise robustness of the SR-based QRS detectors can be evaluated by comparing the value of  at which the performance starts to degrade.In this work, considering that the F1-score combines sensitivity and predictive value, we define the value of  at which the F1score of the QRS detector starts to degrade as the robustness boundary   .Figure 7 presents the results of the noise stress testing on EDB and MIT-BIH NST datasets for the SR-based QRS detection algorithms.Clearly, under all test conditions, the   of the UPSR-based QRS detection algorithm is larger than that of the UMSR-based algorithm.This indicates that, similar to the case of MIT-BIH Arrhythmia dataset, our proposed UPSR can provide the QRS detector with stronger noise robustness compared to the traditional UMSR.

SR effect comparison between UMSR and UPSR
To investigate the enhancement effects of the two SR modules on QRS complexes, we defined the SNR gain of the ECG signal after SR module processing as ∆ .Figure 8 presents the relationship curve between ∆ and  for the two SR-based QRS detectors under different injected noise conditions.Clearly, as  increases, both UMSR and UPSR initially exhibit an increase in ∆ followed by a decrease, providing evidence of successfully induced SR effects [52].In related studies, the noise robustness of SR systems is typically considered to be positively correlated with the SNR gain of the processed signal [53].Therefore, this suggests that the UPSR achieves stronger noise robustness for the QRS detection algorithm compared to the UMSR by inducing a stronger SR effect.It is noteworthy that the complexity of the UPSR described in Algorithm 1 is the same as that of UMSR presented in reference [21].This implies that under identical optimization conditions, the UPSR-based QRS detector can achieve the same computational complexity as the UMSR-based QRS detector, i.e., O(n).

Figure 2 .
Figure 2. Morphological changes of ECG waveforms at the different stage of the UPSRbased QRS detection algorithm.

Figures 4 -
Figures 4-6present the performance variations of the two QRS detectors when injected with BW, EM, and mixed noise, respectively.The trends depicted in these three figures follow similar patterns as shown in Figure3.In all cases, the UPSR-based QRS detector consistently maintains better performance at larger  compared to the UMSR-based QRS detector.These results indicate that the UPSR module significantly improves the noise robustness of the QRS detection algorithm for ECG data with cardiac arrhythmias.

Figure 7 .
Figure 7. Robustness boundary D max of UMSR and UPSR-based QRS detector on the (a) EDB and (b) MIT-BIH NST datasets under different noise injection conditions.

Table 1 .
Information of three widely used benchmark ECG datasets.

Table 2 .
Performance comparison among different QRS detection methods on MIT-BIH Arrhythmia database.

Table 3 .
Performance comparison among different QRS detection methods on EDB database.

Table 4 .
Performance comparison among different QRS detection methods on MIT-BIH NST database.