underwent DC cardioversion at Royal Victoria Hospital,. Belfast. The efficacy of the R-peak detection algorithm for both normal sinus rhythm and atrial fibrillation ...
Denoising and Automated R-peak Detection in the ECG using Discrete Wavelet Transform Jonathan Goodfellow1, Omar J Escalona1, Vivek Kodoth2, Ganesh Manoharan2, Antonio Bosnjak3 1
University of Ulster, Newtownabbey, Northern Ireland 2 Royal Victoria Hospital, Belfast, Northern Ireland 3
Universidad de Carabobo, Valencia, Venezuela
Abstract This work presents a novel approach to ECG R-peak detection based on the Discrete Wavelet Transform. 18,647 beats were analysed from thirty AF patients who underwent DC cardioversion at Royal Victoria Hospital, Belfast. The efficacy of the R-peak detection algorithm for both normal sinus rhythm and atrial fibrillation beats was assessed using three performance parameters: Sensitivity, Positive Predictivity and Accuracy. The preliminary results acquired using the proposed Rpeak detection approach provided results of 99.61%, 99.88% and 99.50% respectively, indicating that the utilization of DWT to assist peak detection is a viable method. The second phase of the study assessed how effectively the algorithm could discriminate between segments presenting normal sinus rhythm and those presenting atrial fibrillation based on RR interval data derived from the R-peak detection method. Fifty segments of normal sinus rhythm and AF-ECG were tested, and 100% successful classification was achieved. This highlights that the DWT R-peak detection method can be utilized in a practical application to differentiate between patients in normal sinus rhythm and those in AF.
1.
Introduction
Automated detection of ECG features is very useful in ECG analysis and has been shown to be important for heart rate variability analysis and arrhythmia detection [1, 2]. Accurate determination of ECG features, such as R-peak points is also significant in the treatment of arrhythmias, such as DC cardioversion where shocks to patients must be administered at precise points in time with respect to the ECG [4]. Feature detection algorithms also play an important role in implantable devices such as pacemakers and implantable defibrillators by monitoring the rhythm of the patient and providing an intervention when required
Computing in Cardiology 2016; VOL 43
[5]. The purpose of this study is to outline a novel approach for R-peak detection in ECG, focussing on both samples that present normal sinus rhythm (NSR) and those presenting atrial fibrillation (AF). Atrial fibrillation (AF) is the most common cardiac arrhythmia, affecting approximately 2% of the population [6]. AF can be characterized by predominantly uncoordinated atrial activation, driven by disruptive vortex-like, rotating waves of electrical activity which consequently lead to atrial mechanical dysfunction [7]. The presence of AF is indicated on the electrocardiogram (ECG) as irregular fibrillatory waves, giving rise to a loss of normal P-wave, and also the presence of a very erratic ventricular rate. The second phase of this work will focus on using the presented R-peak detection algorithm on real ECG signals, in order to determine the efficacy of the algorithm in differentiating between segments of NSR and AF-ECG
2.
Methods
2.1.
Study population
18,647 beats in total are analysed for automated R-peak detection using the novel wavelet based detection approach outlined in this work. The real ECG data was recorded from thirty fully anti-coagulated patients with persistent AF, who would clinically benefit from external DC cardioversion. Exclusion criteria and complete medical procedure were as previously described by Kodoth et al. [8]. The data was split into two subsections; AF beats which are those prior to successful cardioversion and NSR beats which are those from patients after they have been successfully cardioverted.
2.2.
Data acquisition
A standard ECG lead II was acquired during the entire cardioversion procedure. The signals were digitized at a sampling rate of 1000Hz with 16-bit resolution. ECG processing was performed using Matlab® version 2015a
ISSN: 2325-887X
DOI:10.22489/CinC.2016.301-506
(The Mathworks Ins., Natick, MA, USA). Thirty ECG recordings were analysed, with the sections of data containing DC shocks being excluded from the study. For the second phase of the study, fifty AF-ECG segments and fifty NSR segments, all twenty seconds long, were isolated and used to determine the effectiveness of the wavelet based R-peak detection algorithm in differentiating between AF and NSR episodes in ECG analysis.
2.3.
Twindow =
𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚(𝑅𝑅𝑟𝑟𝑟𝑟𝑟𝑟 )
(2)
4
Figure 2.0 provides a representation of the signal at each stage of the R-peak detection process.
Input Signal
DWT Denoising
D5 coefficient soft thresholding
Squaring operation and DWT 10-level decomposition
D1-D5 band cancellation to produce reference window
Find peak point inside reference window
Record R-peak points
Performance Evaluation
Automated DWT R-peak detection
The first step of the process required the DC component of the ECG signal to be removed by subtracting the mean value of the ECG signal as seen in equation 1. ECGDCR = ECGinput – mean(ECGinput)
(1)
The signals were then denoised using Discrete Wavelet Transform (DWT). This was achieved through 10 level decomposition of the signal using Daubechie’s ‘Db10’ analysing wavelet. This specific wavelet was chosen as it has been shown in previous work to produce optimal denoising performance of ECG [9]. Once decomposed, the signal can be fully represented as a collection of detail coefficients (D1-D10) and one approximation coefficient at the lowest level of decomposition (A10). Full-band cancellation of the D1-D4 coefficients provided satisfactory attenuation of high frequency corruptive noise sources and power line interference. Baseline wander was attenuated through removal of the A10 coefficient, which has been previously shown to be an effective method of baseline correction [10]. In this study however, further baseline wander attenuation was achieved through the removal of the A10 and D10 coefficients as this improved baseline correction without distorting the morphology of key ECG features. For the R-peak detection method, isolation of the D5 coefficient was required, as through the time-frequency representation of the DWT, The QRS regions are amplified whilst features relating to other ECG points are attenuated. To improve the attenuation of nonQRS regions within the D5 coefficient, DWT soft thresholding was utilised, with a fixed threshold value of T = 300 to modify the D5 coefficient, the result of which can be seen in Figure 2 below. The modified D5 coefficient is squared to make all values positive and further amplify the QRS regions within the signal. At this point a 10 level DWT decomposition of the modified D5 coefficient is undertaken and D1-D5 are removed from the signal in order to produce a reference window (Rref) in which the Rpeak points can be found. The algorithm uses these windows as a reference and looks for the peak value inside each window, which relates to the R-peak of each QRS complex, once a predetermined threshold value, Twindow, is exceeded. For this study, a threshold value was calculated using equation 2.
Figure 1.0 Block diagram of proposed R-peak detection algorithm using Discrete Wavelet Transform.
The time-frequency localised R-peak reference window generated through the manipulation of the D5 coefficient provides a region of interest that is localised narrowly around QRS regions of the ECG signal. This is advantageous in R-peak detection as it minimises the possibility for other ECG features, such as high amplitude T-waves from being incorrectly detected. Wavelet Denoised Signal 5000 0 -5000
0
500
1000 1500 2000 2500 3000 3500 4000 D5 Coefficient after Soft Thresholding T=300
4500
5000
0 500 1000 1500 2000 2500 3000 3500 4000 4500 6 x 10 D5 Coefficient after Squaring and D1-D5 Band Cancellation
5000
0
500
1000 1500 2000 2500 3000 3500 4000 ECG Signal after R-peak Point Detection
4500
5000
0
500
1000
4500
5000
2000 0 -2000 1 0 -1 5000 0 -5000
1500
2000
2500
3000
3500
4000
Figure 2.0 Representation of denoised signal (blue), generation of R-peak reference window (red) and detected peaks when algorithm is implemented (green)
2.4.
ECG classification: NSR vs AF
Acc =
After utilizing the proposed R-peak detection algorithm describe in Section 2.4, the practical application of the algorithm was tested by investigating the efficacy of discrimination between NSR and AFECG. For this study, fifty segments of NSR-ECG and fifty segments of AF-ECG, each twenty seconds long, were extracted and analyzed with the R-peak detection algorithm. RR intervals were calculated and subsequently, the mean RR interval (RRmean) and standard deviation of RR interval (RRstd) were calculated for each segment. RRmean and RRstd from fifty of these segments, twenty five NSR-ECG and twenty five AFECG were used as a training set using Weka® 3.6 Machine Learning software. The data was analyzed using the J48 classification algorithm to produce a classification tree based on the two input variables. The classification tree produced indicated that a cutoff value for RRmean = 919.28 milliseconds was an optimal cutoff value based on the training set data analyzed. Based on this information, Matlab® code was created to classify a test set of fifty ECG signals and produce an outcome of ‘NSR’ if RRmean was greater than 919.28 ms or ‘AF’ if RRmean was less than or equal to the same value. The efficacy of the classification of ECG signals based on the RR interval data derived from the proposed R-peak detection algorithm was assessed by comparison with the true signal type, and the accuracy was calculated.
𝑇𝑇𝑇𝑇
(𝑇𝑇𝑇𝑇+𝐹𝐹𝐹𝐹+𝐹𝐹𝐹𝐹)
x 100
(5)
Where TP = True positive beats, R-peaks that have been correctly identified. FP = False positive beats, any point that has been incorrectly detected as an R-peak, and FN = False Negative; any R-peak point which has not been detected. The three performance parameters were calculated for AF beats, NSR beats and also for the total number of beats tested in the study. The second phase of this study was the classification of fifty, twenty seconds long recordings of either NSR-ECG or AF-ECG based on RR interval data derived from the novel R-peak detection algorithm described above. The performance of the classification was based on how effectively the algorithm could differentiate between AF and NSR, by comparing the outcome of the decision tree with the true signal classification.
3.
Results
Table 1 presents the results and shows the performance of the DWT R-peak detection method, in terms of Sensitivity, Positive Predictivity and Accuracy was 99.61%, 99.88% and 99.50% respectively. It is evident that the algorithm performed well on both NSR-ECG beats and AF beats also, with sensitivity and accuracy being higher for NSR beats, whereas the Positive Predictivity for AF beats showed better performance at 99.90%. Table 1. Table of results showing Se, Sp and Acc of proposed R-peak detection algorithm.
Figure 3.0 Classification decision tree produced by Weka® for detecting AF and NSR-ECG segments.
2.5.
Performance parameters
In order to assess the efficacy of the proposed R-peak detection method, a number of performance measures were implemented, namely the calculation of Sensitivity (Se), Positive Predictivity (Pp) and Accuracy (Acc). Se = Pp =
𝑇𝑇𝑇𝑇
x 100
(3)
𝑇𝑇𝑇𝑇
x 100
(4)
(𝑇𝑇𝑇𝑇+𝐹𝐹𝐹𝐹) (𝑇𝑇𝑇𝑇+𝐹𝐹𝐹𝐹)
The results of the second phase of this study investigate how effectively RR interval data, derived from the DWT R-peak algorithm, can differentiate between NSR and AF-ECG segments. Using the RRmean cutoff value calculated in section 2.4, fifty unknown ECG segments were analysed, and classified as ‘AF’ or ‘NSR’. The algorithm was able to correctly classify 100% of the unknown ECG segments, suggesting that the DWT Rpeak detection algorithm could be effectively implemented for practical arrhythmia detection.
4.
Discussion and conclusion References
The results presented above show that the proposed DWT R-peak detection method can accurately predict the location of R-peaks in ECG data for both patients in normal sinus rhythm and those in AF also. The overall Se, Pp and Acc of the algorithm across all 18,647 analysed beats were 99.61%, 99.88% and 99.50% respectively. The utilization of the time-frequency characteristics of the DWT and particularly the D5 coefficient allow for the generation of a reference window around QRS regions, it could be said that this method helps to minimize false positives such as high amplitude T-waves due to the localization of the reference window. A fixed threshold value was used for the soft thresholding of the D5 coefficient, it could be said that further performance improvements could be achieved using this method with a more robust selection of threshold value. Additionally, further considering of the optimal threshold value for, Twindow, could enhance the performance of the proposed algorithm, as it was observed that a lower value of Twindow produces less false negatives, however the incidence of false positives may increase as a result in certain cases. The RR-interval data derived from using the DWT Rpeak detection algorithm was highly effective at discriminating between NSR and AF-ECG segments, where the algorithm correctly classified 100% of the test ECG signals. This indicates that the proposed method for R-peak detection can be used effectively in a practical application in order to differentiate between atrial fibrillation and normal sinus rhythm in ECG.
5.
Limitations and future work
The proposed method for R-peak detection is effective based on ECG signals sampled at 1000Hz, therefore the efficacy of this method at a range of sampling frequency is unknown. Further work would include developing the algorithm to be effective at R-peak detection for a range of sampling frequencies and validate the method further using ECG signals from sources such as the MIT-BIH arrhythmia database [11, 12].
Acknowledgement During the original clinical data gathering work, Dr Vivek Kodoth was the recipient of a Research and Development Fellowship from the Northern Ireland Health and Personal Social Services Office. This research is supported by funding from the European Union (EU): H2020-MSCA-RISE Programme (WASTCArD Project, Grant #645759).
[1] Wilke T, Groth A, Mueller S, Pfannkuche M, Verheyen F, Linder R, et al. A Novel Algorithm for the Automatic Detection of Sleep Apnea from Single-Lead ECG. IEEE Transaction on Biomedical Engineering, 2015;62(9):22692278 [2] Oster J, Clifford GD. Impact of the presence of noise on RR interval-based atrial fibrillation detection. J Electrocardiol 2015;48(6):947-951. [3] Walsh P, Kodoth V, McEneaney D, Rodrigues P, Velasquez J, Waterman N, et al. Towards low energy atrial defibrillation. Sensors 2015;15(9):22378-22400. [4] Walters TE, Teh AW, Spence S, Kistler PM, Morton JB, Kalman JM. Relationship between the electrocardiographic atrial fibrillation cycle length and left atrial remodeling: A detailed electroanatomic mapping study. Heart Rhythm, 2014;11(4):670-676. [5] Tripathy RK, Sharma LN, Dandapat S. Detection of Shockable Ventricular Arrhythmia using Variational Mode Decomposition. J Med Syst 2016;40(4):1-13. [6] Wilke T, Groth A, Mueller S, Pfannkuche M, Verheyen F, Linder R, et al. Incidence and prevalence of atrial fibrillation: An analysis based on 8.3 million patients. Europace, 2013;15(4):486-493. [7] Luther S, Fenton FH, Kornreich BG, Squires A, Bittihn P, Hornung D, et al. Low-energy control of electrical turbulence in the heart. Nature, 2011;475(7355):235-239. [8] Kodoth V, Castro NC, Glover BM, Anderson JM, Escalona OJ, Lau E, et al. Waveform optimization for internal cardioversion of atrial fibrillation. J Electrocardiol, 2011;44(6):689-693. [9] Goodfellow J, Escalona OE,et al. Efficacy of dwt denoising in the removal of power line interference and the effect on morphological distortion of underlying atrial fibrillatory waves in AF-ECG. IFMBE Proceedings; 2015. [10] Banerjee S, Gupta R, Mitra M. Delineation of ECG characteristic features using multiresolution wavelet analysis method. Meas J Int Meas Confed, 2012;45(3):474-487. [11] Moody GB, Mark RG. The impact of the MIT-BIH Arrhythmia Database. IEEE Eng in Med and Biol, 2001:20(3):45-50. [12] Goldberger AL, Amaral LAN, Glass L, Hausdorff JM, Ivanov PCh, Mark RG, Mietus JE, Moody GB, Peng C-K, Stanley HE. PhysioBank, PhysioToolkit and Physionet: Components of a New Research Resource for Complex Physiologic Signals. Circulation, 2000;101(23);e215e220.