Full text
Robust QRS Detection Using Combination of Three Independent Methods Lukas Smital1, Lucie Marsanova1, Radovan Smisek1,2, Andrea Nemcova1, Martin Vitek1 1Brno University of Technology, Brno, Czech Republic 2Institute of Scientific Instruments of the Czech Academy of Sciences, Brno, Czech Republic Abstract QRS detection is a fundamental step in ECG analysis. Although there are many algorithms reporting results close to 100%, this problem is still not resolved. The reported numbers are influenced by the quality of the detector, the quality of annotations and also by the chosen method of testing. In this study, we proposed and properly tested robust QRS detection algorithm based on a combination of three independent principles. For enhancement of QRS complexes there were developed three independent approaches based on continuous wavelet transform, Stockwell transform and phasor transform which are followed by individual adaptive thresholding. Each method produces candidates for QRS complexes which are further processed by cluster analysis resulting in final QRS positions. The proposed detection algorithm was tested on three complete standard ECG databases: MIT-BIH Arrhythmia Database, European ST- T Database and QT Database without any change in algorithm setting. We utilized complete data from mentioned databases including all provided leads and used original (not adjusted) reference positions of QRS complexes. Summarized detection accuracy for all three databases was expressed by sensitivity 99.16% and positive predictive value 98.99%. 1. Introduction One of the first step towards the fully automated computer-based ECG analysis is detecting QRS complexes which are the most visible and also the most informative part of ECG record. Positions of subsequent QRS complexes bring valuable information about heart rate and its variability and serve as an important feature for revealing heart diseases. Even though the scientific community has been focusing on this issue for several decades, the issue of QRS detection is still a living and open topic, as evidenced by a number of publications in recent years [1,2]. Detection is often complicated by different morphology of QRS complexes (and thus different frequency content) in different subjects or in other leads of the same subject. Another complication can be additive interference from both internal and external environments. Internal influences include mainly muscle and respiratory activity or also changes in morphology caused by heart abnormalities. External influences include, for example, powerline interference or impulse interference caused by surrounding electrical devices. Many authors, despite these facts, report the accuracy of detectors to be close to 100% limit. The most successful being those based on timefrequency decomposition, e.g. wavelet transform or Stockwell transform. The weak point is the way of testing. Under the ideal conditions, testing of algorithms should be held independently of the development of algorithms and under the same conditions for all authors. This means i) on the same and secret dataset, ii) the data must be precisely annotated, iii) the algorithm for evaluating the accuracy of the detector must have precisely and reasonably selected parameters (e.g., a tolerance window for successful detection or solution of boundary conditions). Unfortunately, unequal conditions in evaluating the accuracy of QRS detectors between different authors cause incomparability of the achieved results. This is especially true when the achieved results differ by only a tenth of a percent. 2. Materials and methods The following chapters describe proposed algorithms for QRS complex detection and used dataset for development and evaluation in this study. 2.1. ECG databases For evaluation of proposed QRS detector, three most frequent standard databases were used in this study: MITBIH Arrhythmia Database (MITDB) [3], European ST-T Database (EDB) [4] and QT Database (QTDB) [5]. All databases are publicly available on PhysioNet [6]. Altogether, these databases involve 440 unique signals with duration of 449 hours and almost 2 million beats. Computing in Cardiology 2020; Vol 47 Page 1 ISSN: 2325-887X DOI: 10.22489/CinC.2020.100
MIT-BIH Arrhythmia Database It contains 48 half-hour excerpts of two-channel ECG recordings obtained from 47 subjects. Many records in the MITDB demonstrate cardiac rhythm disorders, significant noise artefacts, and contain a broad variety of QRS morphologies. Sampling frequency of the database is 360 Hz and 11 bit resolution covers a 10 mV range. It contains 109494 annotated beats in each channel. European ST-T Database Database consists of 90 two hours excerpts of twochannel ECG recordings from 79 subjects. EDB focuses on abnormalities in the ST segment including baseline ST segment displacement. Thanks to QRS complex annotations can be also used for QRS detectors testing. Sampling frequency of the database is 250 Hz and 12 bit resolution covers 20 mV input range. It contains 790565 annotated beats in each channel. QT Database QTDB consists of 105 ECG recordings in two channels with duration of 15 minutes. Database represent a wide variety of QRS and ST-T morphologies. Sampling frequency of the database is 250 Hz. Complete annotations of QRS complexes have only 82 recordings thus it contains 86995 annotated beats in each channel suitable for QRS detectors testing. 2.2. QRS detection algorithms Designed QRS detector is based on three independent methods: continuous wavelet transform, Stockwell transform and phasor transform. These methods produce candidates for QRS complexes which subsequently inputs cluster analysis. The continuous wavelet transform based method uses wavelet “bior1.5” and scale 15 to highlight QRS complexes [7]. The thresholding is done in sliding window with duration of 2 seconds. The threshold is derived from standard deviation within the window by multiplying it by constant 1.73. The second approach of QRS complex enhancement is based on the time-frequency analysis using Stockwell transform and calculation of Shannon energy envelope within the range from 5 to 20 Hz as in [8]. The subsequent thresholding is adaptive. Initially set as 0.375 times median of the last three QRS complexes amplitudes within the envelope signal. Later, the threshold is adapted by exponential decreasing driven by the distance from last detected position. The third approach is based on enhancement of ECG waves by phasor transform [9]. Subsequently, a sliding window with 300 milliseconds duration is applied for the phasor signal and the maxima is searched for. As a next step it is checked, whether the maxima are higher than the adaptive threshold, which is set as 2 times of standard deviation of phasor signal calculated in a sliding window of 2 seconds duration. 2.3. Cluster analysis Cluster analysis is applied on candidates for QRS complexes provided by all three described methods. Cluster is defined as the group of candidates which are not distanced more than 100 milliseconds. In ideal situation there are three values (candidates) in one cluster. In this case, the final QRS position is calculated as median within the cluster and considered as true positive (TP) QRS detection. If there are only two candidates, the final QRS position is calculated as the mean of both values. This case indicates possible missing candidate of one of the detectors. This procedure prevent false negative (FN) QRS detections. The clusters with only one value are considered as a false positive (FP) QRS detection and excluded to be QRS complex. The advantage is that all methods have a different principle and therefore tend to make mistakes in different part of signal. This gives a chance to cluster analysis to eliminate some FN or FP types of errors. 3. Results Proposed QRS detector was evaluated by reached sensitivity (Se) and positive predictivity (PP) according to ,, FPTP TP PP FNTP TP Se + = + = (1) which is standard evaluation metric for QRS detectors in many articles. Detected location is identified as TP when there is a reference position within the 100 milliseconds tolerance window. We consider such a tolerance window to be the longest possible and still physiologically justifiable because the average width of a normal QRS complex is around 100 milliseconds. Prior to testing, all three sub-algorithms were optimized on the first lead of the MITDB. For subsequent testing on other data, parameters remained unchanged. Results can be seen in Table 1. Table 1. Detection accuracy. DBs Lead TP FN FP Se [%] PP [%] MITDB 1 109274 220 84 99.80 99.92 2 106471 3023 3048 97.24 97.22 EDB 1 785269 5296 5406 99.33 99.32 2 783146 7419 10501 99.06 98.68 QTDB 1 86745 250 260 99.71 99.70 2 86638 357 749 99.59 99.14 Total 1957543 16565 20048 99.16 98.99 Page 2
As expected, the best results are achieved at the MITDB first lead. However, on other databases, the results are comparable, which proves that the sub-algorithms have not been overtrained. On the contrary, the worst results were achieved at the second lead of MITDB, which is more influences by interference. 4. Discussion The proposed detector failed in about 40 thousand cases out of the total number of almost 2 million beats. This give an error rate about 2%. By careful searching were identified three main types of errors: Detector failure Of course, no detector can work without failure. The most detector failures are caused by unexpected sudden changes in the signal. In our case are the most frequent failures caused by noise (see Figure 1, upper part) and changes in heart beats, where the QRS complex have a different morphology and frequency content (see Figure 1, bottom part). Figure 1. Detector failure. Top: 2nd lead of record 104, MITDB. Bottom: 1st lead of record 203, MITDB. Incorrect references There were discovered many cases where the reference position is placed outside of QRS complex as we can see in the Figure 2. If we want to be successful (as many others are) in detection of QRS complexes in these particular signals, we have two possibilities: a) we can extend the tolerance window; b) we can manipulate with reference positions. The first possibility is inappropriate because, as explained above, the tolerance window we use is already long enough and further expansion would not be physiologically justifiable. The second option is even less suitable. Only the author of the database can afford to manipulate the data. If everyone adjusts the data according to their judgment, the results will no longer be comparable between the authors. This issue is not marginal. One bad reference position actually causes pair of mistakes (one FP and one FN) as evident in Figure 2. As an example, if we move the references to their correct positions at EDB and retest the proposed detector on the first channel, the total number of errors (FP + FN) will be more than half lower (decreases from 10702 to 4374) and Se together with PP will increase by 0.4 %. Figure 2. Incorrect references. Top: 1st lead of record e0129, EDB. Bottom: 1st lead of record e0614, EDB. Boundary conditions For some signals that started or ended at the moment of occurrence of the QRS complex, we found missing or remaining references. Figure 3. Boundary conditions. Top: 2nd lead of record sele0203, QTDB. Bottom: 1st lead of record sele0122, QTDB. At the top of the Figure 3 can be seen ECG record starting in the middle of QRS complex. Proposed detector found this position but was penalized because there was Page 3
not reference position. The opposite situation can be seen at the bottom of Figure 3. Just before the end of the signal, the reference position of the QRS complex occurs. The record is truncated closely before QRS complex. The proposed detector logically could not find this QRS complex and was penalized for it. In our opinion, the protection zone should be determined at the beginning and at the end of each signal, where the tested detector would not be penalized. 5. Conclusion QRS detection algorithm based on three independent principles is proposed and tested in this study. The efficiency of the detector is verified on three complete databases with almost 2 million beats. Sufficient robustness of the proposed solution was demonstrated. The achieved results depend not only on the quality of the proposed algorithm but also on the selected test data, the quality of references and testing parameters. Until the method of testing is unified on one standard, it will not be possible to sufficiently compare the quality of the algorithms among different studies. Acknowledgments This work has been funded by the United States Office of Naval Research (ONR) Global, award number N62909- 19-1-2006. The authors wish to thank LCDR Joshua Swift from ONR Code 342 and Dr. Stephen O’Regan from ONR Global Central and Eastern European Office for their support. References [1] C. Nayak et al., “An efficient and robust digital fractional order differentiator based ECG Pre-processor design for QRS detection,” IEEE T BIOMED CIRC S, vol. 13, no. 4, pp. 682– 696, Aug. 2019. [2] M. Jia et al., “Robust QRS detection using high-resolution wavelet packet decomposition and time-attention convolutional neural network,” IEEE ACCESS, vol. 8, pp. 16979–16988, Jan. 2020. [3] G.B. Moody, and R.G. Mark, “The impact of the MIT-BIH Arrhythmia Database,” IEEE ENG MED BIOL, vol. 20, no. 3, pp. 45–50, May 2001. [4] A. Taddei et al., “The European ST-T Database: standard for evaluating systems for the analysis of ST-T changes in ambulatory electrocardiography,” EUR HEART J, vol. 13, no. 9, pp. 1164–1172, Sep. 1992. [5] P. Laguna et al., “A database for evaluation of algorithms for measurement of QT and other waveform intervals in the ECG,” Computers in Cardiology, Lund, Sweden, pp. 673– 676, Sep. 1997. [6] A.L. Goldberger et al., “PhysioBank, PhysioToolkit, and PhysioNet: components of a new research resource for complex physiologic signals,” CIRCULATION, vol. 101, no. 23, pp. e215– e220, Jun. 2000. [7] M. Vitek et al., “A wavelet-based ECG delineation with improved P wave offset detection accuracy,” in Proc. 20th Bienn. Int. EURASIP Conf. BIOSIGNAL, Brno, Czech Republic, pp. 160–165, 2010. [8] Z. Zidelmal et al., “QRS detection using S-transform and Shannon energy,” COMPUT METH PROG BIO, vol. 116, no. 1, pp. 1–9, Aug. 2014. [9] A. Martinez et al., “Application of the phasor transform for automatic delineation of single-lead ECG fiducial points,” PHYSIOL MEAS, vol. 31, no. 11, pp. 1467–1485, Sep. 2010. Address for correspondence: Lukas Smital Department of Biomedical Engineering, Technicka 3082/12, 616 00 Brno [email protected] Page 4