Internet of Medical Things for Healthcare EngineeringView this Special Issue
Research Article | Open Access
Zhou Zhang, Zeyu Li, Zhangyong Li, "An Improved Real-Time R-Wave 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 Real-Time R-Wave Detection Efficient Algorithm in Exercise ECG Signal Analysis
R-wave detection is a prerequisite for the extraction and recognition of ECG signal feature parameters. In the analysis and diagnosis of exercise electrocardiograms, accurate and real-time detection of QRS complexes is very important for the prevention and monitoring of heart disease. This paper proposes a lightweight R-wave real-time detection method for exercise ECG signals. After real-time denoising of the exercise ECG signal, the median line is used to correct the baseline, and the first-order difference processing is performed on the differential square signal. Max-Min Threshold (MMT) is used to realize real-time R-wave detection of the exercise ECG signal. The abovementioned method was verified by using the measured data in the MIT-BIH ECG database of the Massachusetts Institute of Technology and the exercise plate experiment. The R-wave 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.
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 time-consuming process that required an on-site 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 . 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 12-lead, resulting in a poor detection performance of some QRS detection algorithms. Therefore, real-time detection and anomaly analysis of the QRS waveform is a challenging task .
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 , wavelet transform [4, 5], neural network [6–8], image segmentation , 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 ; Kalidas and Tamil proposed an online QRS detector algorithm using stationary wavelet transform (SWT) for real-time heartbeat detection from a single lead ECG signal ; Muhammad et al. proposed the use of transient phasor transformation to study the location of characteristic points (reference points) of ECG signals . 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 R-waves, which increases the complexity of calculation load and computing cost .
The R-wave 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 R-wave detection algorithm .
Aiming at the characteristics of difficulty in real-time detection and abnormal analysis of single lead of motion electrocardiogram, large motion interference, and high computing cost, this paper proposes a lightweight adaptive Max-Min Threshold (MMT) algorithm for R-wave detection of a motion ECG signal, which is an optimization of the differential threshold method for R-wave detection. Compared with the traditional R-wave detection algorithm, the algorithm proposed in this paper has lower operation cost, higher anti-environment interference and anti-motion interference ability, and is suitable for the medium and long-term exercise ECG detection on the mobile ECG sensor. In order to determine the detection efficiency, the algorithm performed the exercise ECG acquisition and real-time R-wave detection on the exercise plate. Meanwhile, the ECG data from the MIT-BIH arrhythmia database were used for R-wave detection.
2. Lightweight R-Wave Detection Method
The detection of R-waves in ECG signals presents many challenges, such as EMG interference , power-frequency 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 R-wave, which includes the following steps: the whole algorithm process of preprocessing baseline correction for R-wave 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 . In this paper, an FIR filter and Notch filter are used to eliminate EMG interference and power-frequency 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 R-wave. 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 R-wave 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 R-wave varies from person to person, and the amplitude of the R-wave 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 R-wave is accurately calculated.
Based on the power-frequency interference and myoelectric interference existing in the ECG acquisition process, the R-wave detection is greatly affected, so pretreatment is needed to eliminate the corresponding interference. This section will discuss the power-frequency interference and myoelectric interference in the ECG acquisition process and how to remove the noise.
2.1.1. Power-Frequency Interference
Frequency interference at 50 Hz is usually eliminated before further analysis and processing of the signal . 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 narrow-band 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 power-frequency interference such as power-frequency electricity and magnetic field. According to the Notch filter selected, its filtering effect is shown in Figure 2.
2.1.2. EMG Interference
Because FIR and IIR filters show maximum signal-to-noise ratio improvement when used to eliminate interference, these simple filters are commonly used for ECG signal noise reduction .
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.
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  and is widely used in biomedical signal processing .
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 real-time ECG record, and m meetswhere the value range of I is .
Window size W is an odd-numbered 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. R-Wave Detection
The detection process of the R-wave mainly includes window difference, initial threshold calculation, MMT detection of the R-wave, error correction, and adaptive threshold.
2.3.1. Window Difference
Signal differential algorithm is the first step to detect the R-wave. 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 real-time 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 follow-up, 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 R-wave: the maximum threshold of first-order difference, the minimum threshold of first-order 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 R-Waves
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 R-wave, some interference may lead to multiple detection and missed detection of the R-wave. In this paper, the error correction of the R-wave is carried out by the following methods. The index difference between the R-wave position and the previous R-wave position is recorded, and it is compared with the previous index difference .
If , there may be a missed judgment between this R-wave and the previous R-wave. 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 R-wave 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 R-wave in time, it is necessary to judge the amplitude of the current measured R-wave once in the abovementioned formula. If the amplitude of the R-wave 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 R-wave of the ECG waveform of the subject is detected and displayed in real-time, 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 R-waves of a total of 8619 ECG waveforms of 10 subjects. When the maximum heart rate was reached (195-age) , 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 R-wave detection results were accurate. At the same time, the memory utilization is low in the detection process.
3.2. MIT-BIH Public Database
The MIT-BIH arrhythmia database contains 48 1/2 hours of excerpts from two-channel dynamic ECG recordings. The records are digitized with 360 samples per second per channel, with an 11-bit resolution in the 10 mV range .The ANSI/AAMI/ISO EC57 : 1998/(R) 2008 standard states that the QRS detection algorithm must provide statistical reports from the MIT-BIH arrhythmia database .
In order to evaluate the performance of the proposed algorithm, common detector performance measurements are applied and defined as follows .
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) .
As can be seen from Table 2, this algorithm successfully detected 47,398 R-waveforms in 47,498 QRS-waveforms, indicating that this algorithm can correctly detect the vast majority of R-waveforms. 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 R-wave recognition algorithms based on differential thresholds. In the R-wave detection results, the method of this paper has improved by 0.05% and 0.3% on average.
This paper presents a lightweight adaptive MMT ECG signal R-wave detection algorithm. After denoising the ECG signal and correcting the baseline, the algorithm performs first-order difference processing, detects the R-wave through the maximum and minimum difference threshold, and updates the threshold according to the index information of the R-wave. The algorithm of R-wave 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 R-wave 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 anti-interference 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 real-time and durability of ECG monitoring.
It is important to note that the algorithm of R-wave detection is faulty in some occasions, such as MIT-BIH database in 203 and 205 of two groups of ECG data waveform, the waveform memory is intermittent R-wave inversion, the phenomenon of greater influence on the sensitivity of the proposed algorithm, leads to recognition of the R-wave in 203 and 205 groups of data, and the sensitivity of 99.00% and 98.04%, as shown in Figure 5.
In summary, R-wave detection was evaluated on the existing standard MIT-BIH 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 anti-interference 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.
The ECG data used to support the findings of this study have been deposited in the MIT-BIT repository.
Conflicts of Interest
The authors declare that there are no conflicts of interest regarding the publication of this paper.
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).
- S. Gradl, P. Kugler, C. Lohmüller, and B. Eskofier, “Real-time ECG monitoring and arrhythmia detection using android-based 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.
- 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 max-min difference algorithm,” Computer Methods and Programs in Biomedicine, vol. 144, pp. 61–75, 2017.
- 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.
- V. Kalidas and L. Tamil, “Real-time 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.
- 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.
- 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.
- 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.
- Y. Xiang, L. Zhitao, and M. Jianyi, “Automatic QRS complex detection using two-level convolutional neural network,” Biomedical Engineering Online, vol. 17, no. 1, pp. 1–17, 2018.
- M. Saadatmand-Tarzjan, 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.
- X. Tang, Q. Hu, and W. Tang, “A real-time 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.
- M. Kashif, S. Jonas, and T. Deserno, “Deterioration of R-wave 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.
- 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.
- 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.
- 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.
- S. Sahoo, P. Biswal, T. Das, and S. Sabut, “De-noising of ECG signal and QRS detection using hilbert transform and adaptive thresholding,” Procedia Technology, vol. 25, pp. 68–75, 2016.
- 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.
- 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.
- 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.
- T. Pander, “The class of M-filters in the application of ECG signal processing,” Biocybernetics & Biomedical Engineering, vol. 26, no. 4, pp. 3–13, 2006.
- H. Tanaka, K. D. Monahan, and D. R. Seals, “Age-predicted maximal heart rate revisited,” Journal of the American College of Cardiology, vol. 37, no. 1, pp. 153–156, 2001.
- G. B. Moody and R. G. Mark, “The impact of the MIT-BIH arrhythmia database,” IEEE Engineering in Medicine and Biology Magazine, vol. 20, no. 3, pp. 45–50, 2001.
- “American national standard ANSI/AAMI EC 57:2012, testing and reporting performance results of cardiac rhythm and ST-segment measurement algorithms,” 2017, https://webstore.ansi.org/RecordDetail.aspx?sku=CARDIO+MEDICAL+DEVICE+PACKAGE.
- C. Chieh-Li and C. Chun-Te, “A QRS detection and R point recognition method for wearable single-lead ECG devices,” Sensors, vol. 17, no. 9, p. 1969, 2017.
- D. Lai, F. Zhang, and C. Wang, “A real-time 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.
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.