ECG Feature Extraction Using Time Domain Morphology and Gradient Based Algorithm
ECG Feature Extraction Using Time Domain Morphology and Gradient Based Algorithm
Ahstract-A Time Domain Morphology and Gradient (TDMG) etc). Fig.l illustrates a typical PQRST-complex and the rele
based algorithm is presented in this paper for the extraction of vant ECG features. Evaluation takes place by examining the
all the fiducial time instances from a single PQRST complex.
morphology of the waveform and the value of the clinically
By estimating these characteristic points, all clinically important
temporal ECG parameters can be calculated. The proposed
important parameters. For example, a prolonged QT-interval is
algorithm is based on a combination of extrema detection and a bio-marker of arrhythmia, while an elongated QRS may be
slope information, with the use of adaptive thresholding to indicative of bundle branch block. Similarly, abnormal wave
achieve the extraction of 11 time instances. A pre-processing morphologies (additional peaks, discontinuities) are related to
step removes any noise and artefacts from the captured ECG
a number of heart conditions (e.g. hypertrophy, myocardial
signal. Initially, the position of the R-wave and the QRS-complex
boundaries are localized in time. Following, by focusing on
infarction) [1], [2].
the part of the signal that precedes and succeeds the QRS
QRSComplex
complex, the remaining fiducial points from the P and T waves
are estimated. The initial localisation of the wave boundaries
is complimented by amendment steps which are introduced to
cater for atypical wave morphologies, indicative of particular
heart conditions. The proposed algorithm is evaluated on the QT
and PTB databases against medically annotated ECG samples.
The results demonstrate the ability of the proposed scheme,
to estimate the ECG fiducial points with acceptable accuracy
from a single-lead ECG signal. In addition, this investigation
reveals the ability of the TDMG algorithm to perform accurately
irrespective of the lead chosen, the different disease categories
and the sampling frequency of the captured ECG signal. Fig. 1. The PQRST complex. Image reproduced from [3] .
Authorized licensed use limited to: VIT University. Downloaded on October 20,2020 at 03:39:07 UTC from IEEE Xplore. Restrictions apply.
[10]. WT analysis transfonns the ECG signal into its frequency The two main objectives that the TDMG algorithm attempts
components with their corresponding time localisation [11]. to achieve are accuracy and Ubiquity. In order for the extracted
Thus, by investigating the value of WT coefficients at different features to be used for medical evaluation, the desired param
decomposition levels, the ECG features can be estimated. The eters must be calculated with the maximum possible accuracy.
"Common Standards for Quantitative Electrocardiography" Ubiquity refers to the ability of the algorithm to handle all the
(CSE) project provided a reference database and also defined intricacies of different heart conditions as these are reflected
the acceptable tolerance limits for automated ECG feature on the ECG waveform (e.g. ST-elevation, ST-depression, frag
extraction [12], [13] systems. mented QRS). In addition, the TDMG algorithm is designed to
In this paper, we present the design of a Time-Domain be independent of the lead used to capture the ECG signal, as
Morphology and Gradient (TDMG) based algorithm for the well as be able to perfonn adequately on ECG signals sampled
extraction of the fiducial time instances of the PQRST com with low sampling frequencies (l00 -250Hz).
plex. Different to a number of previous gradient-based ap (P-peak pOSition,
the TDMG algorithm also takes into account some atypical ..... .......
...
.
I
considering them as inflection points. Due to the morphology
of the ECG waves (P,QRS,T), the value of the slope exhibits
an abrupt change at the onset/offset time instances of each
wave compared to its value at the isoelectric line segments.
By capturing this change one can determine the onset/offset
I
L ________________________________________________________________ J
,fIn]
time instances. On the other hand, the peak time points are Fig. 3. Pre-Processing Stage. x[n] is the sampled ECG-signal and j[n] is
extracted by considering these points as local extrema around the formulated feature signal.
their vicinity. Following the standard medical convention,
the TDMG algorithm considers that, the Q and S-peak are After the completion of the denoising stage, we proceed to
always negative deflections (local minima) while the R-peak the formulation of the feature signal. Inspired by the Pan
is positive (local maximum). Different to this, the P and T Tompkins algorithm, the feature signal is synthesized as a
peak can be upright (positive deflection), downright (negative linear combination of the first and second derivatives of the
deflection) or sometimes biphasic (both positive and negative ECG signal [5]. The derivative signals are calculated with
segments) compared to the isoelectric line. A block diagram the use of a moving slope filter. This filter operates on a
of the TDMG algorithm is depicted in Fig. 2. given sliding window and approximates the slope (derivative)
118
Authorized licensed use limited to: VIT University. Downloaded on October 20,2020 at 03:39:07 UTC from IEEE Xplore. Restrictions apply.
of that window with the use of a first order model. The extreme point, it must have the highest value in its vicinity
smoothing filter is also applied on the derivative signals. and must be preceded by a time point which has a value
The feature signal j[n] is defined as linear combination of smaller than a predefined threshold. From the collection of
the first and second derivative using experimentally verified the extreme points, the R-peak time instance is extracted as
coefficients; j[n] 1.3grad1[n] + 1.1grad2[n]. The feature
= the local maxima which has the highest gradient value (slope)
signal attenuates the P and T-wave while enhances the QRS around it. This is accomplished by summing the value of the
complex. By looking at Fig. 4 it is clear that the boundaries of gradient signal for a 30ms window around the local maxima
the QRS complex can be approximated from the feature signal points and comparing the sums. Nevertheless, in situations
with the use of a threshold policy. The entire pre -processing where the R-wave height is small, other extreme points (e.g.
stage is illustrated in Fig.3. P-peak, T-peak) may exhibit higher gradient around them,
0
•
g - 000 g
onset and offset time instances are extracted by comparing
200 400 600 800 200 400 600 800
time (msec) time (msec)
the value of the feature signal against an adaptive threshold.
[JJ i'0000
� 5000
Feature Signal The maximum point of the feature signal is identified (t fmax)
and used as a reference. The time windows within which the
QRS boundaries are searched are 170ms wide, defined by
the following time instances, t fmax 200ms and t fmax - -
S
"0
GOO0
5000
!
�.
w i d w wi d w
OR�_
n o
170 ms
'1"','
,
,
,
,
OR�.nH.
n o
170ms
,
,
,
,
, ,
respectively. , ,
.:g , ,
�
,
3000
1) Temporal Search Windows: The estimation of the on
QRS-off !
>
,
2000 QRS-on
set/offset time points for each wave (P,QRS,T), is accom
,
,
plished by investigating the value of the gradient signal (for
P,T) or the feature signal (for QRS), within specific time
1000
0
100
j � ,I
200 300 400 500
,
600 700 800
sample number
windows around a reference point. The values that are used
to define the width of the search window for each point, are Fig. 5. QRS boundaries extraction from the feature signal.
based on the experimentation that was carried out during the
development of the algorithm and ensure that the point to be The extracted R-peak time instance is checked if it falls
estimated, always falls within these windows irrespective of within the QRS boundaries. If this is not satisfied, the initial
the ECG morphology, the lead, or the sampling frequency of approximation of the R-peak position is considered erroneous.
the signal. The R-peak position is then calculated as the local maxima
2) QRS-complex: Typically the R-wave is the most out present within the QRS boundaries. Maxima are calculated
standing feature of the PQRST-complex. However, in a number with the use of the same peak detection algorithm limited this
of leads in the standard I2-lead ECG system, a high negative time in returning at most two maxima for comparison. The
deflection which corresponds to either the Q or the S-wave is complete procedure that is employed for the characterisation
the most prominent feature. This is caused due to the polarity of the R-wave is summarized in Proc.I.
of the different leads and the direction of the heart's electrical Having obtained the final R-peak position, the next step in
axis. To account for this, we follow a two-stage process in the the feature extraction algorithm includes a refinement of the
characterisation of the R-peak time instance. QRS boundaries and the identification of the time instances
To begin with, a peak detection algorithm is executed on the for the Q and S-wave. The refinement on the QRS boundaries
PQRST-complex to detect the position in time of all the local is required due to the fact that in ECG signals captured
maxima. In order for a time instance to be characterised as an from subjects suffering various diseases, the QRS-complex
119
Authorized licensed use limited to: VIT University. Downloaded on October 20,2020 at 03:39:07 UTC from IEEE Xplore. Restrictions apply.
Procedure 1 QRS Features Extraction Pseudocode. 3) P and T-wave: The P and T-waves are curved shaped
- Detect local maxima in the entire PQRST-complex deflections occurring before and after the QRS-complex. P
(Xl, h),(X2, t2) ... (xn, tn) and T waves can exhibit either convexity or concavity with
Calculate the steepness of each maxima Xl --t dXl,··· , Xn --t
dXn
respect to the isoelectric line. This is dependent on the lead
- Find maxima with highest steepness: maX(dXl, ... , dXn) that captures the ECG signal as well as the heart condition of
- Designate this as the R-peak at time rt the subject. In the following, we describe the details of the
- Estimate QRS boundaries (qrson, qrsoff) from feature signal TDMG algorithm in respect to the P-wave features extraction.
if qrson < rt < qrso ff then
The P-peak is considered to be a local extrema (maximum
Correct R-peak
else
or minimum) in the portion of the signal that precedes the
Designate the highest maxima within [qrson qrsoff 1 as the detected QRS-complex. Since the P-peak can either be a local
R-peak maximum or minimum point, a peak detection algorithm is
end if tasked with returning the time instances of the local maximum
Proceed to the QRS boundaries refinement
and minimum samples. The decision on which one of these
two points is the P-peak is taken by comparing the absolute
difference of the two extreme values with the isoelectric line.
may exhibit fragmented segments. Fragmented QRS shows The value of the isoelectric line is taken as the value of the
irregular shapes on the ECG waveform. Examples include, signal at the QRS-onset which is supposed to be lying on
notches, double peaks, and "plateaus". These discontinuities the baseline. The local extrema which demonstrates higher
may result in the feature signal having a very small value in separation from the isoelectric line is considered as the P
these fragmented segments. This value might be erroneously wave peak. The time instances of the onset and offset of the
detected as the onset/offset of the QRS-complex. The amend P-wave are extracted as the inflection points on the left (P
ment that is introduced at this stage simply looks at the onset) and right (p-offset) of the P-peak. For the P-onset the
vicinity of the originally extracted boundaries for values of the portion of the gradient signal (grad1[n]) from the beginning up
feature signal which are 20 times higher than the value of the to 35ms before the P-peak is checked and the last time instance
threshold used to calculate the boundaries. If this is found to which has a gradient value smaller than a predefined threshold
be true, this translates to the initial boundaries being erroneous is identified as the P-onset (see Fig. 7). Similarly, for the P
since such high values of the feature signal only exist within offset, this investigation starts 25ms after the P-peak point and
the QRS complex. The new boundaries are searched in a up to 15ms before the QRS-onset and the first time point of
smaller window on the left side and right side of the initial the gradient, found to be smaller that the same threshold, is
boundary for the QRS-onset and QRS-offset respectively. This extracted as the P-offset.
amending step efficiently deals with any erroneous detections For the extraction of the T-wave fiducial points, a similar
caused from fragmentations or in some cases inadequate signal procedure is executed on the portion of the signal that succeeds
sampling. An example of this amendment on a fragmented the detected QRS complex. Because the T-wave typically has
QRS-complex is given in Fig. 6. The "notch" on the S-wave a longer duration than the P-wave, longer windows are used
causes the erroneous estimation of the QRS-offset in the first around the T-peak instance to partition the signal in the two
phase and the proposed amendment effectively identifies this parts where the algorithm looks for the onset and offset points
and corrects it. The final part of the QRS segment features (see Fig. 7). Moreover, the QRS-offset value is used as the
extraction is devoted to the detection of the Q- and S-peak isoelectric reference.
instances. These are extracted as the local minimum between
the QRS-onset and the R-peak and the R-peak and the QRS
offset for the Q-peak and the S-peak respectively.
0.5 0.5
5�OO 5400 5600 5800 6000 5°200 5400 5600 5800 6000
�
J
-l�
0 [jJ [j[]
�
tOO
4000
6OO0
4000
window
2000 2000
(a) A fragmented QRS-complex (b) QRS offset before and after the amendment
Fig. 6. An example of amending the QRS boundaries due to the presence Fig. 7. P and T-wave feature extraction.
of a fragmented segment.
120
Authorized licensed use limited to: VIT University. Downloaded on October 20,2020 at 03:39:07 UTC from IEEE Xplore. Restrictions apply.
(both positive and negative deflections) patterns or "double irrespective of the lead that is used and the characteristic ECG
humps" patterns (two sequential convex!concave deflections). morphologies. All the thresholds are defined in a parameterised
Such morphologies are known to be associated with a number way, typically being a small percentage of the amplitude range
of diseases. These peculiar waves may lead the algorithm to ( max - min ) of the ECG and the featured signal. In addition,
erroneous results in the calculation of the onset and otlset. the bandpass filter order, the moving average filter window
To accommodate this, an extra step is carried out for both and the time constants used to define the windows, in which
the P and T-wave where the value of the ECG signal at the fiducial points are searched, are all defined with respect to
the onset and offset points is compared to the value of the the sampling frequency of the ECG signal.
signal at the isoelectric line, taken at QRS-onset and QRS
otlset for the P-wave and T-wave respectively. These three III. EXP ERIMENTATION RESULTS
values must all fall within a certain limit since the three
points are supposed to be lying on the isoelectric line. If The experimental evaluation of the TDMG feature extrac
the difference between these values exceeds a threshold then tion algorithm was carried out using annotated ECG signals
the onset/offset point is considered to be wrong, thus an from the QT database (QTDB) available at Physionet [14].
amendment takes place where the new onset/otlset point is From the 105 records of the QTDB, we chose 50 records from
again found using the gradient signal threshold at the part of the available subgroups and validated our algorithm's with
the signal that precedes/succeeds the initially extracted time respect to the existing annotations. In addition, ECG signals
point. An example of the refining process being applied on a were extracted from the PTB database (PTBDB) and given
P-wave which exhibits a "double hump" pattern is illustrated in to cardiologists for manual annotation. The PTBDB contains
Fig. 8. Complete results from applying the TDMG algorithm standard IS-lead ECG recordings at 1KHz from 290 subjects
on a PQRST-complex is illustrated in Fig. 9 from different disease categories. The experts annotated the
relevant fiducial points for a single heartbeat from the standard
12-leads for a total of 10 patients covering all the available
disease categories, resulting in a pool of 120 ECG heartbeats
which was used to evaluate the TDMG algorithm.
The reason for choosing signals from the PTBDB in
addition to the extensively used QTDB is to evaluate the
performance of the TDMG algorithm on ECG signals from
.��-,:';;;,-
11m. (m_l
---�L-".",:;;-�,..--L-,,:;;;:--d the standard l2-lead system as well as on ECG signals
(a) Initial P-wave boundaries (b) Amended P-wave boundaries from different disease categories. Our intention is to ascertain
Fig. 8. An example of the P-wave amendment on a "double humped" P-wave. the applicability of the TDMG on the standard ECG leads
as well as on the various intricate ECG morphologies. In
situations where the experts could not identify the presence
1200 .----.---...-��;..".;.;.:.; ;;.... -....
-r-.__--r--.,... . .,
T OMG Results
121
Authorized licensed use limited to: VIT University. Downloaded on October 20,2020 at 03:39:07 UTC from IEEE Xplore. Restrictions apply.
Feature Pon Ppeak Pof! QRSon Rpeak QRSof! Ton Tpeak Tof!
no of beats 1410 1413 1413 1528 1528 1528 464 1528 1387
QTDB mean (ms) 0.33 7.6 11.2 4.1 -5.2 5.1 12.1 2.8 5.6
std (ms) 21.1 15 20.8 8.7 15.6 12.4 24.6 25.3 28.6
no of beats 114 114 114 120 115 120 118 118 118
PTBDB mean (ms) 0.2 -1.2 -1.5 -4.1 -1.4 1.3 -4.1 1.1 -11.9
std (ms) 18.7 19.2 22.4 6.1 4.5 8.7 18.8 11.3 19.8
mean (ms) 10.2 -0.4 -5.7 -7.8 -9.3 -3.6 16 23.2 18.6
10. IS
TO (QTDB) [15]
std (ms) 14 10.9 13.5 4.4 10.7 29.8 28.2 29.7
CSE [12] std (ms) 10.2 - 12.7 6.5 - 11.6 - - 30.6
TABLE I
PERFORMANCE RESULTS OF THE TDMG ALGORITHM ON SIGNALS FROM THE QTD B AND PTBD B AND ACCEPTABLE TOLERANCE LIMITS
sense that the difference in the standard deviation the two proposed algorithm can be successfully applied in all standard
[i] [JJ
algorithms report, is under two samples (i.e. 8ms). 12 leads, accurately handle intricate ECG morphologies and
�500
o
.!:!.
� 500 �
Future work involves the investigation of schemes to en
g-1000 0 100
hance the robustness of the TDMG algorithm against baseline
-1000 0 100
.. .. ..
c: c: c:
:::J :::J
�
C" C"
:::J
wandering. This will particularly improve the detection of the
.t
[IJ [iJ
,t U. o
error(msec) error(msec) error(msec) P and T-peaks as this is dependent on the baseline value. We
$"
�1500 1000
are also working towards the incorporation of a partitioning
QRS-onset $" R-peak $" QRS-olfset
1000
r[]J
technique in order to separate a train of ECG heartbeats into
I 500
c:
.!:!.
500 >-
g �
individual PQRST-complexes. This will allow the automated
0-50 0 50 -500 ..
0 50 -1000 0 100
.. analysis of the ECG signal in real-time.
c:
:::J :::J
C" C" C"
,t ,t ,t REFERENCES
'"
11000
error(msec)
T-onset '"
[1;] [1]
T-peak
11000
error(msec)
'"
error(msec)
T-olfset [I] R. Baltazar, Basic and Bedside Electrocardiography.
Williams & Wilkins, 2009.
Lippincott
i=1Il
[2] T. B. Garcia and N. E. Holtz, 12 Lead ECG: The Art of Interpretation.
500 �
c:
500 �
c:
Jones and Bartlett Learning, 2002.
gO�
-100 0 100 g-1000 0 100 -1000 0 100
.. .. [3] http://www.skippinghearts.com.
:::J :::J
[4] B. U. Kohler, C. Hennig, and R. Orglmeister, "The principles of software
.t .t
�
u. qrs detection," IEEE Eng. Med. BioI. Mag, vol. 21, no. I, pp. 42-57,
error(msec) error(msec) error(msec)
2002.
[5] J. Pan and W. J. Tompkins, "A real-time qrs detection algorithm," IEEE
Fig. 10. Error distributions of the extracted parameters from the experimen Trans Biomed Eng, vol. 32, no. 3, pp. 230-236, mar 1985.
tation on the QTDB. [6] P. S. Hamilton and W. J. Tompkins, "Quantitative investigation of QRS
detection rules using the MITIBIH arrhythmia database." IEEE Trans
Biomed Eng, vol. 33, no. 12, pp. 1157-1165, dec 1986.
IV. CONCLUD ING REMARKS [7] P. Laguna, R. Jane, and P. Caminal, "Automatic detection of wave
boundaries in multilead ecg signals: validation with the cse database,"
This paper reported the design of the TDMG algorithm Comput Biomed Res., vol. 27, pp. 45-60, Feb 1994.
for the extraction of all the fiducial points from the ECG [8] S. Mahmoodabadi, A. Ahmadian, M. Abolhasani, M. Eslami, and
J. Bidgoli, "Ecg feature extraction based on multiresolution wavelet
waveform. The proposed algorithm is based on the morpho transform," in IEEE EMBS, Jan 2005, pp. 3902 -3905.
logical characteristics that the composite waves of the PQRST [9] J. Sahambi, S. Tandon, and R. Bhatt, "Using wavelet transforms for ecg
complex demonstrate. After removing the corrupting noise and characterization. an on-line digital signal processing system," IEEE Eng
Med Bioi Mag, vol. 16, no. I, pp. 77 -83, jan.-feb. 1997.
artefacts from the ECG signal, the TDMG algorithm initially [10] J. Martinez, R. Almeida, S. Olmos, A. Rocha, and P. Laguna, "A
detects the boundaries of the QRS complex by employing an wavelet-based ecg delineator: evaluation on standard databases," IEEE
Trans Biomed Eng, vol. 51, no. 4, pp. 570-581, Apr 2004.
[II] c. Li, C. Zheng, and C. Tai, "Detection of ecg characteristic points
extended version of the Pan -Tompkins detection method. The
proposed extension accounts for fragmented QRS segments, using wavelet transforms," IEEE Trans Biomed Eng, vol. 42, no. I, pp.
occurring typically in a number of heart conditions. In the 21 -28, jan. 1995.
[12] The CSE working party, "Recommendations for measurement standards
in quantitative electrocardiography," Eur Heart 1., vol. 6, no. 10, pp.
sequel the algorithm extracts all the fiducial points from the
remaining P and T waves by taking advantage of the curva 815-825, Oct 1985.
ture that these two waves exhibit and considering the onset [13] J.L Willems et aI., "Assessment of the performance of electrocardio
and onset of these points as inflection points. The TDMG graphic computer programs with the use of a reference database,"
Circulation, vol. 71, no. 3, pp. 523-5, Mar 1985.
algorithm is evaluated with ECG samples from two databases [14] A.L. Goldberger et. aI., "Physiobank, physiotoolkit, and physionet com
(QTDB, PTBDB) and the obtained results, apart from the P ponents of a new research resource for complex physiologic signals,"
Circulation, vol. 101, no. 23, 2000 (June 13).
wave fiducial points, are either within or very close to the
[15] R. Jane, A. Blasi, J. Garcia, and P. Laguna, "Evaluation of an automatic
acceptable tolerance limits, particularly in the high resolution threshold based detector of waveform limits in holter ecg with the qt
signals from PTBDB. Finally, this investigation reveals that the database," in Compo Cardio., sep 1997, pp. 295 -298.
122
Authorized licensed use limited to: VIT University. Downloaded on October 20,2020 at 03:39:07 UTC from IEEE Xplore. Restrictions apply.