Dipjyoti Bisharad1, Debakshi Dey1, Brinda Bhowmick1 1 National Institute of Technology Silchar,Silchar – 788010, Assam, India{dipjyotibisharad.nit, deydebakshi16,brindabhowmick}@gmail.comAbstract. Electrocardiography (ECG orEKG) is a widely employed non invasive technique to determine the condition ofhuman heart and detect any abnormal cardiac behavior. Computer systems for ECGanalysis can aid physicians in prompt detection of dangerous events such asventricular fibrillation in patients with high cardiac risks. The first andcrucial part of automatic analysis of ECG signals is to accurately identify andmeasure characteristic features of ECG signal, which is to locate exactposition of the onset and offset points of P, QRS and T-waves.
In this paper,we propose a fast technique that can accurately identify these key referencepoints using local windows around R peaks. The proposed method has been testedon standard QT database and a very high accuracy of above 99% is achieved onidentifying different segments in ECG signal.Keywords: electrocardiogram, patternrecognition, ECG features, ECG segmentation.1 IntroductionAn ECG signal originates from the electricalactivity of the heart that coordinates the contraction and relaxation of thedifferent chambers of the heart. The analysis of ECG signal and detection ofits characteristic points can be used to identify various heart rhythmabnormalities, chest pains and other diseases.
One cardiac cycle in a ECGsignal comprises P, QRS and T wave complexes. The field ofautomatic ECG analysis has become quite mature. There has been a lot of priorwork done in identifying characteristic points in ECG signals. However most ofthese use sophisticated and complex signal processing techniques which makethem computationally expensive. In 11, the Pan Tompkins proposed a methodwhich recognizes the QRS complexes using the information on the signal’s slope,amplitude and width. But the dual-threshold technique used in this method forsearching back the missed out complexes is only useful if the heart rate isregular and unable to find out the missed beats in case of abnormalities.
In 12, all the P, QRS and T complexes aredetected using wavelet transform method but the P and T onsets and offsets arenot detected with much accuracy under serious noise influence. 13 showsdetection of the P wave in addition to the QRS complex using Hidden MarkovModel. In 14, QRS complexes are detected using moving-average filters butthis methodology is not robust to false positives or false negatives.
The QRScomplex detection technique proposed in 15 applied first-order derivative andadaptive threshold adjustment to detect the complexes and filtered thehigh-frequency noise by employing discrete wavelet transform. 16 introduces anew and fast version of ECG delineation algorithm using line fitting but is notrobust against certain arrhythmias where no wave is detected. Support vectormachine has been used for detection of P and T waves in 17. In 18 the QRScomplexes have been clustered into different groups using self-organizingneural networks for detection. The algorithm proposed in 19 can be evaluatedfor both clinical and telehealth ECG data. The work in 20 describes a complexQRS detector which is based on dyadic wavelet transform.
It gave goodperformance for multiform premature ventricular contractions, bigeminy, andcouplets tapes. 21 employs S-transform to isolate QRS complexes and Shannonenergy for localizing R waves. Detection of QRS complexes is also found in 22that has been performed using difference equation operation. In 23 a QRScomplex detector with limited hardware resources has been proposed.In our paper,we aim towards detecting the P, QRS and T complexes in a reliable and robustway using local windowing which gives a very high detection accuracy and hasO(N) computational complexity in detecting P, Q, S and T waves.
This paper is organized as follows. In section 2, we present a briefdiscussion on the anatomy of ECG signal and its characteristic waveforms,Section 3 provides a description of the dataset that has been used to evaluatethe proposed method. In section 4, we discuss the methodologies and algorithmsimplemented in this work. The results that the evaluation has yielded are shownin section 5 and 6 with quantitative as well as qualitative interpretations.Finally, Section 7 concludes the paper.
2 Review of the Morphology ofECG SignalThe ECG captures the direction and magnitude of electricaldepolarization and repolarization generated by a person during his one cycle ofheartbeat. The components of a normal ECG tracings consists of multiplewaveforms each indicating an electrical event during one heart beat. Thesewaveforms are labeled as P wave, QRS complex and T wave as shown in Fig. 1 .
There is another small wave called U wave which is the successor of the T waveand may not always be observed as a result of its small size 2. We ignore Uwave in this work.P wave marks the beginning of the ECG cycleand is the first short upward movement of the ECG tracing.
It indicates thatthe atria are contracting, pumping blood into the ventricles. It is followed bythe QRS complex, normally beginning with a downward deflection, denoted as Q; alarger upward deflection, a peak denoted as R; and then a downward S wave. Fig.1. Schematic diagram of single ECG wave. {src:http://www.rn.
org/courses/} The QRS complex represents ventriculardepolarization and contraction. The PR interval indicates the transit time forthe electrical signal to travel from the sinus node to the ventricles. T waveis normally a modest upwards waveform representing ventricular repolarization.However in certain cases, T wave can be inverted 3.Each of these wave has a characteristic duration. The P-Wave lasts forabout 80 ms. The normal PR interval inan ECG wave ranges from 120 ms to 200 ms. Duration of PR-Segment is 50 ms to120 ms.
The QRS complex duration is about 80 ms to 120 ms. Duration ofST-Segment is 80 ms to 120 ms. Duration of ST-Interval is 320 ms. The QTinterval is heart rate dependent. The normal QT intervals are less than 450 msfor men and less than 460 ms for womenbut may vary from 270 ms at a heart rateof 150 beats per min to 500 ms at a heart rate of 40 beats per min 4.3 Dataset DescriptionSeveral databases are available for studyingand analyzing ECG data.
The dataset usedin this paper is the QT database which contains 105 records, each being 15minutes in duration 5. It has been created by incorporating new data fromHolter recordings of patients into the MIT-BIH Arrhythmia Database, the European Society of Cardiology ST-T Database and severalother databases 6-7.The sampling frequency of all the records in thisdatabase is 250 Hz. The reason behind choosing this database for the evaluationof our algorithm is that reference annotations have been given to mark thewaveform boundaries in addition to those already marked in the other databases.
More specifically, this database includes annotation for P and T complexes inaddition to annotations for Q, R and S complexes thus helping us to compare ourobtained results.4 MethodologyFrom the discussion on the morphology of ECGsignal in section 2, it can be observed that the points of interest viz. P, Q,R, S and T have a distinct and characteristic physical appearance.
Also if anyone of these points is known, then rest of the points can be identified fromits neighborhood with fair accuracy. For instance, P peak is the local maximabetween the R peak of the corresponding wave and T peak of the previous wave; Qtrough is the local minima between P peak and R peak. Similar neighborhoodcharacteristics exist for S and T wave. Hence by only knowing the position of Rpeak, all the other waves can be identified from the signal. In this work, weexploit these local features of P, Q, R, S and T waves to locate them.
The steps followed in this work can besummarized as follows: Step 1: The digitized ECG data from the database isfiltered with a bandpass FIR filter with lower and upper cutoff frequency of 3Hz and 45 Hz respectively to remove noises originating due to electromyogram(EMG) signals, high frequency interferences, DC offset and baseline wandering8.Step 2: From the filtered signal, the R peak isextracted using the R segmentation algorithm proposed by Hamilton in 9.Step 3: After extracting the location of R peaks, thelocation of remaining four peaks is computed using local context window in theneighborhood of corresponding R peak.The primary contribution of this work is instep 3 and is discussed in detail in following sub-sections.
4.1 Detection of P peaks Fig. 2. The points A and B denote the beginning and end of the context window respectively for the detection of P peak; A and B are 100 ms apart; Point B is 100 ms offset from R. After filtering the signal and locating Rpeaks, we proceed towards locating P peaks.
As stated earlier, P peak isapproximated as the local maxima between R peak and T peak of previous wave.However, considering the entire region between T peak and R peak can lead toincreased false positives since this region is quite extended, can be noisy andhave multiple peaks and troughs. Hence, a reduced context window of 100 msduration is chosen which is offset from R peak by 100 ms on the left. A typical boundary of the context window for detectingP waveare marked A and B as shown in Fig 2. The peak of P wave is taken asmaximum of the values in the context window. 4.
2 Detection of Q – trough Q trough is the point of inflexion between PRsegment and QRS complex. To determine its position, a context window of 100 msis taken. The window terminates at the position of R peak. The Q peak is takenat point of minimum value within the window as shown in Fig. 3.
Fig. 3.The points A and B denote the beginning and end of the context window respectively for the detection of Q trough; A and B are 100 ms apart; Point B coincides with the location of R. 4.
3 Detection of S – troughThe S trough is the point of inflexion between QRS complex and STsegment. To determine its position, a context window of 100 ms is taken. Thewindow originates at the position of R peak as shown in Fig. 4. The S peak istaken at point of minimum value within the window. Fig. 4.The points A and B denote the beginning and end of the context window respectively for the detection of S trough; A and B are 100 ms apart; Point A coincides with the location of R.
4.4 Detection of T – peakAs stated in section 2, T peak possess a unique property of beinginverted in some cases. Thus, within the context window, the T peak will beeither the minima or maxima, whichever has the maximum magnitude. To removethis ambiguity, all the values within the window are squared.
Thus T peak willnecessarily be at the location of the value having maximum squared magnitude.However, there is a glitch. In case there is an inverted T peak, the voltagelevel at the peak might lie below 0 V, and possibly in between 0 mV and -1 mV.In that case, squaring a value between 0 and 1 will, in turn, reduce its magnitude.Thus a threshold of 1mV is added to all the values before squaring them.T peaks occur fairly long after QRS wave and may be present in anextended region. Thus the size of context window is increased to 200ms durationand is offset to the right by 200 ms from the position of R peak.Fig.
5 showsthe window boundaries A and B for locating T peak. Fig. 5. The points A and B denote the beginning and end of the context window respectively for the detection of T peak; A and B are 200 ms apart; Point A is 200 ms offset from R. 5 Comparing the AnnotationPerformanceInthis section we present a qualitative visual evaluation of our proposed method.The record sel17453 from the QT databaseis annotated with the annotations given in the dataset itself and with theannotations generated from our model as shown in Fig. 6. We observe that theannotations closely match with each other.
This indicates that our model isworking as expected on this benchmark dataset. (a) Raw unannotated ECG data extract (b) Extract annotated with .q1c Fig. 6.Original signal and annotation from .q1c on the waveform of the signal from record sel17453 in the interval 612 to 614.5 sec (c) Extract annotated with .
pu0 (d) Extract annotated with our proposed method Fig. 7.Annotations from .
pu0 and from our proposed method on the waveform of the signal from record sel17453 in the interval 612 to 614.5 sec 6 Results and DiscussionsIn this section we present a quantitative evaluation of our model. Byapplying the methods described in section 4, we annotate all the 105 records inQT database and compare our annotations with the annotations given in thedataset. The dataset has 9 annotation files in total. To evaluate our proposedmethod, we chose two of the annotation files from the dataset. The first one is.pu0 annotation which contains automatically determined waveformboundary measurements for all beats.
The second set of annotation filesconsidered is .q1c annotation which contains manually determinedwaveform boundary measurements for a small fraction of beats. We compared ourresults against reference annotations allowing for a 5% tolerance level; thatis, a prediction is deemed correct if its value falls within a range of ±5% ofthe reference value. Table 1. Evaluation results.
Wave Annotation Total number of correct predictions Total number of incorrect predictions Overall Accuracy Median Accuracy P .pu0 88652 88 0.9990 1.0 .q1c 2724 189 0.935 1.
0 Q .pu0 100741 69 0.9993 1.
0 .q1c 3111 174 0.9470 1.0 R .pu0 107624 4 0.9999 1.0 .q1c 3266 20 0.
9939 1.0 S .pu0 102470 269 0.9974 1.0 .q1c 3154 226 0.9331 1.
0 T .pu0 78675 2876 0.9647 1.0 .
q1c 2481 1267 0.6620 1.0 As an evaluation metric, for each P, Q, R, S and T, we list the totalnumber of correct predictions, total number of incorrect predictions, overallaccuracy and median accuracy across 105 records achieved by our proposed methodfor respective peaks and troughs.The results are extremely impressive. Weobtain 100% median accuracy on 105 records for all the waves across both thereference annotations. We also obtain very staggering overall accuracy on .pu0annotations.
However the accuracy for .q1c is not as good as that for .pu0.
However manual inspection of .q1c annotations showed that some annotations werefairly deviated from where they ought to be. Fig 8 shows an extract of the dataof ECG record sel17453 from the dataset and it is annotated from its.q1c file. It can be observed that R and S are not correctly labeled; also T isslightly offset from its appropriate location. We think that small sample sizeof .
q1c annotations accompanied with inaccurate annotations might have affectedthe statistics that resulted in lower accuracy for P, Q and S. Fig. 8.
.q1c annotations on the waveform of the signal from record sel17453 in the interval 618.5 to 622 sec It is also observed from Table 1. that theoverall accuracy for T peak detection is lower than its counterparts. It is tobe pointed out that detecting T peaks is in fact a non trivial task. DetectingT wave accurately is more challenging than detecting QRS complex due toits lowamplitudes, low signal-to-noise ratio (SNR), amplitude and morphologyvariability, and possible overlapping of the P wave and T wave 10. Theapproximation used to detect boundaries of T wave in this proposed method worksefficiently for normal ECG signal but may give inaccurate results for certainkinds of abnormal ECG signals. We acknowledge this as a limitation of ourproposed method.
7 ConclusionIn this work, we demonstrated a robust and fast method to detect the P,Q, S and T waves. The algorithm runs in linear time with respect to size ofinput data because the algorithm is essentially finding maximum or minimumvalue within an array of numbers. The method is highly accurate, particularlyfor normal ECG signals. The proposed technique can be used to estimate theboundaries of an ECG signal and then the extracted samples can be used forfurther analysis. AcknowledgmentsThe authors would like to thank Innovation & EntrepreneurshipDevelopment Centre, NIT Silchar for funding this project. The authors are alsograteful to Mr. Arkajyoti Saha and Ms. Maitrayee Deb of Silchar Medical Collegeand Hospital for their valuable inputs and suggestions.
References1 Baldonado, M., Chang, C.-C.
K., Gravano, L., Paepcke, A.: TheStanford Digital Library Metadata Architecture.
Int. J. Digit. Libr.
1 (1997)108–1212 di Bernardo, D. and Murray, A., 2002.
Origin on theelectrocardiogram of U-waves and abnormal U-wave inversion. Cardiovascularresearch, 53(1), pp.202-208.
3 Hoffman, B.F. and Cranefield, P.
F., 1960. Electrophysiology ofthe Heart.
McGraw-Hill, Blakiston Division.4 Joshi, Anand Kumar, ArunTomar, and MangeshTomar. “A Review Paperon Analysis of Electrocardiograph (ECG) Signal for the Detection of ArrhythmiaAbnormalities.
” International Journal of Advanced Research inElectrical, Electronics and Instrumentation Engineering 3, no. 10 (2014).5 Laguna P, Mark RG,Goldberger AL, Moody GB. A Database forEvaluation of Algorithms for Measurement of QT and Other Waveform Intervals inthe ECG.
Computersin Cardiology24:673-676(1997)6 Moody GB, Mark RG. The impact of the MIT-BIH Arrhythmia Database. IEEEEng in Med and Biol 20(3):45-50 (May-June 2001). (PMID: 11446209)7 TaddeiA, Distante G, Emdin M, Pisani P, Moody GB, Zeelenberg C, Marchesi C.
TheEuropean ST-T Database: standard for evaluating systems for the analysis ofST-T changes in ambulatory electrocardiography. European Heart Journal13:1164-1172 (1992)8 Thakor, Nitish V., andY-S. Zhu. “Applications of adaptive filtering to ECG analysis: noisecancellation and arrhythmia detection.” IEEE transactions onbiomedical engineering 38.
8 (1991): 785-794.9 Hamilton, P. “Opensource ECG analysis.” In Computers in Cardiology, IEEE (2002): 101-104.10 Elgendi, Mohamed,Bjoern Eskofier, and Derek Abbott. “Fast T wave detection calibrated byclinical knowledge with annotation of P and T waves.” Sensors 15,no.
7 (2015): 17693-17714.11 Pan, Jiapu, and Willis J. Tompkins. “A real-time QRS detectionalgorithm.”IEEE transactions on biomedical engineering 3 (1985):230-236.12 Li, Cuiwei, Chongxun Zheng, and ChangfengTai.
“Detection of ECG characteristic points using wavelettransforms.”IEEE Transactions on biomedical Engineering 42, no. 1(1995): 21-28.13 Coast, Douglas A., Richard M. Stern, Gerald G.
Cano, and Stanley A.Briller. “An approach to cardiac arrhythmia analysis using hidden Markovmodels.”IEEE Transactions on biomedical Engineering 37, no. 9(1990): 826-836.
14Elgendi, Mohamed. “Fast QRS detection with anoptimized knowledge-based method: Evaluation on 11 standard ECGdatabases.”PloS one 8, no. 9 (2013): e73557.15 Karimipour, Atiyeh, and Mohammad Reza Homaeinezhad.
“Real-time electrocardiogram P-QRS-T detection–delineation algorithm basedon quality-supported analysis of characteristic templates.”Computers inbiology and medicine 52 (2014): 153-16516 Leutheuser, Heike, Stefan Gradl, Lars Anneken, MartinArnold, Nadine Lang, Stephan Achenbach, and Bjoern M. Eskofier.”Instantaneous P-and T-wave detection: Assessment of three ECG fiducialpoints detection algorithms.” In Wearable and Implantable Body SensorNetworks (BSN), 2016 IEEE 13th International Conference on, pp.
329-334.IEEE, 2016.17 Mehta, S. S., and N. S.
Lingayat. “Detection ofP and T-waves in Electrocardiogram.” In Proceedings of the worldcongress on Engineering and computer science, pp. 22-24. 2008.18 Lagerholm, Martin, Carsten Peterson, Guido Braccini,Lars Edenbrandt, and Leif Sornmo. “Clustering ECG complexes using Hermitefunctions and self-organizing maps.”IEEE Transactions on BiomedicalEngineering 47, no.
7 (2000): 838-848.16 Khamis, Heba, Robert Weiss, Yang Xie, Chan-Wei Chang,Nigel H. Lovell, and Steph9n J. Redmond.
“QRS Detection Algorithm forTelehealth Electrocardiogram Recordings.”IEEE Transactions onBiomedical Engineering 63, no. 7 (2016): 1377-1388.20 Kadambe, Shubha, Robin Murray, and G. FayeBoudreaux-Bartels. “Wavelet transform-based QRS complex detector.”IEEETransactions on biomedical Engineering 46, no. 7 (1999): 838-848.
21 Zidelmal, Zahia, Ahmed Amirou, D. Ould-Abdeslam, AliMoukadem, and Alain Dieterlen. “QRS detection using S-Transform andShannon energy.
“Computer methods and programs in biomedicine 116,no. 1 (2014): 1-9.22 Yeh, Yun-Chi, and Wen-June Wang. “QRS complexesdetection for ECG signal: The Difference Operation Method.”Computermethods and programs in biomedicine 91, no.
3 (2008): 245-254.23 Gutiérrez-Rivas, Raquel, Juan Jesús García, WilliamP. Marnane, and Álvaro Hernández. “Novel real-time low-complexity QRScomplex detector based on adaptive thresholding.
“IEEE Sensors Journal15, no. 10 (2015): 6036-6043.