Research Article  Open Access
Zhou Zhang, Zeyu Li, Zhangyong Li, "An Improved RealTime RWave Detection Efficient Algorithm in Exercise ECG Signal Analysis", Journal of Healthcare Engineering, vol. 2020, Article ID 8868685, 7 pages, 2020. https://doi.org/10.1155/2020/8868685
An Improved RealTime RWave Detection Efficient Algorithm in Exercise ECG Signal Analysis
Abstract
Rwave detection is a prerequisite for the extraction and recognition of ECG signal feature parameters. In the analysis and diagnosis of exercise electrocardiograms, accurate and realtime detection of QRS complexes is very important for the prevention and monitoring of heart disease. This paper proposes a lightweight Rwave realtime detection method for exercise ECG signals. After realtime denoising of the exercise ECG signal, the median line is used to correct the baseline, and the firstorder difference processing is performed on the differential square signal. MaxMin Threshold (MMT) is used to realize realtime Rwave detection of the exercise ECG signal. The abovementioned method was verified by using the measured data in the MITBIH ECG database of the Massachusetts Institute of Technology and the exercise plate experiment. The Rwave detection rates were 99.93% and 99.98%, respectively. Experimental results show that this method has high accuracy and low computational complexity and is suitable for wearable devices and motion process monitoring.
1. Introduction
ECG (Electrocardiogram) represents the myocardial electrical activity of the heart. ECG signals play an important role in the diagnosis of cardiovascular diseases, such as arrhythmia, hypertension, or ischemic heart disease. ECG recording used to be a timeconsuming process that required an onsite cardiologist to detect and diagnose various types of heart disease. Today, ECG signals can be recorded using mobile ECG sensors, such as Shimmer sensor or Alivecor sensor [1]. These sensors are not only easy to use but also economical and efficient to obtain ECG signals. However, these sensors mainly use only 1 or 2 leads (usually lead I or lead II) for recording, rather than all standard 12lead, resulting in a poor detection performance of some QRS detection algorithms. Therefore, realtime detection and anomaly analysis of the QRS waveform is a challenging task [2].
QRS detection has become a research topic in the field of intelligent ECG detection for more than 30 years. In the meantime, researchers have developed a number of algorithms, for example, based on the digital filter [3], wavelet transform [4, 5], neural network [6–8], image segmentation [9], and so on. Tang et al. proposed a parallel incremental modulator architecture with local maximum point and local minimum point algorithms to detect QRS and PT waves [10]; Kalidas and Tamil proposed an online QRS detector algorithm using stationary wavelet transform (SWT) for realtime heartbeat detection from a single lead ECG signal [4]; Muhammad et al. proposed the use of transient phasor transformation to study the location of characteristic points (reference points) of ECG signals [11]. However, most of the studies are only applicable to the static ECG signal for a long time, and the processing ability of motion interference is not strong. Moreover, the abovementioned methods require additional process steps, such as training, setting, and predicting model parameters, when detecting Rwaves, which increases the complexity of calculation load and computing cost [12].
The Rwave in the QRS waveform plays an important role in the diagnosis of arrhythmia and the recognition of heart rate variability. Due to the rise of wearable devices, the noninvasive exercise tablet experiment (stress test) and the high prediction of coronary heart disease and other diseases, wearable devices, and exercise tablet experiment have gradually become popular in the detection of the cardiovascular function. However, mobile devices are used to detect the ECG activity of patients in their daily life, rather than in the isolated hospital environment. As a result, various electrical signal noises in the environment will seriously interfere with ECG signals. Exercise ECG detection will cause the ECG signals of patients to be interfered by the electrical signals generated by human muscle movements during exercise, which will lead to a sharp increase in detection Windows, thus increasing the possibility of detecting errors and detecting omissions by the traditional Rwave detection algorithm [13].
Aiming at the characteristics of difficulty in realtime detection and abnormal analysis of single lead of motion electrocardiogram, large motion interference, and high computing cost, this paper proposes a lightweight adaptive MaxMin Threshold (MMT) algorithm for Rwave detection of a motion ECG signal, which is an optimization of the differential threshold method for Rwave detection. Compared with the traditional Rwave detection algorithm, the algorithm proposed in this paper has lower operation cost, higher antienvironment interference and antimotion interference ability, and is suitable for the medium and longterm exercise ECG detection on the mobile ECG sensor. In order to determine the detection efficiency, the algorithm performed the exercise ECG acquisition and realtime Rwave detection on the exercise plate. Meanwhile, the ECG data from the MITBIH arrhythmia database were used for Rwave detection.
2. Lightweight RWave Detection Method
The detection of Rwaves in ECG signals presents many challenges, such as EMG interference [14], powerfrequency interference, and baseline drift, which can affect signal primitiveness. These noises are the difficulties in the automatic detection of ECG signals. Due to the large body swing and electrode friction caused by movement, the noise is particularly prominent in the motion ECG signals.
This paper proposes an adaptive MMT difference algorithm to detect Rwave, which includes the following steps: the whole algorithm process of preprocessing baseline correction for Rwave detection is shown in Figure 1.
Firstly, in order to eliminate the noise embedded in the ECG signal and enhance the ECG signal, digital filters with appropriate parameters and adaptive filters are usually used to eliminate the noise [15]. In this paper, an FIR filter and Notch filter are used to eliminate EMG interference and powerfrequency interference in the ECG signal. This process has a large amount of ECG processing capacity and a lot of detail processing, but it does not affect the detection of Rwave. In addition, the calculation cost of the filtering process is lower and the space occupancy is less.
Secondly, a baseline drift can greatly interfere with overall Rwave detection, for which a sliding window is used to overcome the baseline drift. The ECG baseline was extracted from the ECG through the sliding window, and the difference between the original signal and the ECG baseline was calculated to obtain the ECG signal after the baseline was more positive.
Finally, the amplitude of the Rwave varies from person to person, and the amplitude of the Rwave varies greatly from person to person at different times. Therefore, it is very important to find the appropriate threshold. In this paper, through adaptive multithreshold to cope with different scenarios, different populations, and different collection patterns, the Rwave is accurately calculated.
2.1. Pretreatment
Based on the powerfrequency interference and myoelectric interference existing in the ECG acquisition process, the Rwave detection is greatly affected, so pretreatment is needed to eliminate the corresponding interference. This section will discuss the powerfrequency interference and myoelectric interference in the ECG acquisition process and how to remove the noise.
2.1.1. PowerFrequency Interference
Frequency interference at 50 Hz is usually eliminated before further analysis and processing of the signal [16]. In addition, the basic principle of an adaptive Notch filter is a center frequency of an orthogonal signal as the reference signal, using the linear combination of the orthogonal signal tracking the input signal, and through every step of the residual, continuously adjust the weights of linear combination, so as to make the input signal related to the reference signal linear part of the separation, to achieve the effect of a narrowband filter.
In this paper, a Notch filter is used to filter the received ECG signal, so as to eliminate the capacitance and electrode lead loop distributed in the human body from 50 Hz powerfrequency interference such as powerfrequency electricity and magnetic field. According to the Notch filter selected, its filtering effect is shown in Figure 2.
(a)
(b)
2.1.2. EMG Interference
Because FIR and IIR filters show maximum signaltonoise ratio improvement when used to eliminate interference, these simple filters are commonly used for ECG signal noise reduction [17].
A finite impulse response (FIR) filter is to perform weighted and average processing on N sampled data, in which the input signal is temporal and changes with the change of time. The final output of the FIR filter is the input at each moment multiplied by the corresponding weight (coefficient), then superimposed, and finally, output. The difference equation can be expressed as follows:
The low pass filter of an FIR is adopted to eliminate the noise greater than 100 Hz which does not belong to the range of the ECG signal. The filter is of order 40, with a sensitivity factor of 40, a sampling frequency (FS) of 500 Hz, a passband frequency (Fpass) of 6, a stopband frequency (Fstop) of 100, a passband waste (Wpass) of 3 db, and a stopband waste (Wstop) of 1 db. According to the optimal approximation method of FIR and other ripples selected, its filtering effect is shown in Figure 3.
(a)
(b)
2.2. Baseline Correction
Baseline drift often occurs in the motion ECG signal, especially when the subject swings too much and the lead line wobbles more, resulting in a very serious baseline drift. Because median filtering can effectively discard outliers while retaining relevant information, median filtering has been widely used as a postprocessing operator in different fields [18] and is widely used in biomedical signal processing [19].
In this paper, the ECG signal end is wrapped by a large sliding window, and the median amplitude of the ECG data in the window is calculated as the baseline drift value of the middle position of the window. The baseline correction can be completed by subtracting the ECG amplitude from the baseline drift value. The algorithm of its window size W and ECG amplitude Y after removing baseline drift is as follows:where is the ECG signal sampling rate, time is the time length, index is the index value of the current realtime ECG record, and m meetswhere the value range of I is .
Window size W is an oddnumbered window, and its window should contain at least 0.6 s of sample data, which is helpful to calculate the baseline of the ECG signal.
2.3. RWave Detection
The detection process of the Rwave mainly includes window difference, initial threshold calculation, MMT detection of the Rwave, error correction, and adaptive threshold.
2.3.1. Window Difference
Signal differential algorithm is the first step to detect the Rwave. In this paper, a sliding window is used to wrap the differential data of the ECG signal, which can effectively reduce the memory consumption and improve the detection efficiency of realtime ECG. The difference amplitude Y algorithm is as follows:where X represents the ECG signal processed by using a Notch filter (Section 2.1.1) and FIR filter (Section 2.1.2).
In this paper, a window of size 3 is set up to record the difference amplitude, which is represented by , , and in the followup, where represents the largest difference amplitude that can be obtained.
2.3.2. Calculation of Initial Threshold
In this paper, three thresholds are adopted to determine the position of the Rwave: the maximum threshold of firstorder difference, the minimum threshold of firstorder difference, and the threshold of ECG amplitude. The initial process of the three thresholds is as follows:where is the maximum value of ECG after processing and and are the maximum and minimum values of differential signals, respectively.
Due to the characteristics of the finite unit impulse response (FIR) filter and adaptive Notch filter (Notch), the ECG signal 1s before recording should not be considered when calculating the threshold value.
2.3.3. MMT Detects RWaves
According to the maximum and minimum difference thresholds and obtained in Section 2.3.2, the maximum point in the range of amplitude of differential signals in a continuous period of time was calculated through the continuously input ECG signals, and the index of this point was recorded. The minimum point in the range of differential signal amplitude in a continuous period of time is calculated, and the index of this point is recorded. When and the range is within 0.2 ms, the maximum value of ECG after processing is calculated in the index range of point and . When , this point is considered to be point R.
2.3.4. Error Correction
In the detection of Rwave, some interference may lead to multiple detection and missed detection of the Rwave. In this paper, the error correction of the Rwave is carried out by the following methods. The index difference between the Rwave position and the previous Rwave position is recorded, and it is compared with the previous index difference .
If , there may be a missed judgment between this Rwave and the previous Rwave. At this time, the threshold value of reduction amplitude is 90% of the original threshold value for redetection. If , the gap between the point and the previous Rwave is too small, which is considered as a misjudgment.
2.3.5. Adaptive Threshold
According to the amplitude and corresponding to the index and the index , as well as the amplitude of point R, the three thresholds , , and are updated adaptively according to the following formula:
Due to the difference in the amplitude of the Rwave in time, it is necessary to judge the amplitude of the current measured Rwave once in the abovementioned formula. If the amplitude of the Rwave is in the state of increasing (or decreasing) for two consecutive times, the adaptive updating of the threshold needs to be stopped.
3. Results and Discussion
3.1. Exercise ECG Data
A panel exercise test was performed on 10 test subjects using disposable button electrodes. The heart rate of the subject was increased through exercise, the V1 and V2 leads of the subject are recorded, and the Rwave of the ECG waveform of the subject is detected and displayed in realtime, as shown in Figure 4.
It can be seen from Table 1 that this algorithm has a good performance in 10 subjects of different genders, and it can effectively monitor and recognize the Rwaves of a total of 8619 ECG waveforms of 10 subjects. When the maximum heart rate was reached (195age) [20], the body swing amplitude of the subjects reached the maximum, and the ECG signal received the maximum interference. This algorithm also had a good performance, and the Rwave detection results were accurate. At the same time, the memory utilization is low in the detection process.

3.2. MITBIH Public Database
The MITBIH arrhythmia database contains 48 1/2 hours of excerpts from twochannel dynamic ECG recordings. The records are digitized with 360 samples per second per channel, with an 11bit resolution in the 10 mV range [21].The ANSI/AAMI/ISO EC57 : 1998/(R) 2008 standard states that the QRS detection algorithm must provide statistical reports from the MITBIH arrhythmia database [22].
In order to evaluate the performance of the proposed algorithm, common detector performance measurements are applied and defined as follows [23].
Sensitivity (Se) represents the percentage of events detected:
Positive prediction represents the score of the test, that is, the event:where TP is the number of true positive beats (correct detection), FN is the number of false negative beats (false detection), and FP is the number of false positive beats (missed detection) [10].
As can be seen from Table 2, this algorithm successfully detected 47,398 Rwaveforms in 47,498 QRSwaveforms, indicating that this algorithm can correctly detect the vast majority of Rwaveforms. In addition, Table 3 shows a quantitative comparison of the algorithms presented in this paper with those proposed by Pandit and Lai. The values of Se and in this paper reach 99.70% and 99.93%, while Pandit’s and Lai’s algorithms are 99.62% and 99.67% and 99.69% and 99.63%, respectively. The algorithms of Pandit and Lai are both Rwave recognition algorithms based on differential thresholds. In the Rwave detection results, the method of this paper has improved by 0.05% and 0.3% on average.

4. Conclusions
This paper presents a lightweight adaptive MMT ECG signal Rwave detection algorithm. After denoising the ECG signal and correcting the baseline, the algorithm performs firstorder difference processing, detects the Rwave through the maximum and minimum difference threshold, and updates the threshold according to the index information of the Rwave. The algorithm of Rwave detection in an athletic flat test is in good condition, and in the MIT/BIH database of 21 ECG data detection, through comparing with Pandit algorithm and Lai algorithm, the presented method of Rwave identification not only is of high sensitivity (Se) and high positive predictive but also has advantages in terms of computing requirements.
In addition, it can be seen from Figure 5 that this algorithm shows a strong antiinterference capability in the detection of moving plate experiment and can effectively reduce the ECG noise and baseline drift brought by movement, so that it can effectively detect and monitor the ECG in different motion states. At the same time, the operation speed and resource share of the algorithm can guarantee the realtime and durability of ECG monitoring.
(a)
(b)
It is important to note that the algorithm of Rwave detection is faulty in some occasions, such as MITBIH database in 203 and 205 of two groups of ECG data waveform, the waveform memory is intermittent Rwave inversion, the phenomenon of greater influence on the sensitivity of the proposed algorithm, leads to recognition of the Rwave in 203 and 205 groups of data, and the sensitivity of 99.00% and 98.04%, as shown in Figure 5.
In summary, Rwave detection was evaluated on the existing standard MITBIH database. The algorithm has a relatively high performance, with 99.70% sensitivity and 99.93% positive predictability, showing obvious advantages. In addition, its low computational requirements and good antiinterference capability make it easy to deploy and implement in portable monitoring and motion monitoring applications. We will further study the limitations of the current algorithm in order to develop a more complete and practical algorithm.
Data Availability
The ECG data used to support the findings of this study have been deposited in the MITBIT repository.
Conflicts of Interest
The authors declare that there are no conflicts of interest regarding the publication of this paper.
Acknowledgments
This research was funded by the National Natural Science Foundation of China under grants no. 61571070. This research was also funded by the Scientific Research and Innovation Project of Chongqing, China (project no. CYS19256).
References
 S. Gradl, P. Kugler, C. Lohmüller, and B. Eskofier, “Realtime ECG monitoring and arrhythmia detection using androidbased mobile devices,” in Proceedings of the 2012 Annual International Conference of the IEEE Engineering in Medicine and Biology Society, pp. 2452–2455, San Diego, CA, USA, August 2012. View at: Publisher Site  Google Scholar
 D. Pandit, L. Zhang, C. Liu, S. Chattopadhyay, N. Aslam, and C. P. Lim, “A lightweight QRS detector for single lead ECG signals using a maxmin difference algorithm,” Computer Methods and Programs in Biomedicine, vol. 144, pp. 61–75, 2017. View at: Publisher Site  Google Scholar
 M. Marouf and L. Saranovac, “Adaptive EMG noise reduction in ECG signals using noise level approximation,” in Proceedings of the 2017 International Conference on Robotics and Machine Vision, Kitakyushu, Japan, December 2017. View at: Publisher Site  Google Scholar
 V. Kalidas and L. Tamil, “Realtime QRS detector using stationary wavelet transform for automated ECG analysis,” in Proceedings of the 2017 IEEE 17th International Conference on Bioinformatics and Bioengineering, pp. 457–461, Washington, DC, USA, October 2017. View at: Publisher Site  Google Scholar
 S. Sabut, S. Sahoo, B. Kanungo et al., “Multiresolution wavelet transform based feature extraction and ECG classification to detect cardiac abnormalities,” Measurement, vol. 108, pp. 55–66, 2017. View at: Publisher Site  Google Scholar
 M. Šarlija, F. Jurišić, and S. Popović, “A convolutional neural network based approach to QRS detection,” in Proceedings of the 10th International Symposium on Image and Signal Processing and Analysis, pp. 121–125, Ljubljana, Slovenia, September 2017. View at: Publisher Site  Google Scholar
 P. Silva, E. Wanner, D. Menotti et al., “QRS detection in ECG signal with convolutional network,” Iberoamerican Congress on Pattern Recognition, Springer, Madrid, Spain, 2018. View at: Publisher Site  Google Scholar
 Y. Xiang, L. Zhitao, and M. Jianyi, “Automatic QRS complex detection using twolevel convolutional neural network,” Biomedical Engineering Online, vol. 17, no. 1, pp. 1–17, 2018. View at: Publisher Site  Google Scholar
 M. SaadatmandTarzjan, N. Rashidi, and M. Iqbal, “A novel parametric deformable model based on calculus of variations for QRS detection,” Iranian Journal of Science and Technology, Transactions A: Science, vol. 43, no. 3, pp. 1101–1107, 2019. View at: Publisher Site  Google Scholar
 X. Tang, Q. Hu, and W. Tang, “A realtime QRS detection system with PR/RT interval and ST segment measurements for wearable ECG sensors using parallel delta modulators,” IEEE Transactions on Biomedical Circuits and Systems, vol. 12, no. 4, pp. 751–761, 2018. View at: Publisher Site  Google Scholar
 M. Kashif, S. Jonas, and T. Deserno, “Deterioration of Rwave detection in pathology and noise: a comprehensive analysis using simultaneous truth and performance level estimation,” IEEE Transactions on Biomedical Engineering, vol. 64, no. 9, pp. 2163–2175, 2017. View at: Publisher Site  Google Scholar
 A. K. Dohare, V. Kumar, and R. Kumar, “An efficient new method for the detection of QRS in electrocardiogram,” Computers & Electrical Engineering, vol. 40, no. 5, pp. 1717–1730, 2014. View at: Publisher Site  Google Scholar
 J. Moeyersons, E. Smets, J. Morales et al., “Artefact detection and quality assessment of ambulatory ECG signals,” Computer Methods and Programs in Biomedicine, vol. 182, Article ID 105050, 2019. View at: Publisher Site  Google Scholar
 G. M. Friesen, T. C. Jannett, M. A. Jadallah, S. L. Yates, S. R. Quint, and H. T. Nagle, “A comparison of the noise sensitivity of nine QRS detection algorithms,” IEEE Transactions on Biomedical Engineering, vol. 37, no. 1, pp. 85–98, 1990. View at: Publisher Site  Google Scholar
 S. Sahoo, P. Biswal, T. Das, and S. Sabut, “Denoising of ECG signal and QRS detection using hilbert transform and adaptive thresholding,” Procedia Technology, vol. 25, pp. 68–75, 2016. View at: Publisher Site  Google Scholar
 Z. Peng and G. Wang, “Study on optimal selection of wavelet vanishing moments for ECG denoising,” Scientific Reports, vol. 7, no. 1, pp. 45–64, 2017. View at: Publisher Site  Google Scholar
 N. Das and M. Chakraborty, “Performance analysis of FIR and IIR filters for ECG signal denoising based on SNR,” in Proceedings of the 2017 International Conference on Research in Computational Intelligence & Communication Networks, pp. 90–97, Kolkata, India, November 2017. View at: Publisher Site  Google Scholar
 C. Pasquini, G. Boato, N. Alajlan et al., “A deterministic approach to detect median filtering in 1D data,” IEEE Transactions on Information Forensics and Security, vol. 11, no. 7, pp. 1425–1437, 2017. View at: Publisher Site  Google Scholar
 T. Pander, “The class of Mfilters in the application of ECG signal processing,” Biocybernetics & Biomedical Engineering, vol. 26, no. 4, pp. 3–13, 2006. View at: Google Scholar
 H. Tanaka, K. D. Monahan, and D. R. Seals, “Agepredicted maximal heart rate revisited,” Journal of the American College of Cardiology, vol. 37, no. 1, pp. 153–156, 2001. View at: Publisher Site  Google Scholar
 G. B. Moody and R. G. Mark, “The impact of the MITBIH arrhythmia database,” IEEE Engineering in Medicine and Biology Magazine, vol. 20, no. 3, pp. 45–50, 2001. View at: Publisher Site  Google Scholar
 “American national standard ANSI/AAMI EC 57:2012, testing and reporting performance results of cardiac rhythm and STsegment measurement algorithms,” 2017, https://webstore.ansi.org/RecordDetail.aspx?sku=CARDIO+MEDICAL+DEVICE+PACKAGE. View at: Google Scholar
 C. ChiehLi and C. ChunTe, “A QRS detection and R point recognition method for wearable singlelead ECG devices,” Sensors, vol. 17, no. 9, p. 1969, 2017. View at: Publisher Site  Google Scholar
 D. Lai, F. Zhang, and C. Wang, “A realtime QRS complex detection algorithm based on differential threshold method,” in Proceedings of the 2015 IEEE International Conference on Digital Signal Processing (DSP), pp. 129–133, Singapore, July 2015. View at: Publisher Site  Google Scholar
Copyright
Copyright © 2020 Zhou Zhang et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.