SIGNAL TO NOISE RATIO EVALUATION IN SIGNAL
AVERAGED ECG BY DERIVATIVE DYNAMIC TIME WARPING
AND PIECEWISE LINEAR APPROXIMATION
Roberto L. Avitia, Marco A. Reyna, Miguel E. Bravo
Bioengineering Academic Body, University Autonomous of Baja California, Alvaro Obregon Ave., Mexicali, Mexico
Lucio A. Cetto
Computational Biology Department, The MathWorks, Inc., 3 Apple Hill Drive, Natick MA, U.S.A.
Keywords: Signal averaged electrocardiography, Dynamic programming, Piecewise linear approximation, Heartbeat
alignment.
Abstract: Signal Averaged Electrocardiography (SAECG) is a technique widely used as an alternative to improve
signal to noise ratio (SNR), but sometimes patient’s physiology may alter the characteristics of quasi-steady
heartbeats that are assumed in the averaging. This paper evaluates the noise as a parameter for measuring
the alignment heartbeats by Derivative Dynamic Time Warping (DDTW) and using Piecewise Linear
Approximation (PLA) as well. The records were taken from a group of healthy individuals and the results
show that the number of heartbeats averaged necessary to improve the SNR is less than the traditional
method.
1 INTRODUCTION
The High Resolution Electrocardiography (HRECG)
gives us important information about the normal and
abnormal electrical activity of the heart, such as
Ventricular Late Potentials (VLP). Often, these VLP
occur in people who survive to a heart attack (M.E.
Tagluk et al, 1998). Many studies focus the VLP
detection on the QRS complex by means of the
quantification of its duration (A. Illanes et al, 2008;
Z.E. Hadj, 2005 and 2006; T. Bragge et al, 2004).
When HRECG are been recorded, it is very common
that noise masks signals of interest like VLP. To
improve the quality of records, it can be used
multiple techniques such as the well known Signal-
Averaged ECG (SAECG), a widely used technique
in noise reduction for VLPs studies. SAECG assume
that the noise is completely a random signal and
both the signal of interest (i.e., HRECG) and its VLP
pattern (if exists) are quasi-stationary processes,
which are repeating heartbeat to heartbeat at the end
of the QRS complex or at the beginning of ST
segment (G. Breithard, 1991). The noise level is
reduced proportionately as long as more and more
heartbeats are taken into an ensemble. In the results
presented in this paper, the heartbeats had complied
with a correlation coefficient higher than 0.9
compared with a reference or template (G. Breithard
et al, 1993). Alignment of heartbeats is an important
part of the signal averaging, because the
physiological nature of electrocardiographic signals.
This nature alters the behaviour from heartbeat to
heartbeat in lag, in duration, and amplitude.
Variations in time are due to both the heart rate
variability and the elongation in duration. Variations
in amplitude are due to attenuations or
amplifications on the wave forms. It makes the
heartbeats look lagged, shorter or longer in duration,
and higher or lower in amplitude. This would cause
that the ensemble rejects those heartbeats which do
not reach the minimal correlation coefficient
criterion (i.e., 0.9). An alignment technique firstly
used in speech recognition was called dynamic
programming, and now commonly known as
"Dynamic Time Warping” (H. Sakoe et al, 1978). It
has been used in making decisions on segmentation
of ECG signals, showing good results (A. Zifan et
al, 2007).
201
L. Avitia R., A. Reyna M., E. Bravo M. and A. Cetto L. (2010).
SIGNAL TO NOISE RATIO EVALUATION IN SIGNAL AVERAGED ECG BY DERIVATIVE DYNAMIC TIME WARPING AND PIECEWISE LINEAR
APPROXIMATION .
In Proceedings of the Third International Conference on Biomedical Electronics and Devices, pages 201-205
DOI: 10.5220/0002748802010205
Copyright
c
SciTePress
In this paper, we recorded 30 HRECG each of them
including 350 heartbeats taken from 30 healthy
subjects. A method on dynamic programming and
heartbeats segmentation, based on Piecewise Linear
Approximation (PLA) (H.J.L.M. Vullings et al,
1997) was used for heartbeats alignment. Results
show that using PLA it is possible to reach similar
noise levels by mean of the added of less heartbeat
in the ensemble than in conventional method (G.
Breithard, 1991).
2 MATERIALS AND METHODS
A CARDIAX PC-ECG system was used at 500 Hz
sampling rate for electrocardiography tracings.
Interpolation to a rate of 2 was applied achieving a
double sampling frequency. Simple smoothing was
applied to remove the high frequency noise. Each of
the obtained curves was separated into heartbeats
using a conventional method for R peak detection.
Those, that meet a correlation higher than 0.9, i.e.
100 to 350 beats were selected and averaged. Then
the level of the noise in the ST segment (G.
Breithard, 1991) was assessed and the beats were
approximated by straight lines using the method of
Piecewise Linear Approximation (PLA) from which
alignments will be compared with the same
heartbeat reference using dynamic programming
(DTW), and then perform the averaging of the
heartbeats and re-evaluate the noise level in the ST
segment.
2.1 Preprocessing
A moving average band pass Butterworth filter (1 to
100 Hz) of order 5 was applied first removing the
high frequency noise like interspersions and muscle
noise. Next, a previous segmentation was done by
selecting QRS complex with the classical Pan and
Tompkins algorithm (J. Pan et al, 1985), after that
we selected a region around the R-peak, 150 samples
before and 250 samples after the R-peak. Then the
region around the R-peak, 150 samples before and
250 samples after the R-peak were selected and the
template beat is decomposed in three different parts:
a) before the QRS complex (P wave and PQ
segment); b) the QRS complex part and c) after the
QRS complex (ST segment and T wave).
2.2 Piecewise Linear Approximation
The PLA algorithm was used to represent adaptively
any signal trough straight lines. We propose to
approximate the ECG with a series of line segments.
The ECG is regarded as a vector
[ (1),...... ( )]
x
xxn=
,
where
()
x
i
(1 )in
is the voltage of the ECG at
time
i
. The first proposed segment consist of the
first samples of
x
. We approximate this segment
with a straight line connecting the first and the last
sample. As long as this line approximates the
original segment with an acceptable error
e
,
s
more
samples are added to the segment. To calculate the
error consider figure 1, where
j
samples are
approximated by the straight line
()yi ai b=+
. The
error
()ei
for sample
(1 )iij≤≤
should never
exceed an empirical determined threshold calculated
as:
We add s more samples to the segment, until (1)
does not hold. Then, we start shrinking the segment
in order to obtain a segment which does not
exceed
. The new end-point of the segment is the
point
i
for which
()ei
is maximal. If the error on the
new segment remains below
, the line segment to
approximate a part of the ECG is found. The new
segment will start at the end-point of the previous
segment. However, if the error is still not below
,
we shrink the segment again and again, until (1)
holds.
Figure 1: The error
()ei
for a segment.
A complete heartbeat consists of a sequence of lines
which can be displayed in string format. One line
can be represented as a combination of slope and a
horizontal length
(, )ax
Δ
, which enable us to
describe the heartbeat in terms of segment lines as
illustrated in figure 2, where template heartbeat is
represented using PLA i.e. using lines defined by a
slope and number of samples taken in account by
these lines.
2
() ()
()
1
xi yi
ei
a
<∈
+
(1)
BIODEVICES 2010 - International Conference on Biomedical Electronics and Devices
202
Since alignment is an important part of SAECG, a
method to perform it is described as follow.
Figure 2: PLA of a heartbeat taken as template.
2.3 Derivative Dynamic Time Warping
In order to overcome some limitations of the classic
DTW algorithm the Derivative Dynamic Time
Warping algorithm (DDTW) was applied. To find
the similarity between two sequences, DTW looks
for the best alignment, which is generally referred to
as Warp-Path, and thus warps the time axis of one of
the series and calculates the distance between the
two sequences. In some cases it can produce some
misalignments, for instance when multiple points on
one time series correspond to only one point in the
matching time series, or when the two sequences
strongly vary in the Y-axis. Figure 3 shows the
limitations of DTW (S. Chu. et al, 2002).
Figure 3: Alignment produced by DTW. Alignment fails
because of differences in the “y” axis.
In the present case, each input signal is considered
as a sequence of
n
samples
[ (1), (2)....... ( )],
x
xx xn=
and the template is a sequence of
m
samples
[ (1), (2),...... ( )]yyy ym=
. DTW builds a
matrix
[]Dn m×
in which each element represents
the distance between the
ith
element of
()
x
i
and
the
jth
element of
()yj
. Then, a new matrix
θ
is
introduced, with:
(,) (,) min[( 1, 1), (, 1), ( 1,)]
j
i d ji j i ji j i
θ
θθθ
=
+−
(2)
So, that each element is the sum between the local
distance
(,)dji
and the minimum of the total
distances of the neighbor elements.
The warping path
W
, is a contiguous set of matrix
elements that defines a mapping between
x
and
y
.
The
kelement
of
W
is defined as
(, )
kk
Wij=
:
12
, ,....
k
Www w
=
max( , ) 1nm k n m<<+
(3)
The warping path generally undergoes to several
constraints: among them, the requirement for the
warping path to start and finish in diagonally
opposite corner cells of the matrix, restriction to the
number of allowable steps in the warping path to
adjacent cells and monotonicity in time.
Among all the warping paths that satisfy the above
conditions, for recognition/classification purposes of
interest is in the path that minimizes the warping
cost:
DDTW differs from DTW by considering the square
of the difference of the estimated derivatives of
i
x
and
i
y
instead of the original time series:
A simple representative block diagram of procedure
is shown in Figure 4. It is very important to say that
averaging has not been made with heartbeat-
segmented, but with heartbeat-aligned, and SNR
evaluation has been made in the ST segment only.
1
1
(, ) min
k
k
i
DTW x y w
K
=
=
⎩⎭
(4)
111
()( )/2
() ,1
2
ii i i
xx x x
D
xin
−+
+−
=
<<
(5)
SIGNAL TO NOISE RATIO EVALUATION IN SIGNAL AVERAGED ECG BY DERIVATIVE DYNAMIC TIME
WARPING AND PIECEWISE LINEAR APPROXIMATION
203
Representation of every
segmented-hearbeat by their
corresponding samples.
Selection of template by
visual criterion.
Hearbeats separation from
ECG trace.
Segmentation of every
heartbeat using PLA.
Segmented-heartbeats
Alignment using DDTW
Application of averaging to
heartbeats-aligned ensemble.
SNR evaluation in heartbeat
aligned and averaged.
Figure 4: Method used representation by a simple block
diagram.
3 RESULTS
Each heartbeat to be segmented has a distance
matrix alignment much smaller than if it were made
with all samples of the signals, as shown in Figure 5.
Derivative Time Warping alignment technique
produces an alignment based on the slopes of the
lines generated and amplitude values no matter.
Q (QRS for warping)
C (QRS for Template)
Warping Path (Red)
2 4 6 8 10 12 14 16 18
2
4
6
8
10
12
14
16
18
20
22
Figure 5: The segmentation produces a smaller matrix
alignment.
For instance two heartbeats with high difference in
amplitude can be aligned almost completely, as
shown in Figure 6.
Figure 6: Alignment produced by DDTW (a) Aligning
segments P, QRS and T, (b) Heartbeats aligned according
to segment slope. Template reference (red), heartbeat to
align (blue) and heartbeat aligned (black).
Making signal average with no alignment heartbeats
(just those which present high correlation) and
aligning with DDTW and PLA noise level could be
computed using ST segment variance or
R
MS
n
where
R is the number of heartbeat taken in account to be
averaged (G. Breithard et al, 1993).
A graphical representation is shown in figure 7,
where four individuals ECG records were noise
measured.
22
11
()/(()/)
RR
RMS i i i i
ii
nxRxR
μμ
==
=−
∑∑
(6)
BIODEVICES 2010 - International Conference on Biomedical Electronics and Devices
204
Figure 7: Four patients ECG noise measured in typical
SAECG (Blue) and using DDTW and PLA (Red).
4 CONCLUSIONS
The alignment algorithm developed based on
DDTW and PLA provides similar results in noise
reduction compared with traditional method based
on high correlation for same number of heartbeats.
For less number of heartbeats however, it reaches
lower noise levels excluding thus the need to reject
as much as traditional method.
ACKNOWLEDGEMENTS
We would like to thank Dr. Zlatev Roumen
Koytchev for his valuable participation as technical
advisor in this paper.
REFERENCES
M.E. Tagluk and M.J. English, 1998, Time-Frequency
Analysis of Model-Based Ventricular Late Potentials,
in 2
nd
International Biomedical Engineering Days
IEEE pp. 134-136.
A. Illanes-Manriquez, Q Zhang, 2008, An Algorithm for
Robust Detection of QRS Onset and Offset in ECG
Signals, Computers in Cardiology vol. 35, pp. 857-
860.
Z.E. Hadj S., F. Bereksi R., 2005, New algorithm for QRS
Complex Detection, Journal of Mechanics in Medicine
and Biology, vol. 5, No. 4, pp. 507-515.
T. Bragge, M.P. Tarvainen, P. A. Karjalainen, 2004,
High-Resolution QRS Detection algorithm for
Sparsely Sampled ECG Recordings, University of
Kuopio Department Physics Report Series ISSN:
0788-4672.
Z.E. Hadj S., F. Bereksi R., 2006, Detection of the QRS
complex by linear prediction, Journal of Medical
Engineering & Technology, vol. 30, No. 3, pp. 134-
138.
G. Breithard, M.E. Cain, N. El-Sherif, N. Flowers, V.
Hombach, M. Janse, M.B. Simson, G. Steinbeck,
1991, Standars for analysis of ventricular late
potentials using high resolution or signal-avaraged
electrocardiography., European Heart Journal, Vo.
12, pp. 473-480.
G. Breithard, T. Wichter, T. Fetsch, T. Seifert, M.
Borggrefe, M. Shenasa, L. Reinhardt, 1993, Te signal-
averaged ECG: time-domain analysis, European Heart
Journal, vol. 14, pp. 27-32.
H. Sakoe, S. Chiba, 1978, Dynamic Programming
Algorithm Optimization for Spoken Word
Recognition, IEEE Transactions on Acoustics, Speech,
and Signal Processing, vol. ASSP-26, No. 1, pp. 43-
49.
A. Zifan, S. Saberi, M. Hassan, F. Towhidkhah, 2007,
Automated ECG Segmentation Using Piecewise
Derivative Time Warping, International Journal of
Biomedical Sciences Vol. 1, No. 3, pp. 181-185.
H.J.L.M. Vullings, M.H.G. Verhaegen, H.B. Verbruggen,
1997, ECG Segmentation Using Time-Warping,
Advances in intelligent Data Analysis (IDA-97), LNCS
1280, pp. 275-285.
J. Pan, W.J. Tompkins., 1985, A real-time QRS detection
algorithm. IEEE transactions on Biomedical
Engineering, BME-32, pp. 230-236.
S. Chu., E. Keogh, D. Hart, M. Pazzani, 2002, Iterative
Deepening Dynamic Time Warping for Time Series,
In Proc 2nd SIAM International Conference on Data
Mining,
SIGNAL TO NOISE RATIO EVALUATION IN SIGNAL AVERAGED ECG BY DERIVATIVE DYNAMIC TIME
WARPING AND PIECEWISE LINEAR APPROXIMATION
205