Anda di halaman 1dari 60

BioMedSigProcAna

Event Detection:
Qrs-Complexes in Ecg Signals
Josef Goette
Bern University of Applied Sciences, Biel/Bienne
Institute of Human Centered Engineering - microLab
Josef.Goette@bfh.ch

February 18, 2013

Contents
1 Introduction
2 Qrs
2.1
2.2
2.3
2.4

Detection
General Structure of Qrs Detector
Simplest: Derivative-Based Ideas .
Aside: Integer Filters . . . . . .
The Pan-Tompkins Algorithm . . .

References

6 EventDet

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

3
3
10
14
28
56

2013

BioMedSigProcAna

c
Josef
Goette, 20072013
All rights reserved. This work may not be translated or copied in
whole or in part without the written permission by the author, except
for brief excerpts in connection with reviews or scholarly analysis.
Use in connection with any form of information storage and retrieval,
electronic adaptation, computer software is forbidden.

6 EventDet

ii

2013

BioMedSigProcAna

Introduction

Events and Epochs


biomedical signals carry signatures of physiological events
epoch =
part of a biomedical signal related to a specific
event
biomedical signal analysis
for monitoring and diagnosis
requires identification of epochs
requires investigation of related events
once an event has been identified, the corresponding waveform may be segmented & analyzed in terms of
amplitude
wave shape (morphology)
time duration
time intervals between events
energy distribution
frequency content
. . . and many more
therefore: event detection is an important step in biomedical signal analysis

6 EventDet

2013

BioMedSigProcAna

Examples of Events: Waves in Ecgs


noisy ECG signal (random noise)
2

R
T

ECG

P
0

1
Q
S

2
0.2

0.4

0.6

0.8

1
1.2
time in seconds

1.4

1.6

1.8

P wave: Duration less than 120 msec with frequencies below


1015 Hz.
Pq segment: Lasts about 80 msec; is a non-event
Qrs wave: Lasts about 70110 msec, frequencies mostly concentrated in the interval 1050 Hz
T wave: Has frequency content similar to that of the P wave.
St segment: Duration is usually about 100120 msec and is
normally flat; is a non-event

For the various waves in the Ecg signal we have a summary


of the main attributes in [Goe13c, Section 2]. You find a more indepth treatment in [SL05, Section 6.2.3] and in [Ran02], where
you find, besides more general information, in Section 4.2.1 a
discussion targeted to event detection.

6 EventDet

2013

BioMedSigProcAna

Qrs Detection

2
2.1

General Structure of Qrs Detector

General Requirements on a Qrs Detector


must be able to detect a large number of different Qrs
morphologies to be clinical useful
must be able to follow
sudden changes
gradual changes
in prevailing Qrs morphology
must not lock onto certain types of rhythm, but treat next
possible event as if anything could happen next

6 EventDet

2013

BioMedSigProcAna

Detector-Critical Types of Noise and Artifacts


noise might be in nature
highly transient
or persistent (e.g. power-line interference)
problem of conditioning Ecg signals w.r.t. noise has been
treated
however, term noise has a somewhat different meaning
when considered form the Qrs-detection viewpoint
P- and T-wave must here be treated as noise
noise might have physiological as well as technical
origins

We refer to our accompanying document [Goe13a] for the


problem of conditioning Ecg signals with respect to noise.

6 EventDet

2013

BioMedSigProcAna

Classification of Noise Problems


signal an noise problems in Qrs detection can be classified into
two main categories with further sub-classification
changes in morphology (including amplitude changes)
of physiological origin
due to technical problems
occurrence of noise
Ecg signals with large P- and T-waves
noise of myoelectric origin
noise due to transient artifacts (mainly due to electrode problems)

6 EventDet

2013

BioMedSigProcAna

General Block-Diagram of Qrs Detectors


most Qrs detectors described in the literature: developed
from ad hoc reasoning and experimental insight
general detector forms
pre-processor: enhance Qrs complex while suppressing noise and artifacts
usually: linear filtering followed by a non-linear transformation
decision rule for detection
prepocessor
x[n]

linear
filtering

nonlinear
transformation

decision
rule

x[n] =
Ecg-signal input to detector
i , i = 1, 2, . . . =
series of occurrence-times of detected
Qrs complexes

The goal of the linear filter in the above block diagram is


to reduce artifacts while keeping the essential spectral contents
of the Qrs complex. It has a bandpass characteristics and reduces the influence of muscle noise, P- and T-waves, power-line
interferences and baseline wander. The center frequency of the
filter varies from 15 Hz to 25 Hz with a bandwidth varying from
6 EventDet

2013

BioMedSigProcAna
5 Hz to 10 Hz. Note that waveform distortion is, in contrast to
other types of Ecg-signal filtering, not a critical issue in Qrs
detection; instead, the goal is to improve signal-to-noise ratio to
achieve good detector performance.
The goal of the nonlinear transformation is to further enhance the Qrs complex relative to the remaining background
noise. Additionally, it must transform each Qrs complex into a
single positive peak that is better suited to threshold detection.
In general, the nonlinear transformation might be memory-less
(static)rectification or squaring are examplesor a more complex transformation involving memory. Note, however, that not
all Qrs detectors use a nonlinear transformation in their preprocessing stage.
The goal of the block named decision rule is to perform,
based on the output of the pre-processor, a test on whether at
a certain time a Qrs complex is present or not. The decision
rule might be implemented as simple as an amplitude threshold procedure, but it may perform additional tests, for example
on reasonable durations of certain waveforms, to obtain better
immunity against various types of noise.
Qrs detectors are usually designed to detect heartbeats.
They rarely need to produce occurrence times of the Qrs complexes with high resolution in time. If time resolution is nevertheless important, it may be necessary to improve the initial
resolution with algorithms that perform time alignment of the
detected beats and thus reduce the problem of smearing which
might occur when computing the ensemble average of several
beats (recall the synchronized averaging, which we have discussed in [Goe13a]).

6 EventDet

2013

BioMedSigProcAna

Qrs Detection as an Estimation Problem


theoretical justification of Qrs-detector structure on page 6
investigate statistical models of Ecg signals
use maximum-likelihood estimation techniques to derive detector structures corresponding to the signal
model of interest
example model: unknown occurrence-time and amplitude

v[n] ,

x[n] = as[n ] + v[n] ,

v[n] ,

where

0n1,
n+D1,
+D nN 1,

N=
length of observation interval
v[n] =
noise
s[n] =
Qrs-complex, known morphology, duration
=
unknown occurrence time of Qrs-complex
a=
unknown amplitude of Qrs-complex

S
ornmo and Laguna [SL05] discuss in Section 7.4 Qrs detection in a more theoretically oriented manner. With the proposed
signal model shown above, it is then feasible to estimate the unknown occurrence time and the unknown amplitude a of the
Qrs-complex. The notion Qrs detection suggests, however,
that we are faced with a detection problem instead of an estimation problem. It is indeed true that the problem considered
in [SL05] can likewise be formulated as a detection problem;
6 EventDet

2013

BioMedSigProcAna
S
ornmo and Laguna discuss these different viewpoints and state
that both of them essentially lead to same detector structures,
for details see [SL05, p. 488].

Qrs Detection as an Estimation Problem (2)


for considered model, theory shows that the Qrs detector
must use as nonlinear transformation a squaring operation
if example model has more a priori knowledge
unknown amplitude is constrained to known interval:
0 < a 1 < a < a2 ,

with known a1 and a1

then theory shows that the Qrs detector must use as nonlinear transformation a rectifier

By generalizing the above Ecg-signal model to a model with


unknown occurrence-time, unknown amplitude, and unknown
duration of the Qrs complex, S
ornmo and Laguna [SL05] derive
the optimum Qrs-complex detector structure.

6 EventDet

2013

BioMedSigProcAna

2.2

Simplest: Derivative-Based Ideas

Using First- and Second Derivatives


differentiation forms basis of many Qrs detection algorithms
differentiation =
basically a highpass filter
amplifies higher frequencies that are characteristic for
the Qrs complex
attenuates lower frequencies that are characteristic
for P- and T-waves
attenuates low frequencies of baseline wander
however: differentiation also amplifies higher frequencies
due to noise ; additional significant smoothing is required
an algorithm based on first and second derivatives, with
smoothing included
by Balda et. al. in 1977
modified by Ahlstom and Tompkins for high-speed
applications in 1983
additionally modified by Friesen et. al. 1990

The references cited in the above slide are [BDD+ 77], [AT83],
and [FJJ+ 90].

6 EventDet

10

2013

BioMedSigProcAna

The Algorithm: Pre-Processing


let x[n] =
input to and y[n] =
output from pre-processing
stage of algorithm
use for pre-processing a linear combination of first- and
second derivative
first derivative: approximated as absolute value of threepoint first difference




y0 [n] = x[n] x[n 2] .
second derivative: approximated as absolute value of threepoint first difference of three-point first differences




y1 [n] = x[n] 2x[n 2] + x[n 4] .
output y[n] of pre-processing stage as linear combination
y[n] = 1.3 y0 [n] + 1.1 y1 [n]

To understand the rationals behind the given approximation


of the first derivative, we start with a first-difference operator:
1 [n] =
x[n] x[n 1]
6 EventDet

11



1 (z) = 1 z 1 X(z) .
2013

BioMedSigProcAna
This filter has a zero at z = 1at Dc frequencyand has a
magnitude response of 2 sin (
/2). For sufficiently low frequencies
, it approximates the derivative operation as we see from
2 sin (
/2) 2
/2 =
. To obtain a smoothing such that highfrequency noise is not too much amplified, we post-process the
sequence 1 [n] by a two-point moving-average filter having transfer function (1 + z 1 ):1
y0 [n] =
1 [n] + 1 [n 1]


= x[n] x[n 1] + x[n 1] x[n 2]

= x[n] x[n 2] .

In the z-transformation domain we equivalently have




Ye0 (z) = 1 + z 1 1 (z)



= 1 + z 1 1 z 1 X(z)


= 1 z 2 X(z) .

Clearly, the complete filter (1 z 2 ) has one zero at z = 1at


frequency
= 0, which approximates the derivative, and a
second zero at z = 1at frequency
= , which suppresses high frequency noise. The magnitude response of the filter is 2 sin (
); for low frequencies we again have 2 sin (
) 2
,
which approximates a derivative with a gain 2.
For the approximation of the second derivative consider the
sequence y0 [n] being the output of a three-point first difference
filter: y0 [n] = x[n] x[n 2]. Processing this sequence by
1 We

denote the output of this processing step by y0 [n] to distinguish it


from y0 [n], which we use in the slide on page 11, and which is the absolute
value of y0 [n].

6 EventDet

12

2013

BioMedSigProcAna
another three-point first difference filter, we obtain2
y1 [n] =
y0 [n] y0 [n 2]


= x[n] x[n 2] x[n 2] x[n 4]

= x[n] 2x[n 2] + x[n 4 .

The Algorithm: Decision Rule


threshold y[n] =
output of pre-processing with a thresholdvalue of 1.0
if y[n0 ] 1.0 for a certain n0 , then compare next 8 samples
to threshold
if 6 or more of these 8 samples pass threshold test, then
take the 8-samples segment as part of a Qrs complex
advantage: additionally to detecting Qrs complexes, the
algorithm produces a pulse that is proportional in width
to the Qrs complex
disadvantage: the method is extremely sensitive to highfrequency noise

2 Again, we denote the output of this processing step by y


1 [n] to distinguish it from y1 [n], which we use in the slide on page 11, and which is the
absolute value of y1 [n].

6 EventDet

13

2013

BioMedSigProcAna

2.3

Aside: Integer Filters

Motivation
in real-time operations of digital filters
many filter designs are unsatisfactory
because huge computation-time requirements
surely if implemented in floating-point operations
but often also if implemented in fixed-point operations
integer filters are a special class of filters having only integer coefficients
here more special: coefficients {0, 1, 2}
here even more special: a preparation to the Pan-Tompkins
algorithm

We admit that we are not sure about the generality of the


notion integer filters. We feel that the notion integer filters
used in the signal processing community is more general than
the same notion often used in the literature on biomedical signal
processing. Our present discussion treats filters in the more
restricted meaning as given, for example, in [Tom93]see there
Chapter 7 entitled Integer Filters, but also see its Chapter 12
on Qrs detection.
For Qrs detection, for example, it is crucial that the Qrs
complex as well as P- and T-waves remain unchanged. This
6 EventDet

14

2013

BioMedSigProcAna
demand on preservation of signal forms calls for linear-phase
filters, which must be Fir filters. Integer filters as we discuss
them here are Fir filters with recursive implementations.
The slide on the previous page 14 states that our integer
filters have only coefficients being 0, 1, and 2. This is not
the full truth: The basic blocks that we consider have such
coefficients, but cascading these basic blocks leads to additional
coefficient values, see page 27.

Simple Example
transfer function
H(z) =

1 z 6
z6 1
N (z)
=
=

1
2
4
2
1z +z
z (z z + 1)
D(z)

zeros
N (zz ) = zz6 1 0
;

zz = ejk2/6 , k = 0, 1, . . . , 5 =
6-th roots of unity
j

................................
.......
...........
......
.......
.....
......
....
.....
...
....
...
.
...
...
...
.
...
..
.
.
...
..
.
...
.
.
..
....
..
..
..
...
.
...
...
...
...
..
...
.
.
...
..
.
.
...
.
...
...
...
...
...
....
.....
....
......
.....
.
.
.
......
.
.
....
........
............................................

zeros: 6-th roots of unity

Note that the transfer function of the above example defines


a filter that has only coefficients 1.
6 EventDet

15

2013

BioMedSigProcAna

Simple Example (contd)

poles zp1 = ej , zp2 = ej = zp1


, zpk = 0, k = 3, . . . , 6

non-trivial poles
e p) =
D(z
zp2 zp + 1 0


zp ej zp ej 0

ej + ej zp + 2 0
zp2
| {z }
|{z} |
{z
}
1
1 = 2 cos 1
{z
}
|

; = 60
j

e
...
.......
.
.
.
... ...
......... ......
.
.
....
.. ..

....................................
.......
..........
......
.......
.....
......
....
.....
...
....
.
.
...
.
...
...
.
...
..
.
...
.
.
...
....
...
.....

....
60
....
..
..
...
...
...
...
.
...
..
.
.
...
...
...
..
...
...
...
...
....
....
.....
.....
......
.
.
.
.
.
.
.......
.......
...........
...............................

poles zp1,2 =

6 EventDet

ej ,

16

= 60

2013

BioMedSigProcAna

Simple Example (contd)


pole-zero map of complete filter (poles eat zeros)
j

.............................
............
........
........
......
......
.....
.....
....
....
....
.
.
...
...
.
...
...
...
.
...
..
.
.
...
.
..
....
..
...
..
...
.
....
...
4-fold
...
...
.
...
.
...
...
.
...
...
.
...
...
...
....
...
...
....
.....
....
......
.....
........
......
.
.
.
.
.
.
.
..............
.........................

c
1

complete pole-zero map

transfer function (filter is Fir, linear phase)


H(z) =

1 z 6
= 1 + z 1 z 3 z 4
1 z 1 + z 2

To see how we obtain the second formthe non-recursive


formof the above Fir-filter transfer function, just multiply
the terms that correspond to the remaining zeros and poles:
1 z 1

1 + z 1



1 ej2/3 z 1



1 ej2/3 z 1


The first pair of terms gives 1 z 2 , the second pair of terms
giveswe use the formula of Euler together with the result
cos (120 ) = 1/2the polynomial 1 + z 1 + z 2 , and we
finally obtain
1 z 2
6 EventDet


1 + z 1 + z 2 = 1 + z 1 z 3 z 4 .
17

2013

BioMedSigProcAna
A second, alternative, way to find the second form of the
transfer function in the slide of page 17 is just to carry-out the
division of the first form: Dividing (1 z 6 ) by (1 z 1 + z 2 )
gives 1 with remainder (z 1 z 2 z 6 ); dividing this remainder by the denominator (1 z 1 + z 2 ) gives z 1 and
a new remainder (z 3 z 6 ); again dividing this new remainder by the denominator gives z 3 and a next remainder
(z 4 + z 5 z 6 ); finally, dividing this last remainder by the
denominator (1 z 1 + z 2 ) ends up with z 4 and a zero
remainder.
The two transfer-function formulae on page 17 suggest that
we could implement the filter as a usual Fir filter by taking the
second formula, but also in a recursive form by taking the first
formula. The question then is which kind of implementation to
select.
To discuss the implementation issue, we take a larger filter
of the considered class of filters where the problem becomes
evident. So consider the N -point moving average-filter having
the transfer function forms3
H(z) =
=


1 
1 + z 1 + z 2 + + z (N 1) ,
N
1 1 z N
.
N 1 z 1

(1a)
(1b)

Naming the input sequence to the filter x[n] and the output
sequence from the filter y[n], the form (1a) could be implemented
in direct form as
y[n] =


1
x[n] + x[n 1] + x[n 2] + + +x[n (N 1)] ,
N
(2)

3 We obtain the second form by applying the formula for the sum of a
geometric series to the first form.

6 EventDet

18

2013

BioMedSigProcAna
whereas the form (1b) could be implemented in direct form as
y[n] = y[n 1] +


1
x[n] x[n N ] ,
N

(3)

or, in what is called the canonical form, as

w[n] = w[n 1] + x[n]



1
y[n] =
w[n] w[n N ] ;
N

(4)

here in (4) w[n] is a newly introduced interval variablean internal signalof the filter.
Comparing the feed-forward implementation (2) to the recursive implementations either (3) or (4), we see that the number of operations needed to compute one output sample favors
the recursive implementations. This lower computational effort
is the reason that many books on biomedical signal processing
suggest the recursive implementations.
We note, however, that the recursive implementations might
become problems with error accumulation and instabilitythe
implementations (3) and (4) both have a pole at z = 1, which
is not strictly inside of the unit circle. To get a feeling of what
might happen, consider the canonical implementation (4) and
assume that the input signal is a white-noise signal.4 The equation w[n] = w[n 1] + x[n] is an accumulator, and accumulating a white-noise sequence gives a non-stationary stochastic
process with a linearly increasing variance, meaning that w[n]
must sooner or later become unstable, which is, of course, not
acceptable. Similar considerations for the implementation (3)
lead to the same conclusions. We do not go into more details,
but, instead, refer to [Orf96], where these issues are discussed
on pages 402 ff., and which has an Appendix A, pages 728 ff.,
discussing discrete-time random signals and their filtering.
4 A discrete-time white noise signal is a sequence where any two samples
are uncorrelated.

6 EventDet

19

2013

BioMedSigProcAna
However, an additional note is in order: The transfer function form (1b) shows perfect pole/zero canceling and an implementation based on this form relies on the achievement of this
perfect canceling by the arithmetic used in the implementation.
Exact integer arithmetic can achieve it: Both, twos complement number systems and, more general, any of the residue
number systems5 have the ability to support error-free arithmetic; in the case of the twos complement number system, the
arithmetic must be performed modulo 2b , that is, with natural
overflow as we explain in [Goe13b], and in the case of residue
number systems, the arithmetic is performed in modulo M .

5 The twos complement number system is a member of the family of


residue number systems, if overflow is correctly treated; see the main text.

6 EventDet

20

2013

BioMedSigProcAna

Simple Example (contd)


frequency response of filter


H(ej )

.................
.................
...
...3.0
......
.....
...
.
...
.
...
.
.. .
...
.
...
..
.
...
.
...
... ..
.. .
...
... ..
.
... ..............
.......... ..
.
.
.
.
.
.
.
.
.
.
.
... .... .......
.... ..
.....
..
.
.
.
....
...
.
..
.
..

0
j

H(e )
..........
.
.
.
.. ..........
.......
/2 ........
.......
.
.......
.. ......
.......
....... ...
.. ........
.
....... .
......
.......
............
..
.......
......
......

.. .........
.
.
.
.
.
.
.
....... .
.......
.......

..
.........
.......
.......
....... ...
/2 .
....... ..
....
6

6 EventDet

21

2013

BioMedSigProcAna

General: Poles
complex-conjugate pole-pair on unit circle
zp1 = ej ,
then

zp2 = ej = zp1


z ej

= z 2 ej + ej z + 1

denominator = z ej

= z 2 2 cos z + 1

has (integer) coefficients {0, 1, 2} only for

0
60
90
120
180

cos
1
1/2
0
1/2
1

2 cos
2
1
0
1
2

Note that the constraints on possible pole locations, which


are given in the above slide, lead to corresponding constraints
on the choice of sampling rates if we need to process continuoustime (analog) signals by discrete-time filters,6 and if, therefore,
natural (physical) frequencies dictate the useful pole locations;
6 Although there are other occasions, we have in biomedical signal processing always, to our knowledge, the situation where the signals to be
processed are in the first instance analog signals.

6 EventDet

22

2013

BioMedSigProcAna
see our exemplifying discussion on the the bandpass filter of the
Pan-Tompkins Qrs detection algorithm given on page 42.
Also note that we compile, later on page 27 and after a corresponding discussion on general zeros, the transfer functions
that can be realized with integer filters.

General: Poles (contd)


possible pole locations for integer polynomial-coefficients

................................
...........
.......
.......
......
.
.
.
.
.
.....
.
.
.
.
.
....
.
....
....
.
.
.
...
.
.
.
...
.
.
.
...
.
...
..
.
.
...
.
.
..
...
..
... 2-fold
2-fold
..
...
..
..
...
.....
...
...
...
...
...
.
.
.
...
...
...
..
....
.
.
....
..
.....
....
......
.....
.
.
.
.
........
.
.......
..............
.........................

6 EventDet

23

2013

BioMedSigProcAna

General: Zeros

first case
numerator = z m 1 ,
zeros:

m=
positive integer

zzm = 1 , zz = ejk2/m , k {0, m1}

zeros are m-th roots of unity

evenly spaced zeros around the unit circle


starting at z = 1

second case
numerator = z m + 1 ,
zeros:

zzm

m=
positive integer

= 1 , zz = ej(/m+k2/m) , k {0, m1}

zeros are m-th roots of (1)

evenly spaced zeros around the unit circle


starting at z = ej/m

The notation k {0, m 1} means that k is in the set


of integers with given lower and upper limits, that is, k =
0, 1, . . . , m 1.

6 EventDet

24

2013

BioMedSigProcAna

Example: Zeros for z m 1 = z 12 1


zeros start at z = 1 for a numerator of type z m 1

jc

..............................
...........
........
.......
......
.
.
.
.
.
.
.....
.
.
.
.
....
.
....
....
.
.
.
...
.
.
.
...
.
.
.
...
.
..
...
.
.
...
.
.
..
...
..
..
..
...
..
..
...
.....
...
.
...
..
...
...
.
.
...
.
...
...
...
...
.
...
.
..
....
...
.....
.....
.......
.
.
.
.
.
..
.........
.........................................

6 EventDet

25

2013

BioMedSigProcAna

Example: Zeros for z m + 1 = z 12 + 1


zeros start at z = ej/m for a numerator of type z m + 1

cj

.....................................
.........
.......
.......
......
.
.
.
.
.
.....
..
.
.
.
....
.
.
.
...
...
.
.
...
.
.
...
.
.
.
...
.
..
...
.
.
...
...
..
..
...
...
.
....
..
...
....
.
...
...
...
...
...
.
.
...
..
...
...
...
.
.
...
..
....
...
.....
.....
.
.
.
.
.......
.
......
.........
.........................................

c1

Note that when the power m is an odd number, the numerator z m + 1 always places a zero at 180at and the
complete zero pattern appears left-right flipped from the zero
pattern of the corresponding numerator z m 1. Take the example m = 3: In the left-hand side of the graphic below we show
the zeros of z 3 1, and in its right-hand side we show the zeros
of z 3 + 1.
j

...................................
.........
.......
.......
......
......
.....
.....
....
...
....
...
...
..
...
...
...
.
.
...
...
...
.
.
..
...
..
...
..
...
.
..
...
...
...
...
..
...
...
...
.
.
.
...
...
...
.
.
.
...
....
...
.....
....
.....
......
......
.......
..........
.......
...................................

...................................
.........
.......
.......
......
......
.....
.....
....
...
....
...
...
..
...
...
...
.
.
...
...
...
.
.
..
...
..
...
..
...
.
..
...
...
...
...
..
...
...
...
.
.
.
...
...
...
.
.
.
...
....
...
.....
....
.....
......
......
.......
..........
.......
...................................

c
1

numerator = z 3 + 1

numerator = z 3 1

6 EventDet

26

2013

BioMedSigProcAna

General: Transfer Functions


two types of general transfer functions
p

H1 (z) =

(1 z m )
q
(1 2 cos z 1 + z 2 )

H2 (z) =

(1 + z m )
q
(1 2 cos z 1 + z 2 )

where m, p, q =
integers
and where {0 , 60 , 90, 120 , 180}
note:
raising p & q by equal integer-amounts corresponds to cascading of identical filters

As an example for cascading, we start with p = q = 1 and


obtain from the above H1 (z)
H11 (z) =

1 z m
.
1 2 cos z 1 + z 2

Taking next p = q = 2, we obtain


2

H12 (z) =

(1 z m )

(1 2 cos z 1 + z 2 )

= H11 (z) H11 (z) ,

which is just the cascade of two identical filters with transfer


function H11 (z).
6 EventDet

27

2013

BioMedSigProcAna

2.4

The Pan-Tompkins Algorithm

Block Diagram of Pan-Tompkins Algorithm

bandpass
filter

squaring
operator

derivative
operator

mov-win
integrator

algorithm for Qrs detection in real-time


referring to general structure on page 6
linear filtering:
bandpass filter & derivative operator
nonlinear transformation:
squaring operator & moving-window (mov-win) integrator
decision rule: not shown
algorithm is intended for Ecg signals that are sampled at
200 samples/sec

The algorithm for Qrs detection in real time has been developed by Pan and Tompkins [PT85]; it has further been analyzed
and described by Hamilton and Tompkins [HT86]. The algorithm recognizes Qrs complexes by analyzing slope and amplitude of Ecg signals taking into account the width of appearing
Ecg waves.

6 EventDet

28

2013

BioMedSigProcAna
We present the algorithm as it is described in [Tom93, Section 12.5]; you might also want to consult [Ran02, Section 4.3.2]
and/or study the original literature [PT85] and [HT86]. The
described form of the algorithm is targeted to an implementation on a microprocessor using integer programming. In the
laboratory exercises we explore variants that might be useful for
hardware implementations.
The slide on the previous page 28 states that the described
Pan-Tompkins algorithm is intended for discrete-time Ecg signals that have been obtained by sampling the true, continuoustime Ecg signal at a rate of 200 samples/sec. This is true because the algorithm uses integer filters that realize pole- and
zero locations that are useful for the intended sampling rate,
but become unreasonable for different sampling rates; see our
discussion starting on page 42.
Because this subsection is quit long, we give an overview
on where you find what. The pre-processing according to the
block diagram shown on page 28 is discussed on pages 3049;
we indicate on page 50 how Pan and Tompkins implement the
decision rule.
For the pre-processing stage we treat the first preprocessing
block, the bandpass filter, on pages 30 to 42. Next we discuss
the derivative operator on pages 44 to 45. The squaring operator
follows on page 46, and the final moving-window integrator is
described on pages 47 to 49.

6 EventDet

29

2013

BioMedSigProcAna

Bandpass Filter
isolates the predominant Qrs energy, which is centered in
the 515 Hz range
attenuates the low -frequency characteristics
of the P- and T-waves
of baseline wander
attenuates the high frequencies associated with
electromyographic noise
power-line interferences
measurement noise
implementation as
integer filter in which poles cancel zeros on unit
circle
cascade of lowpass and highpass filter
Lp
....................................

....
.

.....................................................................Hp.....................................................................
......

........... Bp ...........

..... ........ ....

6 EventDet

30

2013

BioMedSigProcAna

Bandpass Filter: The Lowpass Part


consider the transfer function
HLp1 (z) =

1 z 6
= 1 + z 1 + z 2 + + z 5
1 z 1

the Dc gain is (
= 0 = z = ej0 = 1)

HLp1 (z = 1) = 1 + z 1 + z 2 + + z 5 z=1 = 6

the pole-zero map and the magnitude response are




H(ej )

................................
.......
...........
......
.......
.....
......
....
.....
.
.
.
....
...
.
.
...
...
...
.
...
..
.
...
....
...
....
..
..
...
..
..
...
..
...
5-fold
...
...
..
.
...
.
.
.
...
...
...
...
...
...
...
....
...
.
.
.
.....
....
......
......
.......
.......
..........
...................................

6 EventDet

6.0...........

.. ...
... .....
...
..
c
...
...
...
1
.
...... ..
.
.
... ............ ........
.
.
.
.
.
.
.
.
.
.
.
.
. ..
..... .......... .....
..... ......... .....
.

31

2013

BioMedSigProcAna

Bandpass Filter: The Lowpass Part (contd)


the complete Lp filter is the scaled cascade of two HLp1 (z)
2
the cascade HLp1 (z) HLp1 (z) = HLp1 (z) has Dc-gain
6 6 = 36
for unity Dc-gain it needs a scaling factor 1/36
the used scaling factor is 1/32:
approximates 1/36 to avoid saturation
can be implemented by a right shift of 5 bit-positions
the transfer function of the used lowpass filter then is
1
HLp (z) =

32

6 EventDet

1 z 6
1 z 1

2

Y (z)
1 1 2z 6 + z 12
=

1
2
32 1 2z + z
X(z)

32

2013

BioMedSigProcAna

Bandpass Filter: The Lowpass Part (contd)


the magnitude response is


H(ej )

............
...
..
...
...
...
..
...
..
...
..
...
...
....
.
.
.
.
.
.
.
.
.
.
.
....................................................................
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.........
............. ...................

1.0...

the difference equation for a recursive implementation is

y[n] = 2y[n1] y[n2] +

6 EventDet


1 
x[n] 2x[n6] + x[n12]
32

33

2013

BioMedSigProcAna

Bandpass Filter: The Highpass Part


implemented by a delay-complementary transfer function
highpass = delay allpass lowpass
delay
allpass

32-point
moving average
delay of M -point moving averager is (M 1)/2
for M = 32: half-sample delay 31/2 ; 16 is used

You might want to read more about complementary transfer


functions; [Mit98, pp. 245249] discusses not only delay-complementary transfer functions, but also more general allpasscomplementary filters, power-complementary filters and magnitude-complementary filters. Alternatively, you might use the
newer edition of that book; [Mit06, pp. 391396] additionally
discusses doubly-complementary transfer functions, which are at
the same time allpass-complementary and power-complementary.
Concerning the delay of a moving-average Fir filter we have
the following: First consider a pure delay system
y[n] = x[n n0 ] ,
6 EventDet

34

2013

BioMedSigProcAna
which delays each sample of the input sequences by n0 samples.
The transfer function of this system is H(z) = z n0 , and its
0
.
frequency response becomes H(
) = ej n
Next consider an M -point moving-average filter. Its transfer
function is
H(z) =


1 1 z M
1 
1 + z 1 + . . . + z (M1) =
.
M
M 1 z 1

Its frequency response can be expressed as


H(
) =
H(z = ej ) =

1 1 ej M
j
M 1 e

ej M/2
ej M/2
1 ej M/2

=

M
ej /2
ej /2
ej /2


1 sin(
M/2) j (M1)/2
e
,
=
M sin(
/2)
{z
}
|
Dirichlet function

where we have used Eulers formula, and where the indicated


Dirichlet function is purely real. We see then that H(
) is the

product of two functions, the Dirichlet function and ej (M1)/2


,
with the latter indicating a shift of (M 1)/2 samples. Clearly,
if the filter length M is an odd integer, (M 1)/2 becomes an
integer, and the meaning of delaying by an integer number of
samples is clear. In M is, however, an even integer, (M 1)/2
is not an integer, and the delay needs a special interpretation;
[MSY98, pp. 192194] gives such an interpretation by applying
a discrete-time moving average filter to process continuous-time
signals.

6 EventDet

35

2013

BioMedSigProcAna

Bandpass Filter: The Highpass Part (contd)


the 32-point moving average filter has transfer function
HMA (z) =


1 1 z 32
1
1 + z 1 + . . . + z 31 =
.
32
32 1 z 1

the pole-zero map and the magnitude response are


cj c c c
cc
c

........................................
.........
.......
......
......
......
.....
.....
....
.
.
..
...
.
.
...
...
.
...
..
...
.
...
....
...
...
..
....
...
...
..
...
31-fold
...
..
.
...
.
.
.
...
.
.
.
...
.
...
...
...
...
...
...
....
...
.
.....
.
.
...
......
.......
......
..........
.......
...................................

c
c
c
c
c
c
c

c
c
c
c
c
c1
c

cc
c
c c c c



H(ej )

.
.....
.......
.. ....
... ....
. ..
... ........
.
.
.
..... ......
................................................... ... .. ......................................................
1.0

We note that the phase response of the moving-average transfer function HMA (z) is linearit is just a symmetric Fir filter,
and its recursive realization does, of course, neither change the
magnitude- nor the phase response.

6 EventDet

36

2013

BioMedSigProcAna

Bandpass Filter: The Highpass Part (contd)


the highpass transfer function becomes
HHp (z) = z 16 HMA (z)
= z 16

1 1 z 32
.
32 1 z 1

the pole-zero map and the magnitude response are


c

c c c c

c
c
c

c
c

c
c 1

c c c c



H(ej )

......................................
.........
.......
.......
......
......
.....
....
....
.
.
.
...
..
.
.
...
...
...
.
...
..
.
...
....
..
...
.. 2-fold
..
.. zero
..
...
...
...
31-fold
...
..
.
...
..
.
...
...
...
..
...
...
...
...
...
.
.
.
....
...
.....
.....
......
......
.......
.......
..........
...................................

..... ......
.................................................................. .. ...................................................
.......... .. .
.. . .
... .
.
.
... ..
...
...
.
.
.. ..
.
...
... ..
1.0
... .
.....
.....
.

Note that the phase response of the considered highpass filter


is not exactly linear but merely almost linear. This is because
the involved moving-average filter is a 32-point moving average
filterthe length is selected as a power-of-two such that needed
multiplication by 1/32 can be realized by just bit shiftingand
32 being an even integer gives a half-point delay of (32 1)/2 =
15.5 The delay allpass must, however, of course have an integer
delay, which has been selected to be 16.
6 EventDet

37

2013

BioMedSigProcAna
If we would use instead of the 32-point a 33-point movingaverage filter, we would obtain a highpass filter with exactly
linear phase response, but we would loose the possibility to realize the needed multiplication by mere bit shifting. To illustrate
these arguments, we consider the situation for shorter lengths
of the involved moving average filter.
First consider a 5-point moving-average filter. Its delay is
(M 1)/2 = (5 1)/2 = 2, and we use a delay allpass having a
delay of 2. The transfer function of the realized highpass filter
becomes
HHp5 (z) = z 2 HMA5 (z)

1
= z 2
1 + z 1 + z 2 + z 3 + z 4
5


1
= 1 + z 1 4z 2 + z 3 + z 4 .
5
Clearly, HHp5 (z) realizes a symmetric Fir filter which has a
purely linear phase.
Next consider a 4-point moving-average filter. Its delay is
(M 1)/2 = (4 1)/2 = 1.5, and we must use a delay allpass
having either a delay of 1 or of 2. Consider first the delay 2.
The transfer function of the realized highpass filter becomes
HHp4,2 (z) = z 2 HMA4 (z)

1
= z 2
1 + z 1 + z 2 + z 3
4

1
= 1 + z 1 3z 2 + z 3 .
4
Obviously, HHp4,2 (z) is not a symmetric Fir filter and we cannot expect that it has a linear phase. If we consider to realize
the delay allpass with the delay 1, the transfer function of the
6 EventDet

38

2013

BioMedSigProcAna
realized highpass filter becomes
HHp4,1 (z) = z 1 HMA4 (z)

1
= z 1
1 + z 1 + z 2 + z 3
4

1
= 1 3z 1 + z 2 + z 3 .
4
Again, HHp4,1 (z) is not a symmetric Fir filter and we cannot
expect that it has a linear phase.

6 EventDet

39

2013

BioMedSigProcAna

Bandpass Filter: The Highpass Part (contd)


denote by
x[n] : the input signal to the highpass filter
y[n] : the output signal of the highpass filter
y1 [n] : the output signal of the moving-average filter part
then: the difference equation for the moving-average filter
is

1
y1 [n 1] + x[n] x[n 32]
y1 [n] =
32
then: the difference equation for the highpass filter is
y[n] = x[n 16] y1 [n]

The difference equations given above are nearly the difference


equations given in [Tom93, p. 250] and [Ran02, pp. 187188]
with a slight difference: These two references compute according
to (note that the following two equations stem unaltered from
the articles)
ye1 [n] = ye1 [n 1] + x[n] x[n 32]) ,
(5)


1
y[n] = x[n 16]
ye1 [n 1] + x[n] x[n 32] , (6)
32

that is, they have the moving-average filter not scaled and do the
scaling only when subtracting the moving-average filter output
6 EventDet

40

2013

BioMedSigProcAna
from the delayed input; we do not understand why they seem
to recompute ye1 [n] in (6).
The reference [HT86] computes differently according to
y[n] = y[n 1]

1
1
x[n] + x[n 16] x[n 17] + x[n 32] .
32
32

(7)

We obtain that difference equation by reformulating the transfer


function from page 37 as
1 1 z 32
32 1 z 1


1
1 z 32
1 z 1 z 16 32
=
1 z 1

HHp (z) = z 16

1
32
+ z 16 z 17 +
1 z 1

1 32
32 z

Finally, the original paper [PT85] uses a completely different highpass filter. We suspect, however, that the formula given
there might be in error; indeed, [HT86] state in their introductory section that they use the processor developed by Pan and
Tompkins with slight modifications.

6 EventDet

41

2013

BioMedSigProcAna

Bandpass Filter: The Complete Filter


the magnitude response is
linear


H(ej )

... ...
........................ .......
.
. .
.
.... . . .
.... . . . .
.
... . .
.
.
.... .
.
.
.
.
... .. .....
...
.
...
.
1.0
. .. . ..
.. ........ .....
.
..... ..... ................. ..................
...
....
..
.................................................

in [dB]


H(ej )

dB
................... .......
...... ................ .......
. ....... ..... ... .....
......... ... 0dB
... .... .... .......
....
.
.
.
.
.
.
.
.
.
.
.
... .. ... ... ....
.... ...... ... .... ...60dB........
... . ..
... .
..... ........ ....
...
... ..
..
... ..
.....
.... ................
...
.....
.....
..
.
...
..
.....

If we analyze the complete bandpass filter in detail, we find


that the filter has a middle frequency7 of
mid = 0.2520 rad, a
left 3 dB frequency of
left = 0.1539 rad, and a right 3 dB
7 With a slight abuse of the notion, we call that frequency where the
magnitude is maximum the middle frequency.

6 EventDet

42

2013

BioMedSigProcAna
frequency of
right = 0.3707 rad. If the signal to be processed
stems from a continuous-time Ecg signal which has been sampled at a rate of fs = 200 samples/sec, these characteristics
translate8 to left, middle, and right natural frequencies being
{4.9, 8.0, 11.8}Hz. In the light of the frequency characteristics
of the Qrs complex of Ecg signals as we have compiled on
page 30the dominant Qrs energy is contained in the 515 Hz
frequency range, the realized filter characteristics are reasonable. Note, however, that if the input signal to the Qrs detector stems from a continuous-time Ecg signal sampled at a
rate of fs = 1000 samples/sec, for example, the discrete-time
filter characteristics translate to left, middle, and right natural
frequencies being {24.5, 40, 59}Hz. Obviously, in that case the
bandpass filter is not useful.

8 Recall that the discrete- and continuous-time frequencies are related


by
=
Ts = 2f /fs , where is the continuous-time frequency in
rad/sec, Ts =
1/fs is the sampling time-interval in sec with fs being the
corresponding sampling frequency in Hz, and f is the natural (continuoustime) frequency in Hz.

6 EventDet

43

2013

BioMedSigProcAna

The Derivative Operator


a five-point derivative operator


Hdif (z) = 0.1 2 + z 1 z 3 2z 4 .
the true gain 0.1 is approximated by 1/8
let x[n] =
input, y[n] =
output
the difference equation then becomes
y[n] =


1
2x[n] + x[n 1] x[n 3] 2x[n 4] .
8

Note that the defined derivative operator is an Fir filter with


an impulse response of length 5; this is the reason that we call it
a five-point derivative operator although it uses only 4 terms
for the computationsimagine that the fifth term x[n 2] is
multiplied with a coefficient being zero.

6 EventDet

44

2013

BioMedSigProcAna

The Derivative Operator (contd)


the magnitude response is
linear



H(ej )

....
....
.... ......0.7 ..... .......
...
..
.. . ....
...
... ..
.
.
... ..............
.......
... .
.
...... ....... ...
... .. ...
... .
... ..
...
..
.
... ..
.
.
...
.
..
.
..

in [dB] versus log-frequency


0

j
H(e )
[dB]

20
40
60

...........
............
.
.
.
.
.
.
.
.
.
.
.......
...........
.
.
.
.
.
.
.
.
.
.......
...........
.
.
.
.
.
.
.
.
.
...
...........

103

102
101
log10 (
)

100

We note from the magnitude plots of the bandpass filter on

page 42 that essentially only signal component-frequencies


below 1 rad/sample arrive at the derivative operator. For these
frequencies the proposed operator well acts as a differentiator,
as the second of the above plotsmagnitude in [dB] versus logfrequencyclearly reveals: We have in this double logarithmic
plot a slope of +20 dB/decade in the relevant frequency interval.

6 EventDet

45

2013

BioMedSigProcAna

The Squaring Operator


non-linear operation (as opposed to all other processing
steps)
but static operation (no memory)
let x[n] =
input, y[n] =
output
then: squaring operation is


2
y[n] = x[n] .

makes output-signal samples positive


amplifies output of derivative operator non-linearly
emphasizes higher frequencies in Ecg signal
higher frequencies are mainly due to Qrs complex
smaller differences arising from P- and T-waves are
suppressed

We note that in microprocessor implementations of the PanTompkins algorithm the output of the squaring-operation stage
should be hard-limited to a certain level corresponding to the
number of bits used to represent the data type of the signals.
In hardware implementations, however, we do not need a single
data type for all signals in the chain of operations, and the
decision whether and how to limit the squaring-operator output
must be taken based on other considerations.

6 EventDet

46

2013

BioMedSigProcAna

The Moving-Window Integrator


slope of the R-wave in a Qrs complex is not a guaranteed
measure to detect a Qrs event
many abnormal Qrs complexes that have
large amplitude
large duration
but not very steep slopes
are not detected using only information about slope of Rwave
; need to extract more information from an Ecg signal
to detect a Qrs complex
moving-window integration extracts additional features

6 EventDet

47

2013

BioMedSigProcAna

The Moving-Window Integrator (contd)


let x[n] =
input, y[n] =
output of moving-window integrator
then, difference equation is
y[n] =


1
x[n] + x[n 1] + + x[n (N 1)]
N

is an N -point moving average filter


parameter N =
window-length must be chosen carefully
window-length N approximately the same as widest
possible Qrs complex
usually N is chosen experimentally
for Ecg signals sampled at a rate of 200 samples/sec,
a value of N 30 is reasonable

The given difference equation of the moving-average filter


can, of course, also be written in recursive form: The transfer
function is

1 1 z N
1
Y (z)
1 + z 1 + + z (N 1) =
,
=
X(z)
N
N 1 z 1
and the difference equation in recursive form then reads
y[n] = y[n 1] +

6 EventDet


1
x[n] x[n N ] .
N
48

2013

BioMedSigProcAna
We also note that it might not be necessary to compute the
true average, that is, we could leave away the factor 1/N to simplify the computation, because the subsequent processing step
realizing the decision rule can take account of the resulting
signal gain in that it works with adjusted threshold values. If
we nevertheless like to have the normalizationthe division by
the number N of samplesit is clearly best to choose N = 32,
which is in the order of the proposed 30, because the division
then becomes a mere bit shift.
Concerning the selection of the window size N , the argumentation is as follows: If the window size of the moving-average
filter is too largewe have a too wide window, then the integration waveform y[n] tends to merge Qrs complexes and subsequent T-waves together. If, however, the window size is too
small, a single Qrs complex might produce several peaks at the
integrator-stage output. For the considered Ecg signals sampled at a rate of 200 samples/sec, a choice of N = 30 has 29
intervals between first and last sample in the window and corresponds to an real-world time interval length of 145 msec. Correspondingly, we obtain for a choice of N = 31 a real-world time
interval length of 150 msec, and for N = 32 one of 155 msec.

6 EventDet

49

2013

BioMedSigProcAna

Decision Rule
adaptive thresholding
algorithm adapts to changes in the Ecg signal
by: computing running estimates of signal and noise
peaks
a peak is said to be detected whenever the final output changes direction within a specified interval
adjusting average heartbeat-rate estimates
R-R interval: R-wave to R-wave interval =
heartbeat
interval
works with two averages
1. average: over 8 most recent beats
2. average: over 8 most recent beats that fall into
certain limits
reason (idea): to be able to adapt to quickly changing
or irregular heartbeat rates
for details: see original literature

The original original literature is [PT85] and [HT86]; we


supply these papers as pdf-copies along with the laboratory
exercises. Alternatively, you might want to use the textbooks
[Tom93] or [Ran02].

6 EventDet

50

2013

BioMedSigProcAna

Sampling-Rate Conversion
note: the Pan-Tompkins algorithm is designed for Ecg
signals sampled with fs = 200 samples/sec
if we have an Ecg signal with a different sampling rate,
say fs = 1000 samples/sec, we need a pre-processing
pre-processing: sample-rate conversion
in fixed-point implementations: sample-rate conversion often performed with Cic filters

The acronym Cic stands for cascaded integrator-comb filters,


being a special form of multirate decimation and interpolation
filters. We have the original paper [Hog81], but you might also
want to consult [Don00], [MB07, Section 5.3], [Xil08], or the
corresponding items in the Matlab manuals.9
We note that although the Cic decimation-structures have
as first stages integratorssee our simple example on page 52
which has just one integratorthere is no problem with overflows, if the used data type is twos complement with natural
overflow computations, because then the computations are modulo 2b , and final overall results staying in the representable range
are correctly computed even if intermediate results have overflowed; see our discussion in [Goe13b].

9 In

the Matlab help window just search for Cic.

6 EventDet

51

2013

BioMedSigProcAna

Sampling-Rate Conversion: Cic-Filter Example


to do: realize down-sampling by a factor 5
needed: lowpass filter for limiting to
p = /5
as example use: 10-point moving-sum filter
 1 z 10

H(z) = 1 + z 1 + + z 9 =
1 z 1
with subsequent down-sampling
1 z 10
1 z 1
1
1 z 1

1 z 10

with Cic-filter structure


1
1 z 1

1 z 2

We here call a moving-average filter that comes without


averaging a moving-sum filter. The moving-average filter corresponding to the moving-sum filter introduced above is
H(z) =

6 EventDet


1 1 z 10
1
1 + z 1 + + z 9 =
,
10
10 1 z 1
52

2013

BioMedSigProcAna
that is, the moving-average filter has, as compared to the movingsum filter, an additional scaling factor 1/10the computation
of the average.
Reconsider the Cic-filter decimator structure in the graphics on page 52. We see that the first processing block is an
accumulatorwe may likewise term it an integrator if we prefer
continuous-time (Ct) system parlance. Obviously, that accumulator contributes a not strictly-stable pole at z = 1 to the
system, and the result might be register overflow in the integrator stage.10 However, such a register overflow will have no
consequence if we ensure that the following two conditions hold:
(i) The filter is implemented in twos complement arithmetic;11
(ii) The range of the used number system is equal to or exceeds
the maximum magnitude expected at the output of the complete
Cic filter.
Corresponding to the operation of decimation, there is the
complementary operation of interpolation: Here, an incoming
signal is first upsampled to a higher rate by inserting zero samples and subsequently lowpass filtered for interpolation. In the
interpolation-operation too, Cic-filter structures can be used,
but the sequence of comb sections and integrator sections is reversed: Corresponding to the example on page 52 we would have
the comb block (1 z 2 ), followed by an upsampler, followed
by the integrator. In this situation of the Cic-filter interpolator, the input signal to the overall filter is preconditioned by
the comb sectionthe comb section suppresses a potential Dc
termso that overflow will not occur in the integrator stages.

10 If the input signal to the integrator contains a non-zero Dc component,


the register will overflow sooner or later independently of how small that
Dc component might be.
11 The filter can likewise be implemented by any other number system that
has wrap-around between the most positive and most negative numbers
the number system must have modulo arithmetic.

6 EventDet

53

2013

BioMedSigProcAna
The summary of economical advantages of Cic-filters is,
1. Cic-filters need no multipliers;
2. consequently, Cic-filters need no storage for filter coefficients;
3. Cic-filters reduce internal signal-sample storage, as compared to equivalent implementations with uniform Fir filters, by integrating at the high sampling rate and comb
filtering at the low sampling rate;
4. Cic-filters have a very regular structure consisting of
two basic building blocks;
5. Cic-filters can be implemented with little external control
or complicated internal timing;
6. Cic-filters allow to use the same filter design for a wide
range of rate-change factors, with only the addition of a
scaling circuit and minimum changes to the filter timing.
Problems encountered with Cic-filters include: (i) Register
widths might become large if large sampling-rate factors are
to be implemented; (ii) The frequency response can only be
influenced by three integer parameters.
To understand this second statement, we must generalize
the example on page 52: Instead of using there the 10-point
moving-sum filter for lowpass filtering prior to downsampling
by a factor of 5, we could start with only a 5-point moving
sum filter. Correspondingly, the comb section would become
(1 z 1 ), and in general, the comb section is (1 z M ), where
M is named the differential delay.12 Next, instead of starting
just with the 10-point moving-sum filter as done on page 52, we
could use a cascade of N such moving sum filters, leading then
12 Of course we could also start with a 15-point, or a 20-point, or . . . ,
moving-sum filter, leading to M = 3, M = 4, . . . , but in practice the
differential delay is usually held to M = 1, 2.

6 EventDet

54

2013

BioMedSigProcAna
to a Cic-filter structure corresponding to that on page 52 which
would first have N integrator stages, next the downsampler by
the factor 5, and finally N comb stages each of the form (1
z 2 ). Finally, of course, the downsampling factor could be some
general positive integer R, and the transfer function of the Cicfilter referenced to the high sampling rate would become

H(z) =

1 z RM

N

(1 z 1 )

RM1
X
k=0

!N

From the above transfer-function formula we now understand


that the frequency response of the Cic-filter depends only on the
three integer parameters {R, M, N }, that is, on the samplingrate change factor R, the differential delay M , and the number
of cascaded stages N .

6 EventDet

55

2013

BioMedSigProcAna

References
[AT83]

M. L. Ahlstrom and W. J. Tompkins. Automated


high-speed analysis of holter tapes with microcomputers. IEEE Trans. Biomed. Eng., 30(10):651657,
October 1983.

[AT85]

M. L. Ahlstrom and W. J. Tompkins. Digital filters


for real-time Ecg signal processing using microprocessors. IEEE Trans. Biomed. Eng., 32(9):708713,
September 1985.

[BDD+ 77] R. A. Balda, G. Diller, E. Deardorff, J. Doue, and


P. Hsieh. The Hp Ecg analysis program. In J. H.
van Bemmel and J. L. Willems, editors, Trends in
Computer-Processed Electrocardiograms, pages 197
205. North Holland, Amsterdam, 1977.
[Don00]

Matthew P. Donadio.
Cic filter introduction.
On the Web: For Free Publication by Iowegian,
July 2000. m.p.donadio@ieee.org, http://www.dspguru.com/info/tutor/cic.htm.

[FJJ+ 90]

G. M. Friesen, T. C. Jannett, M. A. Jadallah, S. L.


Yates, S. R. Quint, and H. T. Nagel. A comparison of the noise sensitivity of nine Qrs detection algorithms. IEEE Trans. Biomed. Eng., 37(1):8597,
January 1990.

[Goe13a]

Josef Goette. Biomedical Signal Processing and


AnalysisFiltering for Removing Artifacts. Bern
University of Applied Sciences, Script at the Bfhti Biel/Bienne, HuCE-microLab, February 2013.

6 EventDet

56

2013

BioMedSigProcAna
[Goe13b]

Josef Goette. Biomedical Signal Processing and


AnalysisOn Fixed-Point Filter Realizations. Bern
University of Applied Sciences, Script at the Bfh-ti
Biel/Bienne, HuCE-microLab, February 2013.

[Goe13c]

Josef Goette. Biomedical Signal Processing and


AnalysisReview of Various Biomedical Signals.
Bern University of Applied Sciences, Script at the
Bfh-ti Biel/Bienne, HuCE-microLab, February
2013.

[Hog81]

Eugene B. Hogenauer. An economical class of digital


filters for decimation and interpolation. IEEE Trans.
Acoust., Speech, Signal Processing, 29(2):155162,
April 1981.

[HT86]

P. S. Hamilton and W. J. Tompkins. Quantitative investigation of Qrs detection rules using


the Mit/Bih arrhythmia database. IEEE Trans.
Biomed. Eng., 33(12):11571165, December 1986.

[Los08]

Ricardo A. Losada. Digital filters with Matlab.


Technical report, The MathWorks, Inc., May 2008.

[MB07]

Uwe Meyer-Baese. Digital Signal Processing with


Field Programmable Gate Arrays. Springer Verlag,
Berlin Heidelberg New York, 3rd edition, 2007.

[Mit98]

Sanjit K. Mitra. Digital Signal Processing: A Computer Based Approach. Mc Graw Hill, New York,
1998. Bfh-ti Biel/Bienne Library 621.391 MITRA.

[Mit06]

Sanjit K. Mitra. Digital Signal Processing: A Computer Based Approach. Mc Graw Hill, New York, 3rd
edition, 2006. Bfh-ti Biel/Bienne Library 621.391
MITRA.

6 EventDet

57

2013

BioMedSigProcAna
[MSY98]

James H. McClellan, Ronald W. Schafer, and


Mark A. Yoder. Dsp First: A Multimedia Approach.
Prentice-Hall Inc., 1998.

[Orf96]

Sophocles J. Orfanidis. Introduction to Signal Processing. Prentice-Hall Inc., Upper Saddle River, New
Jersey, 1996. Bfh-ti Biel/Bienne Library 621.391
ORFAN.

[PT85]

J. Pan and W. J. Tompkins. A real-time Qrs


detection algorithm. IEEE Trans. Biomed. Eng.,
32(3):230236, March 1985.

[Ran02]

Rangaraj M. Rangayyan. Biomedical Signal Analysis: A Case-Study Approach. IEEE Press, New York,
2002. Bfh-ti Biel/Bienne Library 57.08 RANGA.

[SL05]

Leif S
ornmo and Pablo Laguna. Bioelectrical Signal
Processing in Cardiac and Neurological Applications.
Elsevier Academic Press, Amsterdam, 2005. Bfh-ti
Biel/Bienne Library 616 SOERN.

[Tom93]

Willis J. Tompkins. Biomedical Digital Signal Processing. Prentice-Hall Inc., Englewood Cliffs, N.J.,
1993. Eth Bib: +521 458.

[Xil08]

Xilinx. Cic Compiler v1.1. On the Web, March


2008. http://www.xilinx.com.

6 EventDet

58

2013

Anda mungkin juga menyukai