Debakshi Dey1, Brinda Bhowmick1
Institute of Technology Silchar, Silchar – 788010, Assam, India
Abstract.Electrocardiography (ECG or EKG) is a medical test that
isheavily used to assess human heart condition and investigatea large set
cardiac diseases. Automated ECG analysis has become a task of increased
clinical importance since it can aid physicians in improved diagnostics. Most
of the automated ECG analysis techniques requires first identifying the onset
and offset locations of its fiducial points and characteristic waves. Two of
the important characteristic waves are P and T waves. They mark the beginning and
end of aECG cycle respectively. In this paper, a fast technique is proposed
that can segment ECG signals by accurately identifying the P and T waves. In
this work, we evaluate the performance of our model on standard QT database
4. We achieved high accuracies above 99% and 97% while detecting P waves and
T waves respectively.
Keywords: electrocardiogram, ECG features, ECG delineation, ECG segmentation.
ECG signal originates from the
electrical activity of the heart that is synchronouswith the contraction and
relaxation of the atria and ventricles of the heart. Monitoring electrical
activities of heart can help to identify various types of heart diseases.
Nowadays several methods are existing for ECG analysis and it has become a
quite mature field. Some well annotated datasets have been developed that has
boosted the research in ECG data analysis 4-6. Many works have been done till
date for determining characteristic points in ECG signals. But most of them are
computationally expensive because of implementing complex signal processing
techniques. In 10, the QRS complexes are recognized using the information on
the signal’s slope, amplitude and width. Another proposed method uses the
wavelet transform to detect all the P, QRS and T complexes but when noise is
high, the detection of P and T onsets and offsets is very difficult 11.
Hidden Markov Model is used to detect P wave along with QRS complex in 12. In
13, P and T waves detection is based on length transformation technique. Some
hardware based implementation alsoexists such as the Xilinx fpga based P and T wave detection algorithm in which
authors used slope detection approach 14. ECG delineation algorithm
introduced in 15 uses simple line fitting technique but cannot identify some
kind of arrhythmias. A SVMbased method used to detect P and T waves is proposed
in 16. In 17 the QRS complexes have been clustered into several groups with
the help of self-organizing neural networks for detection. The algorithm
proposed in 18 is based on digital
fractional order differentiation for P and T waves detection and
delineation. Though in this work we focused on single lead ECG system, the
authors in 19 found that the detection of wave boundaries in multi-lead ECG
signals giving better performance for measurements of T waves than the other
In this paper, segmenting an ECG cycle is by detecting the P and T
complexes using local context window around R peaks. The proposed method shows
very high detection accuracy and has linear computational complexity with
respect to length of the ECG signal. All the ECG signals used in this work is
obtained from modified limb lead II (MLII), which is placed on the chest.
of this paper is organized as follows. In section 2, composition of ECG signal
is discussed and its characteristic waveforms. In section 3, the methodologies
and algorithms are discussed. The results of the proposed method are shown in
section 4. Finally, the paper concludes in section 5.
2 Structure of ECG Signal
In this section, we provide a
brief overview of the structure of ECG signal. Electrical signals are generated
during one heartbeat in a human undergo depolarization and repolarization. The
magnitude and direction of these electrical events is what that is captured by
the ECG. An electrical event takes place which is indicated by one of the
multiple waveforms contained in the components of a normal ECG tracing during
one cardiac cycle. A short and upward P wave which indicates atrial
depolarization. Then, the QRS complex follows it which signifies ventricular
repolarization. After this, the T wave is observed which is usually a small
upward waveform but it may be inverted in some cases 2. These waves follow a
characteristic duration. The P wave exists
for about 80 ms and one ST-segment duration varies from 80 ms to 120 ms.
One ST-Interval is achieved as 320 ms in 3.
Fig.1. Waveform of single ECG wave 1
From the review of ECG signal, it
is clear that the P and T waves have distinct physical characteristics.
Further, if R peak is known, then these two waves can be identified from its
zone with fair accuracy. For instance, P peak can be approximated as the local
maxima between the R peak of the corresponding wave and T peak of the previous
wave. After detecting P and T waves, boundary the ECG wave is determined.
3.1 Preprocessing the signals
Electromyogram (EMG) signals that
originate from muscles corrupt the raw ECG signals. High frequency
interferences, DC offset and baseline wandering occurring from electrical
equipmentscan also corrupt it 7. In order to reduce these noises, the signal
is passed through a bandpass filter with cutoff frequency of 3 Hz and 45 Hz. To
detect the R peaks, the Hamilton segmentation algorithm 8 is used on the
filtered ECG signal.
3.2 Detection of the peak
of P wave
After locating R peaks, we
determine the location of P peaks. From the structure of ECG signal we find
that P peak can be approximated as the local maxima between T peak of the
previous waveform and R peak of the present waveform. But the region between T
and R peaks is quite wide, can be noisy and have multiple peaks and troughs. So
it can lead to increased false positives if entire region is considered. Hence,
a smaller context window of 100 ms duration is used which is offset from R peak
by 100 ms on the left as shown in Fig 2.
The maximum of the values in the context window is chosen as the peak of
and N is the onset and offset of P
wave respectively; M and Nare
100 ms apart; Point Nis 100 ms offset from R peak.
3.3 Detection of the peak of T wave
It is more difficult to
accurately detect T wave than detecting QRS complex. This is due to low
signal-to-noise ratio (SNR), low amplitudes, variation in morphology and
amplitude and probable overlapping of P and T waves 10. Thus the initially
filtered signal is again passed through a 2nd order butterworth filter having
lower and upper cutoff frequency of 0.5 Hz and 25 Hz. As already mentioned
before in section 2, T wave may be inverted in certain cases. Hence, within the
context window, the T peak can be either the maxima or minima, depending on
which one has the maximum absolute magnitude. To eliminate this uncertainty,
all the values within the window are squared. This essentially makes the T peak
to be located at the index of the value having maximum squared magnitude. But
if the T peak is inverted, the voltage level at the peak might possibly lie
between 0 mV and -1 mV. Thus squaring a value between 0 and 1 will make the
value even smaller. Thus 1 mV is added to all the values before squaring.
T waves have
longer duration compared to P wave. Also QT interval is longer than PR
interval. Thus the size of context window is set to 200 ms and its onset is
kept at 200 msahead of R peak. Fig. 3 shows the window boundaries M and N for
locating T peak.
Fig. 3.M and N is the onset and offset of T
wave respectively; M and Nare
200 ms apart; Nis 200 ms ahead of R
boundaries of ECG wave
As stated earlier, P wave and T wave
marks the beginning and end of one ECG cycle respectively. On having determined
the location of peak of P wave and T wave, the onset and offset of ECG segments
can be estimated. Since P wave is approximately 80 ms in duration, we set the
onset of ECG wave as 50 ms off the peak of the P wave. Also T wave is about 250
ms in duration. Thus the end of ECG segment is set to 100 ms ahead of T peak.
Fig. 4 shows the boundary estimation performance of our proposed method on 2
Fig. 4. The
points A and Bis the estimated boundaryof 1stECG cycle. The points C and D is the estimated boundary of 2nd ECG cycle.
4 Results and Discussions
results obtained after quantitative analysis of our model on all the 105
records in database is discussed here. A total of 9 sets of annotation files
are considered in the dataset. We have chosen two sets of annotation files from
the dataset – .pu0 and .q1c for verification of our proposed
method. The .pu0 annotation has the
waveform boundary measurements automatically determined for all beats. The.q1c annotation contains manually
determined waveform boundary measurements for some beats. The results are compared
against reference annotations allowing for a 5% tolerance level; ,a prediction
is considered to be correct if its value lies within a range of ±5% of the
Table 1. Evaluation
Total number of correct
Total number of incorrect
For each P and
T, the total number of correct predictions are listed. Moreover, the total
number of incorrect predictions, overall accuracy and median accuracy across
all the 105 records are determined using our proposed method for the respective
peaks and troughs.
that we have obtained are exceptionally good. A median accuracy of 100% is
achieved on 105 records for both the waves on both reference annotations. The
accuracy for .q1c annotations is not as good as that obtained for .pu0
annotations. However,manual inspection of .q1c annotations showed us that many
annotations were fairly deviated from where they should be.
Also table 1.
shows that the overall accuracy for T peak detection is lower than the P peak.
It is to be mentioned that detecting T peaks is in fact an inherently difficult
task due its varying morphology 9. The approximation used in this proposed
method to detect boundaries of T wave works accurately for most classes of ECG
signal but may provide inaccurate results for some abnormal ECG signals. This
can be considered as a limitation of our proposed method.
In this work we demonstrate an
accurate and efficient method to segment ECG signals by detecting the peaks of
P waves and T waves. The information of P and T waves gives an estimated
boundary of an ECG cycle. The algorithm has O(n) complexity with respect to
size of ECG input data. The proposed technique is shown to be highly robust for
a wide class of ECG signals.
The authors would like to thank
Innovation & Entrepreneurship Development Centre, NIT Silchar for funding
this project. The authors are also grateful to Mr. Arkajyoti Saha and Ms.
Maitrayee Deb of Silchar Medical College and Hospital for their valuable inputs
1 Badilini, Fabio F. “Method
and apparatus for extracting optimum holter ECG reading.” U.S. Patent
8,560,054, issued October 15, 2013.
2 Hoffman, B.F. and Cranefield, P.F.,
1960. Electrophysiology of the Heart.McGraw-Hill, Blakiston Division.
3 Joshi, Anand Kumar, ArunTomar, and
MangeshTomar. “A Review Paper on Analysis of Electrocardiograph (ECG)
Signal for the Detection of Arrhythmia Abnormalities.” International
Journal of Advanced Research in Electrical, Electronics and Instrumentation
Engineering 3, no. 10 (2014).
4 Laguna P, Mark RG, Goldberger AL,
Moody GB. A Database for
Evaluation of Algorithms for Measurement of QT and Other Waveform Intervals in
the ECG. Computers in
5 Moody GB, Mark RG. The impact of
the MIT-BIH Arrhythmia Database. IEEE Eng
in Med and Biol 20(3):45-50 (May-June 2001). (PMID: 11446209)
6 Taddei A, Distante G, Emdin M,
Pisani P, Moody GB, Zeelenberg C, Marchesi C. The European ST-T Database:
standard for evaluating systems for the analysis of ST-T changes in ambulatory
electrocardiography. European Heart
Journal13: 1164-1172 (1992)
Thakor, Nitish V., and Y-S. Zhu. “Applications of adaptive
filtering to ECG analysis: noise cancellation and arrhythmia
detection.” IEEE transactions
on biomedical engineering 38.8 (1991): 785-794.
Hamilton, P. “Open source ECG analysis.” In Computers in Cardiology, IEEE (2002): 101-104.
Elgendi, Mohamed, Bjoern Eskofier, and Derek Abbott. “Fast T wave
detection calibrated by clinical knowledge with annotation of P and T
waves.” Sensors 15,
no. 7 (2015): 17693-17714.
10 Pan, Jiapu, and Willis J.
Tompkins. “A real-time QRS detection algorithm.”IEEE transactions on biomedical engineering 3 (1985): 230-236.
11 Li, Cuiwei, Chongxun Zheng, and
Changfeng Tai. “Detection of ECG characteristic points using wavelet
transforms.”IEEE Transactions on
biomedical Engineering 42, no. 1 (1995): 21-28.
12 Coast, Douglas A., Richard M.
Stern, Gerald G. Cano, and Stanley A. Briller. “An approach to cardiac
arrhythmia analysis using hidden Markov models.”IEEE Transactions on biomedical Engineering 37, no. 9 (1990):
13Gritzali, F., G.
Frangakis, and G. Papakonstantinou. “Detection of the P and T waves in an
ECG.” Computers and Biomedical Research 22, no. 1 (1989):
14 Chatterjee, H. K., R. Gupta, and M. Mitra. “Real time P and T wave
detection from ECG using FPGA.” Procedia Technology4 (2012):
15 Leutheuser, Heike,
Stefan Gradl, Lars Anneken, Martin Arnold, Nadine Lang, Stephan Achenbach, and
Bjoern M. Eskofier. “Instantaneous P-and T-wave detection: Assessment of
three ECG fiducial points detection algorithms.” In Wearable and Implantable Body Sensor Networks (BSN), 2016 IEEE 13th
International Conference on, pp. 329-334. IEEE, 2016.
16 Mehta, S. S., and N.
S. Lingayat. “Detection of P and T-waves in Electrocardiogram.” In Proceedings of the world congress on
Engineering and computer science, pp. 22-24. 2008.
17 Lagerholm, Martin,
Carsten Peterson, Guido Braccini, Lars Edenbrandt, and Leif Sornmo.
“Clustering ECG complexes using Hermite functions and self-organizing
maps.”IEEE Transactions on
Biomedical Engineering 47, no. 7 (2000): 838-848.
18 Goutas, Ahcène, Youcef Ferdi, Jean-Pierre Herbeuval, Malika Boudraa, and
Bachir Boucheham. “Digital fractional order differentiation-based
algorithm for P and T-waves detection and delineation.” ITBM-RBM 26,
no. 2 (2005): 127-132.
19 Laguna, Pablo, Raimon Jané, and Pere Caminal. “Automatic detection
of wave boundaries in multilead ECG signals: Validation with the CSE
database.” Computers and biomedical research 27, no. 1