Numerical Implementation of The Hilbert Transform - XianglingWang
Numerical Implementation of The Hilbert Transform - XianglingWang
HILBERT TRANSFORM
A Thesis
University of Saskatchewan
Saskatoon, Saskatchewan
by
Xiangling Wang
I agree that the Library, University of Saskatchewan, may make this thesis
freely available for inspection. I further agree that permission for copying of this
thesis for scholarly purpose may be granted to the professor or professors who
supervised the thesis work recorded herein or, in their absence, by the Head of the
Department or the Dean of the College in which the thesis work was done. It is
any other use of this thesis for financial gain without approval by the University of
Request for permission to copy or to make any other use of the material in this
57 Campus Drive
University of Saskatchewan
Saskatoon, Saskatchewan
i
ACKNOWLEDGEMENTS
I wish to express my gratitude to the following people who not only made this
Dr. Ronald J. Bolton: my supervisor, for his valuable guidance, criticisms and
All my friends in Saskatoon, Sha Li, Song Hu, Jing Yin, Ying Cui, Quan
Wan, Yajun Wang, Xin Xu and Yanan Xing: for making me feel welcome. They
ii
ABSTRACT
Many people have abnormal heartbeats from time to time. A Holter monitor is
a device used to record the electrical impulses of the heart when people do ordinary
activities. Holter monitoring systems that can record heart rate and rhythm when
analytic signal, was used in this thesis. Subsequently pattern recognition can be
used to analyse the ECG data and lossless compression techniques can be used to
The thesis discusses one part of the Holter Monitoring System, Input
processing.
Frequency-Domain approach, the Boche approach and the Remez filter approach
for calculating the Hilbert transform of an ECG wave are discussed in this thesis.
By comparing them from the running time and the ease of software and hardware
Using the Parks-McClellan algorithm, the Remez approach was present, and a
iii
Accurate determination of the QRS complex, in particular, accurate detection
of the R wave peak, is important in ECG analysis and is another task in this thesis.
program chip) Builder system development tool. The performance of the algorithm
was tested using the standard ECG waveform records from the MIT-BIH
iv
Table of Contents
v
3.5 Comparison.................................................................................................... 51
Chapter 4 Implementation ....................................................................................... 53
4.1 Nios Embedded Processor Overview ............................................................ 53
4.2 Digital Filter .................................................................................................. 59
4.3 Implementation.............................................................................................. 63
4.3.1 Filter Order ............................................................................................. 63
4.3.2 Filter Coefficients................................................................................... 69
4.3.3 Digital Filter ........................................................................................... 77
4.3.4 Detector for R Wave Peak...................................................................... 78
4.3.5 R Wave Peak Detection Test................................................................. 79
4.4 Nios Implementation .................................................................................... 84
Chapter 5 Results..................................................................................................... 91
5.1 Experimental Results..................................................................................... 91
5.2 Complete ECG Testing................................................................................ 104
Chapter 6 Summary and Conclusion..................................................................... 112
6.1 Summary…………………………………………………………………...112
6.2 Conclusion…………………………………………………………………115
References ............................................................................................................. 116
Appendix A ........................................................................................................... 119
The MIT-BIH Arrhythmia Database ..................................................................... 119
A.1 Introduction ................................................................................................ 119
A.2 File Structure .............................................................................................. 120
A.3 Notational and Other Conventions ............................................................. 121
A.4 File Format Specifications.......................................................................... 122
A.5 Annotation Specifications........................................................................... 124
Appendix B............................................................................................................ 128
B.1 The Parks-McClellan Algorithm ................................................................ 128
vi
List of Tables
Table 1.1 Comparison general Holter Monitor with new system in this thesis ........ 7
Table 3.1 The comparison of the four methods for computing Hilbert transform. . 51
Table 4.1 Four types of the linear phase FIR filter.................................................. 62
Table 4.2 Filter order comparison ........................................................................... 67
Table 4.3 XW_1 extreme points and values............................................................ 81
Table 4.4 XW_2 extreme points and values............................................................ 84
Table 4.5 XW_1 R wave points and their Hilbert transform points........................ 90
Table 4.6 XW_2 R wave points and their Hilbert transform points........................ 90
Table 5.1 mit212from100 extreme points and values ............................................. 94
Table 5.2 mit212_1from47200 extreme points and values ..................................... 95
Table 5.3 mit213_1from67000 extreme points and values ..................................... 98
Table 5.4 mit213_1from1450 extreme points and values ..................................... 100
Table 5.5 mit223_1from47700 extreme points and values ................................... 102
Table 5.6 mit223_1from7900 extreme points and values ..................................... 103
Table 5.7 R wave detection performance .............................................................. 110
vii
List of Figures
viii
Figure 4.2 Hardware/Software development flow for a Nios processor system [15]
................................................................................................................................. 56
Figure 4.3 Nios SDK Shell (bash)........................................................................... 57
Figure 4.4 Nios Development Board Components [17].......................................... 58
Figure 4.5 Filter. ...................................................................................................... 60
Figure 4.6 Digital filter transposed structure........................................................... 60
Figure 4.7 Illustration of four types of impulse response symmetry....................... 62
Figure 4.8 Input waveform: sin(2 * π * 0.02 * 500) .................................................. 64
Figure 4.9 Output waveform, M = 51 . .................................................................... 64
Figure 4.10 Output waveform, M = 71 . .................................................................. 65
Figure 4.11 Output waveform, M = 91 . .................................................................. 65
Figure 4.12 Output waveform, M = 101 . ................................................................. 66
Figure 4.13 Output waveform, M = 201 .................................................................. 66
Figure 4.14 Frequency response, M = 100 ............................................................. 68
Figure 4.15 Frequency response, M = 101 . ............................................................ 68
Figure 4.16 Frequency response of the ideal and Remez design filter.................... 70
Figure 4.17 Coefficients of the filter when M = 100 . ............................................ 71
Figure 4.18 Frequency response of Remez filter..................................................... 72
Figure 4.19 Initial parameter of remez.c ................................................................ 75
Figure 4.20 Coefficients from the C program. ........................................................ 76
Figure 4.21 Frequency response for a M = 100 Hilbert transform filter................ 77
Figure 4.22 Input wavefom: XW_1......................................................................... 80
Figure 4.23 Output waveform for XW_1. ............................................................... 81
Figure 4.24 Input waveform: XW_2. ...................................................................... 82
Figure 4.25 Output waveform for XW_2. ............................................................... 83
Figure 4.26 Nios SDK Shell Prompt. ...................................................................... 85
Figure 4.27 Nios-Build messages............................................................................ 86
Figure 4.28 Nios SDK shell prompt. ....................................................................... 87
Figure 4.29 Input ECG waveform: XW_1. ............................................................. 88
Figure 4.30 The Hilbert transform of XW_1........................................................... 88
Figure 4.31 Input ECG waveform: XW_2. ............................................................. 89
ix
Figure 4.32 The Hilbert transform of XW_2........................................................... 89
Figure 5.1 Input waveforms: mit212from100.txt. ................................................... 93
Figure 5.2 Output waveform: outMIT212from100.txt............................................ 93
Figure 5.3 Input waveform: mit212_1from47200.txt.............................................. 94
Figure 5.4 Output waveform: outMIT212from47200.txt........................................ 95
Figure 5.5 Input waveform: mit213_1from67000.txt.............................................. 97
Figure 5.6 Output waveform: outMIT213_1from67000.txt.................................... 98
Figure 5.7 Input waveform: mit213_1from1450.txt................................................ 99
Figure 5.8 Output waveform: outMIT213_1from1450.txt...................................... 99
Figure 5.9 Input waveform: mit223_1from47700.txt............................................ 101
Figure 5.10 Output waveform: outMIT223_1_from47700.txt.............................. 101
Figure 5.11 Input waveform: mit223_1from7900.txt............................................ 102
Figure 5.12 Output waveform: outMIT223_1_from7900.txt................................ 103
Figure 5.13 The portion of results of MIT212. ..................................................... 106
Figure 5.14 The portion of results of MIT213. ..................................................... 107
Figure 5.15 The portion of results of MIT213. ..................................................... 108
Figure 5.16 The portion of results of MIT223. ..................................................... 109
Figure 5.17 The portion of results of MIT223. ..................................................... 110
Figure B.1 Flowchart of Parks-McClellan algorithm………………………….....134
x
List of Abbreviations
ECG electrocardiogram
FT Fourier transform
HW hardware
HT Hilbert transform
PCG polarcardiogram
xi
SW software
VCG vectorcardiogram
xii
Chapter 1 Introduction
system is one of them. The most common type of ECG monitoring is called Holter
monitoring. Holt monitoring is a portable recording tool and can help doctors make
a precise diagnosis.
Many people have irregular heartbeats from time to time. Some heart
problems occur during certain activities, such as eating, exercise or even sleeping.
Sometimes the irregular heartbeats don’t influence life style and are usually
harmless in normal hearts. But it is also possible that these irregular heartbeats with
pre-existing illness can cause heart attacks that lead to death. A device that can
record the activities of the heart is very useful in preventing heart attacks. The
situation.
capture ECG data of the heart’s electrical activities over a period of time. The
1
patient can carry it in a pocket or in a small pouch. The monitor is battery operated.
1.1.1 Electrocadiogram
recorded from electrodes that are placed on different parts of patient’s body.
rhythm, waves and complexes are the P wave, QRS complex, ST Segment, T wave
2
Different parts of the ECG waves are caused differently. Detailed information
(atria). It is usually positive, low amplitude and smooth. In normal situation, the
high amplitude in normal situations. The shape of the QRS complex will be
changed if the electrodes are placed on different parts of the body. It also changes
when abnormal heartbeats occur. A QRS complex can have positive (upwards) or
• The ST segment represents the time following the QRS it takes for
low amplitude signal that occurs during the time of the high amplitude QRS and
3
• The T wave is caused by the repolarization of the ventricles. Usually it is
• The reason that causes the U wave is not that clear, “afterdepolarizations” in
• The PR interval is the time interval from the beginning of the P wave to the
beginning of the QRS complex. In normal situation the PR interval should be 0.12-
repolarization. It is between the onset of the QRS complex and the end of the T
• The PP interval is the duration of atrial cycle. It indicates the atrial rate.
The normal adult heart beats regularly between 60 to 100 beats per minute.
Bradycardia occurs once the heart rate is slower than 60 beats per minute. The
waveform is similar to the normal ECG wave, but the RR interval is longer. A rate
of above 100 beats per minute is called tachycardia, in this case the RR interval is
shorter and the waveform is also similar to the regular sinus rhythm. Each P wave
4
Figure 1.3. The wave of the bradycardia is shown in Figure 1.4. Figure 1.5
illustrates the tachycardia. Figure 1.7 shows some abnormal ECG waves.
5
Figure 1.7 Three abnormal ECG waveforms [3].
produce, how often they occur, how long they last, and whether they occur at the
activity of heart during usual daily activities. A recording is much more likely to
During the late 1960s, computerized ECG's came into use in many of the
6
time is around 24 to 48 hours. That means even when the heartbeat is normal, the
The system discussed in this thesis automatically records the ECG wave when
the user is not feeling good or the heartbeats are not regular. The recording
algorithm is not continuous any more. It also can record the heartbeats manually;
the wearers can record the heartbeat if wanted when the heart rhythms are ordinary.
The differences between the general Holter monitor and the system developed in
Table 1.1 Comparison general Holter Monitor with new system in this thesis
• Record the ECG wave automatically when wearer does not feel good.
7
1.1.3 Structure of the Holter Monitoring System
User
Interface
Pattern Recognition
Normal/Abnormal Abnormal
Nios
From Figure 1.8 it can be seen that the system includes four sub-systems: the
The input data is the raw ECG data. These data record the activities of the
signal that then conducts through specialized pathways to all parts of the heart.
8
These electrical signals also get transmitted through the chest to the skin where they
of the input ECG data on the Nios embedded processor. Then the zero crossing
points corresponding to the input R wave peaks are found and the results
Obtain the results of the input processing, and by using properties of the
Hilbert transform, create the analytic signal and use it to assist in doing pattern
1.1.3.3 Compression
Compress all the abnormal data obtained from the “Input processing” sub-
system.
1.1.3.4 Storage
Save all the compressed data in compact flash card. This card is removable
and can be inserted into the computer to read the information recorded in this card.
9
Holter monitoring gives doctors the record of patient’s heart rate and rhythm
over a period of time. The Holter monitor can record heart rate and rhythm when
the patient feels chest pain or symptoms of an irregular heartbeat (an arrhythmia).
The doctor can then look at the time when the patient noticed their symptoms.
Reading this printout will give the doctor an idea about the nature of the heart
any abnormal heartbeats or rhythms that may be causing the patient’s symptoms.
It’s necessary to develop an efficient (i.e., long time durations and automatic
pattern recognition analysis) system to record these irregular heartbeats so that the
doctor can know what had happened when patient had those symptoms. This
system is a very good tool to prevent people from fatal heart problems.
Briefly, the reasons for using a Holter monitor may include: to detect
The work of this thesis is to implement the input processing sub-system. That
1.2 Objectives
The objectives of this thesis are to address the aforementioned problems and
10
z To compare these algorithms with each other from running time and
hardware/software implementation.
z To develop a detector to find all of the zero crossing points that correspond to
the R wave peaks in the output wave, i.e., the Hilbert transform sequence of an
ECG wave.
Chapter 2 gives the background materials of the Holter monitor and the
approach, the Frequency-Domain approach, the Boche approach and the Remez
filter approach. In this chapter, the examples and the results are given for using
with each other in running time and the ease of software and hardware
Chapter 4 describes how to design and implement the Remez filter approach
that was mentioned in Chapter 3, and also describes how to design and implement a
filter with an optimal fit. The information about Alter’s Nios SOPC Builder system
11
Chapter 5 concentrates on analyzing the results and compares them to the
given.
12
Chapter 2 Background
the properties and the applications of the Hilbert transform are also contained in
this chapter.
heart. An ECG provides information on the condition and performance of the heart.
It is one of the simplest and fastest procedures used to evaluate the heart. Because
an arrhythmia can occur irregularly, it will be difficult to record when the patient is
pound backpack that can record the ECG of the wearer. This portable monitoring
hours. Usually the patient will undergo Holter monitoring as an outpatient, meaning
13
that the monitor will be placed on the body of the patient by a technician in a
cardiologist’s office. Then the patient will go home and do normal activities. With
now very compact and combined with digital recording and used to record ECGs.
The Holter monitor can be easily carried without interfering with the patient’s
activities. At the end of the recording period, the patient will go back to the doctor’s
office to remove the Holter monitor. The data saved in the Holter monitor will be
provide the information about the patient’s heart rhythm, the frequency of the beats
and the irregularities. This portable monitor can be an effective and powerful
diagnostic tool that can directly determine how the physician treats the patient’s
condition.
As Figure 2.1 shows, the Holter monitor is a small-size recording device. The
monitor has wires called leads. The leads attach to metal disks called electrodes,
which the user wears on his chest. These electrodes are very sensitive, and they can
pick up the electrical impulses of the heart. The impulses are recorded by the Holter
14
Figure 2.1 A man with the Holter monitor [5].
The use of the effective home care monitor of the heart patients will decrease the
incidence of the readmissions and lower the costs of the hearth care.
recording, pacemaker pulse detection and analysis, software for analysis of digital
ECG recordings that are downloaded and stored on a computer, and capability of
The system discussed in this thesis is to record the rhythm of the heartbeat
automatically when the symptoms occur. The monitor does not continuously record
15
but records the heart rate and rhythm when the patients feel symptoms of an
irregular heartbeat or when abnormal heart beats or rhythms occur. That means the
device automatically capture the arrhythmias when they occur. It also can be
activated manually by the patients when chest pain is felt during a symptomatic
event. So it can record for a long time. Up to now, the Holter monitor in the market
can record over 24-48 hours; the longest one is not much more than 72 hours. The
system discussed in this thesis will much improve the recording time. The
In the beginning of the 20th century, the German scientist David Hilbert
(1862-1943) proved that the Hilbert transform of the function cos(ωt ) is sin(ωt ) .
π
This is the one of properties of the Hilbert transform, i.e., basic ± phase-shift.
2
16
2.2.1 Definition
1 ∞ x(τ )
π∫
xˆ (t ) = H [ x(t )] = dτ (2.3)
−∞ t −τ
It can be seen from the Equation (2.3) that the independent variable is not
function.
b −ε
lim ⎡ ∫ x(t )dt ⎤ ,
c
x(t )dt + ∫ (2.4)
ε →0+ ⎢
⎣a b +ε ⎥⎦
where b is a point at which the behaviour of the function x(t ) is such that
b
∫ a
x(t )dt = ±∞ for any a < b
c
and ∫
b
x(t )dt = m ∞ for any c > b . [7]
17
1 ∞ x(t − τ )
π∫
H [ x(t )] = dτ (2.5)
−∞ τ
1 ∞ x(t + τ )
π∫
H [ x(t )] = dτ . (2.6)
−∞ τ
From the Equation (2.3), (2.4) and (2.5), it can be seen that Hilbert transform
is a convolution:
1
H [ x(t )] = xˆ (t ) = * x(t ) (2.7)
πt
18
According to the convolution theorem (the Fourier transform of a convolution
of two functions is the product of their Fourier Transforms.), it can be seen that the
1 ⎧1⎫
F {xˆ (t )} = F ⎨ ⎬ F{x(t )} (2.8)
π ⎩t ⎭
Since
⎧1⎫ ∞ 1
F ⎨ ⎬ = ∫ e − j 2π * fx dx = − jπ sgn( f ) (2.9)
⎩ t ⎭ −∞ x
where
1
Therefore, the Fourier transform of is − j sgn( f ) , which is equal to − j
πt
for positive frequency and + j for negative frequency. Hence the Hilbert transform
π
are left unchanged, but their phases are altered by , positively or negatively
2
19
The time domain result can be obtained performing an inverse Fourier
transform.
defined as
1 ∞ f (τ )
π∫
H [ f (t )] = dτ .
−∞ t − τ
1 f (τ )
π∫
H [ f (t )] = lim dτ . (2.11)
ε →0 x − t >ε t −τ
H [ f (t )] = H [c1 f1 (t ) + c 2 f 2 (t )]
1 c1 f 1 (τ ) + c 2 f 2 (τ )
π∫
= lim dτ
ε →0 x − t >ε t −τ
1 f1 (τ ) 1 f 2 (τ )
π∫ ∫
= c1 lim dτ + c 2 lim dτ
ε →0 x − t >ε t −τ ε →0 π x − t >ε t −τ
= c1 H [ f1 (t )] + c 2 H [ f 2 (t )]. (2.12)
20
Equation (2.12) shows the linearity of the Hilbert transform.
(2) The Hilbert transform of a Hilbert transform is the negative of the original
function.
ˆ
[
H [ fˆ (t )] = fˆ (t ) = F −1 − j sgn(ω ) F [ fˆ (t )] ]
= F −1 [− j sgn(ω )[− j sgn(ω ) F ( jω )]]
= F −1 [− F ( jω )]
= − f (t ) (2.13)
1 ∞ f (τ ) 1 ∞ f (t − s )
H [ f (t )] =
π ∫− ∞ t −τ
dτ =
π ∫
−∞ s
ds
f (t − s ) ⎫
{H [ f (t )]} = d ⎧⎨ 1
d ∞
So
dt dt ⎩π ∫−∞ s
ds ⎬
⎭
1 ∞ f ′(t − s )
π∫
= ds
−∞ s
1 ∞ f ′(τ )
π∫
= dτ
−∞ t −τ
= H [ f ′(t )] . (2.14)
∞ ∞ ⎡ 1 ∞ ⎤
∫ f (t ) fˆ (t )dt = ∫ f (t ) ⎢ ∫ − j sgn(ω ) F ( jω )e jωt dω ⎥dt
−∞ −∞
⎣ 2π −∞
⎦
21
1
− j sgn(ω ) F ( jω ) ⎡ ∫ f (t )e jωt dt ⎤ dω
∞ ∞
=
2π ∫
−∞ ⎢⎣ −∞ ⎥⎦
−j ∞ 2
2π ∫−∞
= sgn(ω ) F ( j ω ) dω
=0. (2.15)
2
Since integrand sgn(ω ) F ( jω ) is an odd function which is integrated over
Equation (2.15) proves that a real function and its Hilbert transform are
orthogonal.
(5) The energy in a real function and its Hilbert transform are equal.
The signal and its Hilbert transform have identical energy because a phase
shift does not change the energy of the signal only amplitude changes can do that.
∞ 2
1 ∞ 2
Ef = ∫ f (t ) dt = ∫ F (ω ) dω . (2.16)
−∞ 2π −∞
∞ 2
E fˆ = ∫ fˆ (t ) dt
−∞
1 ∞ 2
=
2π ∫ −∞
− j sgn(ω ) F (ω ) dω
1 ∞ 2
= ∫ F (ω ) dω . (2.17)
2π −∞
22
2.4 Hilbert Transform Applications
The Hilbert transform is a very useful tool for the analysis of problems in
various research areas. The Hilbert transform has a variety of applications, such as
in the field of radio and signal processing, communication and power area.
between the real part and imaginary part of a complex signal. The relationships are
special signals called analytic signals which are especially important in simulation.
where
The real and imaginary parts can be expressed in polar coordinates as:
z (t ) = A(t )e jθ (t ) . (2.19)
where
23
A(t ) is the “envelope” or amplitude of the analytic signal given as
A(t ) = f 2 (t ) + fˆ 2 (t ) . (2.20)
⎛ fˆ (t ) ⎞
θ (t ) = arctan⎜⎜ ⎟.
⎟ (2.21)
⎝ f (t ) ⎠
A(t ) and f (t ) have common tangents and the same values at the points
where fˆ (t ) = 0 , i.e., the envelop determined using Equation (2.20) will have the
to compute the Hilbert transform, fˆ (t ) . This allows the calculation of the envelope
functions are then plotted in polar form (polar plot), the result is a waveform
Thus the resulting magnitude versus angle plot is used for further analysis.
The temporal dependence of the ECG data is removed. In effect the data has been
shifted from a magnitude versus time system into a magnitude versus angle system.
At the same time that because using a sampled-data waveform sampled at a fixed
frequency (usually 360 Hz), the time information is still implicitly available to the
24
user. A major disadvantage of the time normalisation is that it implicitly assumes
linear distortion of the ECG waveform over the length of the normalised segment.
different displays are presented to the user. The main use of this display format is to
monitor the data being placed in the pattern recognition so that different waveform
segments (P,Q,R,S,T) and different time locations (before QRS ,after QRS) could
25
Chapter 3 Computation of the Hilbert
Transform
In this chapter, four methods of implementing the Hilbert transform are given.
1 +∞y (τ )
π∫
yˆ (t ) = dτ . (3.1)
−∞ t − τ
Assume that the signal y (t ) has been sampled every Δt second to give the
the sampling interval [12], for time from Δt to NΔt , the Hilbert transform at time
Δt is
1 NΔt y (τ )
π∫
yˆ k = yˆ (kΔt ) = dτ
Δt kΔt − τ
1 2 Δt y (τ ) ( k −1) Δt y (τ ) kΔt y (τ )
= (∫ dτ + K + ∫ dτ + ∫ dτ
π Δt kΔt − τ ( k − 2 ) Δt kΔt − τ ( k −1) Δt kΔt − τ
26
( k +1) Δt y (τ ) ( k + 2 ) Δt y (τ ) NΔt y (τ )
+∫ +∫ dτ + K + ∫ dτ )
kΔt kΔt − τ ( k +1) Δt kΔt − τ ( N −1) Δt kΔt − τ
k −2
1 N
= (∑ I i( f ) + I k( c ) + ∑I (r )
), (3.2)
π
i
i =1 i =k +2
where
( i +1) Δt y (τ )
I i( f ) ≡ ∫ dτ
iΔt kΔt − τ
kΔt y (τ ) ( k +1) Δt y (τ )
I k( c ) ≡ ∫ dτ + ∫ dτ
( k −1) Δt kΔt − τ kΔt kΔt − τ
iΔt y (τ )
I i( r ) ≡ ∫ dτ .
( i −1) Δt kΔt − τ
So
( i +1) Δt y (τ )
I i( f ) ≡ ∫ dτ
iΔt kΔt − τ
Δt y i + ( y i +1 − y i ) x / Δt
=∫ dx ( x ≡ τ − iΔt )
0 kΔt − iΔt − x
Δt y i + ( y i +1 − y i )τ / Δt
=∫ dτ (3.3)
0 (k − i )Δt − τ
and
iΔt y (τ )
I i( r ) ≡ ∫ dτ
( i −1) Δt kΔt − τ
27
iΔt y i + ( y i −1 − y i )(τ − iΔt ) /(− Δt )
=∫ dτ
( i −1) Δt kΔt − τ
0 y i + ( y i −1 − y i ) x / Δt
= −∫ dx ( x ≡ −(τ − iΔt ))
Δt kΔt − iΔt + x
Δt y i + ( yi −1 − y i )τ / Δt
= −∫ dτ (3.4)
0 (i − k )Δt − τ
and
kΔt y (τ ) ( k +1) Δt y (τ )
I k( c ) ≡ ∫ dτ + ∫ dτ
( k −1) Δt kΔt − τ kΔt kΔt − τ
( x ≡ τ − kΔt , w ≡ τ − kΔt )
0 y k + ( y k − y k −1 )τ / Δt Δt y + ( y
k +1 − y k )τ / Δt
=∫ dτ + ∫ k dτ . (3.5)
− Δt −τ 0 −τ
Δt y i + ( y i +1 − y i )τ / Δt
I i( f ) = ∫ dτ
0 (k − i )Δt − τ
Δt Δt yi + ( y i +1 − y i )(k − i )
= − ∫ ( y i +1 − y i ) / Δtdτ − ∫ dτ
0 0 τ − (k − i)Δt
Δt
= −( y i +1 − y i ) − ( y i + ( y i +1 − y i )(k − i )) ln τ − (k − i )Δt 0
k −i k −i
= y i ln + ( y i +1 − y i )(−1 + (k − i ) ln ) (3.6)
k − i −1 k − i −1
and
28
Δt y i + ( y i −1 − y i )τ / Δt
I i( r ) = − ∫ dτ
0 (i − k )Δt − τ
Δt Δt y i + ( y i −1 − yi )(i − k )
= ∫ ( y i −1 − y i ) / Δtdτ + ∫ dτ
0 0 τ − (i − k )Δt
Δt
= ( y i −1 − y i ) + ( y i + ( y i −1 − y i )(i − k )) ln τ − (i − k )Δt 0
i − k −1 i − k −1
= y i ln + ( y i −1 − y i )(1 + (i − k ) ln ) (3.7)
i−k i−k
and
0 y k + ( y k − y k −1 )τ / Δt Δt y + ( y
k +1 − y k )τ / Δt
I k( c ) = ∫ dτ + ∫ k dτ
− Δt −τ 0 −τ
y k + ( y k − y k −1 )(− x) / Δt k +1 − y k )τ / Δt
0 Δt y + ( y
= −∫ dx − ∫ k dτ
Δt x 0 τ
Δt y k + ( y k − y k −1 )(−τ ) / Δt Δt y k + ( y k +1 − y k )τ / Δt
=∫ dτ − ∫ dτ
0 τ 0 τ
Δt
= ∫ ( y k −1 − y k +1 ) / Δtdτ .
0
= y k −1 − y k +1 . (3.8)
k −2
1 N
yˆ k = (∑ I (f)
+I (c)
+ ∑I (r )
)
π
i k i
i =1 i =k + 2
1 k −2
k −i k −i
= (∑ ( y i ln + ( y i +1 − y i )(−1 + (k − i ) ln ))
π i −1 k − i −1 k − i −1
+ ( y k −1 − y k +1 )
29
N
i − k −1 i − k −1
+ ∑ (y
i =k +2
i ln
i−k
+ ( y i −1 − y i )(1 + (i − k ) ln
i−k
))) . (3.9)
(f) k −i k −i
Ii = y i ln + ( y i +1 − y i )(−1 + (k − i ) ln )
k − i −1 k − i −1
(c)
Ik = y k −1 − y k +1
(r ) i−k i−k
Ii = y i ln + ( y i −1 − y i )(−1 + (i − k ) ln ).
i − k −1 i − k −1
(f) (c)
Noticed that I i and Equation (3.6), I k and Equation (3.8) are the exactly
(r )
same. But I i is different from Equation (3.7). The equation does influence the
(Equation (3.10) or the one given on the reference [12]) is correct, This can be
1 ∞ sin(τ )
π∫
H [sin( x)] = dτ . (3.10)
−∞ x − τ
Letting s = x − τ , get
1 ∞ sin( x − s )
π∫
H (sin x) = (−ds )
−∞ s
30
1⎡ ∞ cos s ∞ sin s ⎤
=− ⎢
π⎣
sin x ∫− ∞ s
ds − cos x ∫− ∞ s
ds ⎥
⎦
1 ∞ cos s 1 sin s
∞
π∫ ∫
It is well known that ds = 0 and ds = 1 .
−∞ s π −∞ s
1 ∞ sin s
π∫
So H (sin x) = cos x ds
−∞ s
= cos x . (3.11)
In order to test that the Equation (3.9) is right, here an example is given.
From the Equation (3.11), it can be seen that the Hilbert transform of
Writing a MATLAB program for this algorithm, Figure 3.1 and Figure 3.2
were obtained. Figure 3.1 shows the input waveform and Figure 3.2 (a) illustrates
the Hilbert transform waveform of this input wave using Equation (3.9). Figure 3.2
(b) shows the results using the equation from reference [12].
31
Figure 3.1 Input waveform: sin(2π * 0.02 * 500) .
Figure 3.2 (a) Output waveform: The Hilbert transform of sin(2π * 0.02 * 500) .
32
Figure 3.2 (b) Output waveform using the equation from [12].
As shown in Figure 3.2 (a), the output waveform is the Hilbert transform of
the input sine wave. It is a cosine wave. It also illustrates that the Hilbert transform
of a real function does not change the amplitude of the signal but only changes its
π
phase by rad/s.
2
The waveform shown in Figure 3.2 (b) is not a cosine wave. From the
(r )
waveform it also can be seen that I i from [12] is not correct and Equation (3. 9)
is correct.
system is an ECG wave. Figure 3.3 is the wave obtained from the MIT-BIH
33
(Massachusetts Institute of Technology-Beth Israel Hospital) arrhythmia database
Equation (3.9), the Hilbert transform of this ECG wave can be computed.
explanation about the ECG waves in Chapter 1, from the value of the P wave, the
seen that Figure 3.3 is a normal ECG wave. Because each R wave stands for a beat,
34
Figure 3.4 The Hilbert transform of the ECG wave.
Figure 3.4 shows the results of the Hilbert transform of this ECG wave. The
Hilbert transform waveform of the ECG wave should oscillate from negative to
positive or from positive to negative around the X-axis. The points corresponding
to peak values of R wave should be zero in the output waveform. But from Figure
3.4, it can be seen that the output waveform is distorted. It’s not the correct
waveform, so this method of computing the Hilbert transform may not be suitable
35
3.2 Frequency-Domain Approach
very useful. The second method to compute the Hilbert transform of a function is
Frequency-Domain approach.
) 1 ∞ y (τ )
π∫
y (t ) = dτ .
−∞ t −τ
Because the usual time domain definition based on the Cauchy principal value
of an integral is usually not easy to calculate, the Hilbert transform in the frequency
)
domain is defined. Suppose Y ( f ) and Y ( f ) are the Fourier transform of y (t ) and
)
yˆ (t ) . Y ( f ) and Y ( f ) are defined as
∞
Y ( f ) = ∫ y (t )e − j 2πft dt
−∞
)
Y ( f ) = − j sgn( f )Y ( f ) . (3.12)
) ) ⎡1⎤
Y ( jω ) = FT [ y (t )] = FT ⎢ ⎥Y ( jω ) = − j sgn(ω )Y ( jω ) [5], (3.13)
⎣ πt ⎦
where
This equation indicates that the Hilbert transform can be interpreted in the
frequency domain.
36
)
So given a sampled signal y k , the sequence y k can then be computed using
where
This formula can be used to calculate the Hilbert transform, by first taking the
) π
Fourier transform, thus obtaining y k . Thus the Hilbert transform is a − phase
2
)
shifter when viewed as a linear system whose input is y k and output is y k .
sin(2π * 0.02 * 500) , used previously, and the output should be the Hilbert
transform of the input, i.e., a cosine wave. Figure 3.5 shows the input waveform
sin(2π * 0.02 * 500) and Figure 3.6 shows the output results using Frequency-
37
Figure 3.5 Input wave: sin(2π * 0.02 * 500) .
38
Figure 3.7 shows the same section of ECG wave taken from the MIT-BIH
approach to obtain the Hilbert transform, the output waveform is shown in Figure
3.8.
39
Figure 3.8 Output: the Hilbert transform of the ECG wave.
The Hilbert transform waveform shown in Figure 3.8 is good. The wave
oscillates around the X-axis. The zero crossing points corresponding to the R peak
From the examples given above, the figures show that the Hilbert transform
of the sine wave is cosine wave. The output wave oscillates around zero as it should
when the input wave is the ECG wave. Even though this algorithm works, it’s also
not suitable for the system developed in this thesis. The reason will be given later.
40
3.3 Boche Approach
n
sin π (t − t k )
f n (t ) = ∑ bk ,n (3.15)
k =1 π (t − t k )
n
sin π (t i − t k )
f n (t i ) = ∑ bk ,n . (3.16)
k =1 π (t i − t k )
sin π (t i − t k )
where aik = t i ≠ t k for i ≠ k .
π (t i − t k )
Using the iteration method to solve the linear equations, the coefficients bk ,n
were obtained.
sin(π (t − t k ))
∞
∫−∞ π (t − t k )
dt = 1
41
and
cos(π (t − t k ))
∞
∫−∞ π (t − t k )
dt = 0 .
sin(π (t − t k ))
Hilbert transform fˆ (t ) of f (t ) = is derived as follows:
π (t − t k )
1 ∞ sin(π (t − t k )) 1
fˆ (t ) =
π∫
dt
−∞ π (t − t k ) λ − t
1 ∞ sin(π (t − t k )) 1 1
π∫
= ( + )dt
−∞ π (λ − t k ) λ − t t − t k
1 ∞ sin(π (t − t )) sin(π (t − λ + λ − t k ))
= ∫ ( − )dt
k
π (λ − t k ) −∞ π (t − t k ) π (t − λ )
π (λ − t k ) − ∞ π (t − t k ) π (t − λ )
1
= (1 − cos(π (λ − t k )))
π (λ − t k )
1 − cos(π (λ − t k ))
= . (3.18)
π (λ − t k )
n
sin π (t − t k )
f n (t ) = ∑ bk ,n
k =1 π (t − t k )
is
n
1 − cos(π (t − t k ))
H { f n (t )} = ∑ bk ,n , (3.19)
k =1 π (t − t k )
42
Here an example is given to demonstrate the algorithm for the sampled signal
0.25, thus yielding 81 sampling points. Based on the Equation (3. 19), i.e.,
1 − cos(π (λ − t k ))
fˆ (λ ) =
π (λ − t k )
and the linear property of the Hilbert transform that discussed in Chapter 2, the
Running a MATLAB program, the results are shown in Figure 3.9 and Figure
3.10. Figure 3.9 (a) shows the waveform of original function f (t ) , Figure3.9 (b) is
using f 26 (t ) minus f (t ) , and the result is shown in Figure 3.9 (c). The error
function is smaller than 0.0001 shown in Figure 3.9 (c). The sample sequence t i is
43
Figure 3.9 (a) f (t ) (b) f 26 (c) f 26 (t ) − f (t ) (d) t i .
Figure 3.10 (a) shows the Hilbert transform fˆ (t ) of the original function f (t ) ,
and the 26th approximation fˆ26 (t ) is shown in Figure 3.10 (b), and then the error
44
Figure 3.10 (a) fˆ (t ) (b) fˆ26 (t ) (c) fˆ26 (t ) − fˆ (t )
Boche algorithm permits reconstruct the bandlimited function from samples and
recovery of the Hilbert transform of this function. Compared with other known
solutions for computing Hilbert transform of a function, this algorithm does not
Here the algorithm is just given as a reference. In this thesis, the difficulty of
computing the solution to a variable set of linear equations is not easier than
calculating an integral. So this method is not suitable for the Holter monitoring
45
3.4 Remez Approach
The Remez Exchange FIR filter design approach (also called the Parks-
The well known Parks-McClellan algorithm uses this approach and Chebyshev
approximation theory to generate filters with an optimal fit between the desired
frequency responses and actual frequency responses. Filters designed in this way
McClellan algorithm [see Appendix B], the Remez approach designs a linear-phase
FIR filter.
The syntax of the remez function can be written the following way:
b = remez(n, f , a)
where
frequencies are specified in the range between 0 and 1, where 1 corresponds to the
specified in f . f and a are the same length. The length is an even number.
46
The output coefficients in b satisfied the symmetry relation
b = remez(n, f , a, w, ' ftype' ) is used when the special filter type is needed.
where
' ftype' represents the filter type parameter. It includes three types:
Multiband, Differentiator and Hilbert transform. The one used in this thesis is
'hilbert', that is the Hilbert transformer, for linear-phase filters with odd symmetry.
The Hilbert transformer has the desired amplitude of 1 across the entire band.
designs an approximate FIR Hilbert transformer of length 100. The frequencies are
specified from 0.05 to 0.95 and their corresponding amplitudes are 1. The
47
Figure 3.11 The input wave: y = sin(2π * 0.02 * 500) .
48
As before, the input signal is the same sine wave y = sin(2π * 0.02 * 500) ,
used previously. The remez function discussed above was used to generate a
Hilbert transformer and obtain the Hilbert transform of the input sine signal. The
y = sin(2π * 0.02 * 500) . Because the order of the filter used here is M = 100 , the
filter phase delay should be 100 / 2 = 50 . From the output waveform, it can be seen
clearly that the filter has a phase delay for N from 0 to 50. The output results
Another example is given here. The input wave is still the normal ECG wave
from the MIT-BITH Arrhythmia database MIT213 used previously (see Figure
3.3).
49
Figure 3.13 An ECG wave.
50
Figure 3.14 shows the output, i.e., the Hilbert transform of the input ECG
signal. For the same reason, the filter phase delay, the output wave lags by 50
samples.
3.5 Comparison
Four methods for computing Hilbert transform are discussed above. From this
section, the comparison of these four methods is given. Table 3.1 shows the
different running time and the easy level of hardware (HW) and software (SW)
implementation. All of programs are MATLAB programs and timing was done
Table 3.1 The comparison of the four methods for computing Hilbert transform.
For Time-Domain approach, even though the equations for computing the
Hilbert transform have been derived and it is not needed to calculate the integral
Nios system that will be used in this thesis because there is no hardware “ ln ”
51
function in the Nios processor. The running time was measured for sine wave and
ECG wave individually. Note that the sample number is 500 for sine wave and 800
for ECG wave. The results are shown in the Table 3.1. Using this method, the
extent.
FFT and IFFT for this method. This is not that easy to implement on the hardware.
The Boche approach supplied a simple way to calculate the Hilbert transform
of the bandlimited function. Even though it does not need to calculate the integral, a
set of linear equations has to be solved. The size of the equations is variable. It’s
not that easy to implement in the Nios processor used in this thesis.
Compared with the first three methods discussed above, the Remez filter
Its running time is shorter and can be implemented on both hardware and software.
RAM: 512MB.
52
Chapter 4 Implementation
applied to the input data have been discussed. After comparing them in terms of
running time and the complexities of the software and hardware implementation,
the Remez approach was selected to be the best method for the ECG Holter
Monitoring System. The problem now, is how to implement the Hilbert transform
algorithm to build the Holter monitoring system on the Nios system. In the
embedded processor that was designed to be a very flexible and powerful processor
solution [14]. The Nios embedded processor has become a commonly used
embedded processor because of its ease-of-use and flexibility. The Nios embedded
53
The Quartus II software, the SOPC (System on a Programmable Chip)
Builder system development tool, is used to build and evaluate custom processor-
based systems. Designers can use SOPC Builder to integrate one or more
configurable Nios CPUs with any number of standard peripherals, gluing the
system together [14]. Using SOPC Builder, a user can combine the Nios
processor with user logic and program it into a FPGA (Field Programmable Gate
Array) easily.
C/C++
VHDL/Verilog
System
Development
Component
Develop Boards & Kits
Design
Nios Development Kit,
CPU Stratix Edition
SOPC Builder
Avalon Nios Development Kit,
Quartus@ II Switch Fabric
Software Cyclone Edition
Peripherals Nios Development Kit
Embedded Software
Development Tools Stratix Professional
On-Chip Edition
Debugging
Third-Party Tools
Third-Party
Boards&Kits
54
In this thesis, the development tool is SOPC Builder, using a Nios
There are a number of necessary steps to create a Nios system on the Nios
development board. The procedure is shown in Figure 4.2. The flow includes both
the hardware and software design tasks required to create a working system. The
right side illustrates the software development flow and the left side illustrates the
Based on the system requirements, the hardware design begins with the SOPC
builder system integration software. At this point, the designer can begin writing
After the hardware designer defines the customer Nios processor hardware
development kit (SDK) that forms the foundation for the software development
flow [16]. With the SDK, the designer can begin writing software that interacts at
The Nios SDK Shell provides an UNIX bash shell environment board on a PC
platform. It is a very useful utility. Figure 4.3 shows the Nios SDK shell (bash
environment).
55
Step1: Predesign Activity
z Analyze System Requirements (Performance &Throughout)
z Defne Nios Processor Subsystem (CPU, Peripherals, Memory Structure, etc.)
Software Development
Hardware Development
Software
Standard System Step2: Libraries
Components Define Nios Processor
Begin C/C++ Development
System Module with
SOPC Builder Custom SDK
Step3:
Develop Drivers& Routines
For Custom Hardware OS Kernel
User-Defined Assign Device, Layout
Components Pins &Compile
Hardware with the
Quartus II Softwar
Step4:
Hardware Prolotype on Step5: Compile & Link, Targeting
development Board Software Prototype on Custom Hardware Platform Drivers
Development Board &Routines
No Does System No
Create Custom Acceleration
Meet Goals?
Hardware
Yes
Figure 4.2 Hardware/Software development flow for a Nios processor system [15]
56
Figure 4.3 Nios SDK Shell (bash).
This “bash” environment can be used for all related development work for the
Nios system and communicate with the Nios development board. The Nios
development board is shown in Figure 4.4. The Nios development kit includes
many Nios-specific utilities that can run in the Nios SDK Shell to generate and
debug software. The Nios SDK Shell also can be used to run test programs on the
57
Figure 4.4 Nios Development Board Components [17]
58
Figure 4.4 shows the Nios development board components. It includes [18]
prototype complex embedded systems. Software developers can use the Nios
software immediately.
unwanted parts of the signal, such as random noise, or to extract useful parts of the
signal, such as the components lying within a certain frequency range [19]. Figure
59
raw (unfiltered) signal filtered signal
FILTER
60
For a linear time-invariant system (Figure 4.6), its input and output satisfy the
following equation
N M
y[n] − ∑ a k y[n − k ] = ∑ bk x[n − k ] (4.1)
k =1 k =0
∑b z k
−k
H ( z) = k =0
N
[20], (4.2)
1 − ∑ ak z −k
k =1
where:
For causal FIR (Finite Impulse Response) system, the system function has
only zeros (except for poles at z=0), FIR filter does not depend on the past values of
the output. FIR filters are therefore non-recursive. Since the coefficients a k are all
M
y[n] = ∑ bk x[n − k ] . (4.3)
k =0
When the filter sequence (impulse response) of FIR filter is either symmetric
or anti-symmetric, the filter is of linear phase. Such filters do not distort the phase
61
of the input signal. It is well known that FIR filters can always be designed such
it is called symmetric.
Figure 4.7.
62
A Type 1 filter may be used to implement any desired bandpass frequency
response. A Type 2 filter may not be used to define a highpass filter since the
where an even length filter is preferable [21]. Antisymmetric filters can be used to
4.3 Implementation
attenuation and the transition bandwidth. MATLAB is a perfect tool for this
purpose. A sine wave signal was used as the test signal. Let M represent the filter
order.
program and 501 samples of the test signal sin(2 * π * 0.02 * n) with n = 0, K,500 .
The input signal is shown in Figure 4.8. The Hilbert transform outputs are shown in
63
Figure 4.8 Input waveform: sin(2 * π * 0.02 * 500) .
64
Figure 4.10 Output waveform, M = 71 .
65
Figure 4.12 Output waveform, M = 101 .
66
The group delay caused by the FIR filter with the anti-symmetric coefficients
M
and order M is . As result, the phase delay when the input
2
M π
* 0.02 * 2π + = (0.02 * M + 0.5)π .
2 2
The output maximum and the minimum values were checked. The amplitude
error and the phase delay for different order filters were also illustrated in Table
4.2. From the Table 4.2, it can be seen that the higher the order is, the less the error
is when M is changed from 51 to 101. In order to not take long time for compute
the Hilbert transform of the ECG wave, the filter order should be chosen properly.
The frequency responses are shown in Figure 4.14 and Figure 4.15 when the
67
Figure 4.14 Frequency response, M = 100 .
68
M f
Based on the delay analysis above, the phase response is − 360 * * − 90
2 2
degree for the normalized sampling frequency of 2. The slopes of the phase
responses in Figure 4.14 and 4.15 are -9090 degree/Hz and -9180 degree/Hz,
respectively.
From the Figure 4.9, Figure 4.10, Figure 4.11 and Figure 4.12 and Figure 4.13
it can be seen that the order of the filter must be bigger than 91 so that the
amplitude of the output wave is ≈ 1 . The phase shift depends on the filter order as
shown above. In addition, in this thesis, the error requirement is to be smaller than
0.5%. From the Figure 4.14 and Figure 4.15, when the order is odd, the frequency
response is not symmetrical (see the right hand side of Figure 4.14 and Figure
where
69
a = [1 1] is a vector containing the desired amplitudes 1 at the points specified
' filtertype' =' h' specifies that the filter is Hilbert transformer. This parameter
Hilbert transformer.
Running a MATLAB program, Figure 4.16 shows that the calculated remez
Figure 4.16 Frequency response of the ideal and Remez design filter.
70
Figure 4.17 Coefficients of the filter when M = 100 .
71
From the output coefficients shown in the Figure 4.17, it can be seen that the
magnitude response around f = 0.5 and a linear phase response with the slope of -
9090 degree/Hz.
This program uses the Remez exchange algorithm to design linear phase FIR
72
ideal frequency response [22]. The program has a special built-in section for
specifying the more common ideal filter types such as multi-band, bandpass filters,
remez.c calculates the optimal FIR filter impulse response for a set of given
band edges, the desired response and the weight on those bands. It includes a main
program that handles the input, sets up the appropriate approximation problem and
Function
has input values numtaps , numband , bands , desired[] , weight[] , type and output
value h[] ,
where
h[] is the impulse response of the filter, i.e. the coefficients of the filter.
and lower cutoff frequencies. The bands array specifys the set F to be the form
frequency response in each band. The number of desired[] should equal to the
number of bands .
73
weight[] is an array, which is the user_specified error weights, a positive
weight function in each band. The number of weight[] equals to the number of
bands. The array desired [] and weight[] specify the ideal response and weight
(d) Differentiators.
In this thesis, it has been explained that the order of the filter is M = 100 , so
the numtaps should be M + 1 = 101 . The numband is 3. The bands , the desired []
and the weight[] is defined as shown in Figure 4.19. The type parameter is
' HILBERT ' . The output result h[] is saved in a text file “coefile.txt”.
remez () was used to generate a filter. The initial parameters are shown in Figure
74
Figure 4.19 Initial parameter of remez.c .
A C program was run in Visual C++ and the filter coefficients are obtained.
They are shown in Figure 4.20. The frequency response of the filter is illustrated in
Figure 4.21.
It can be noticed that the coefficients obtained from the C code are not exactly
the same as those from MATLAB. Since the source code in MATLAB is not
available, it is not possible to check the differences in the specific calculations. The
frequency responses in Figure 4.18 and Figure 4.21 also show the differences. It
looks like the response from C code is closer to the ideal filter response (Figure
4.16).
75
Figure 4.20 Coefficients from the C program.
76
Figure 4.21 Frequency response for a M = 100 Hilbert transform filter.
This filter should also have a linear phase response as the one in Figure 4.18.
However the phase response of the plot does not have the same slope in the
stopband as one in the passband. It is caused by the calculation error because the
fir _ filter ( M , Coef , Xinput ) was written in C program that is used to apply
where
77
M is an integer. It is the number of coefficients of the filter.
where
“infile” is the file name which saved the input data. It is named by users.
“outfile” is the file name which saved the results filtered from the filter. It is
named by user. In this case, the outfile saved the Hilbert transform of the input
ECG data.
described in the previous chapter, one of the properties of the Hilbert transform is
that it is an odd function. That is to say that it will cross zero on the x -axis every
time that there is an inflection point in the original waveform [24]. Similarly a
crossing of the zero between consecutive positive and negative inflection points in
78
waveform. Using this characteristic, a detector for determining the R wave peak in
The Hilbert transform of the ECG wave was obtained in section 4.3.3. The
peaks in the Hilbert transform sequence h(n) represent regions of high probability
of finding R wave peaks. An adaptive threshold is used to locate the peaks in the
h( n) sequence. For finding the R wave peak accurately, a moving 1000 points
window is used to subdivide the Hilbert transform h(n) sequence. The RMS (Root
Mean Square) value and the maximum amplitude in the present window are then
calculated. The threshold in this window was determined according to the criteria
below:
4. If the two peaks in the h(n) sequence are two close together, only one of
In this section, two ECG waveforms taken from the MIT-BIH Arrhythmia
79
The MIT-BIH Arrhythmia database consists of 48 records, each containing 30
recordings were digitized at 360 samples per second per channel with 11-bit
XW_1 and XW_2 are the normal ECG waves. They are the small sections of
MIT213 from the MIT-BIH database. Figures 4.22 and 4.23 illustrate the input data
XW_1 and its filtered version, i.e., the Hilbert transform of the input signal.
the heart electrical activity recorded from electrodes on the body face. Figure 4.22
80
shows a small section beats of a normal heart. There are 4 heartbeats since each R
81
Figure 4.23 shows the Hilbert transform of the input wave, i.e. XW_1. For
those points in Figure 4.22 where the slope changed from positive to negative, their
outputs should be the zero crossing points with the extreme values changing from
negative to positive. Because of the filter delay, the output results lag the input by
heartbeat, i.e., the R wave peak. Compared the results with the MIT-BIH database
annotation file, it can be seen that the output values are close.
82
Figure 4.25 Output waveform for XW_2.
Figure 4.24 shows another channel waveform for the same person. The reason
why Figure 4.24 is different from the Figure 4.22 is the electrode is placed at a
different location. XW_1 is obtained when the electrode is placed at the front of the
body while XW_2 is obtained when the electrode is placed on the back of the body.
For this case, for those points which slope changed from negative to positive, the
output point should be the zero crossing point with the extreme values changing
83
Table 4.4 XW_2 extreme points and values
Table 4.4 shows the results, for the same reason with the previous wave, filter
phase delay, the output wave lag the input by 50 ( M / 2 ). Comparing the output
results with the MIT-BIH database annotation file, the error between the output
In order to use the Nios development board [Figure 4.4], connect the host PC
$ nios − run − t − r
This establishes a simple terminal connection with the development board. Press
the SafeConfig button on the Nios development board to reset the Nios
development board and reconfigure the Stratix FPGA. The reference design emits a
text message to the serial port when the Nios processor boots. After the LEDs begin
84
to blink and the LED displays network-initialization status messages, press SW3 to
abort DHCP network configuration. Text will display in the Nios SDK Shell
window. Press the Enter key on the PC several times to provide stimulus to the
85
If the activity in the Nios SDK shell looks like in Figure 4.26, then the PC is
communicating correctly with the Nios development board. Press Ctrl + C to exit
$ nios − build
The GNU C/C++ compiler and linker will be invoked. Several intermediate files
and an executable ( .srec ) file will be produced. The messages are shown in Figure
4.27.
86
To download and run the code compiled in Figure 4.27, download the srec
file to the Nios development board. Redirect stdout to a data file outputdata1.txt .
The input waveforms XW_1 and XW_2 are a section wave of MIT 213 taken
from the MIT_BIH Arrhythmia database (Figure 4.29 and Figure 4.31). The output
file record the data of the Hilbert transform of the ECG wave. The output
87
Figure 4.29 Input ECG waveform: XW_1.
88
Figure 4.31 Input ECG waveform: XW_2.
89
From the output waveforms in Figure 4.30 and Figure 4.32, it can be seen that
the waveforms are almost the same as the results obtained from Visual C++.
Table 4.5 XW_1 R wave points and their Hilbert transform points
Table 4.6 XW_2 R wave points and their Hilbert transform points
Table 4.5 and Table 4.6 show the N values of the R wave points and their
Hilbert transform points. It’s the same as the one discussed in the section 4.2. The
results illustrates that the programs can work correctly on the Nios embedded
processor.
90
Chapter 5 Results
transform of an ECG wave has been discussed. In order to prove the program is
working well in the Nios processor, some ECG waves taking from the MIT-BIH
Arrhythmia database were used as verifications. The results will be compared with
Further examples of some ECG waves and their Hilbert transformed output
The file mit 212 from100.txt is a small section from MIT212 recorded in the
MIT-BIH arrhythmia database. It includes 1000 data samples from 100 to1099 in
MIT212. Figure 5.1 shows the original ECG waveform. The output, i.e., the Hilbert
mit 212 _ 1 from47200.txt is another section from the MIT212. It also includes 1000
91
data samples. The original waveform and the Hilbert transform of this ECG wave
in ECG analysis. The zero crossing points corresponding to the true R wave peak in
the Hilbert transformed data of the original ECG waveform are shown in Table 5.1
and Table 5.2. The actual position of R wave points in the MIT-BIH arrhythmia
database is also given. The error between the located R and actual R is calculated
where
N ouput is the number of the zero crossing point in the Hilbert transform
N MIT − BIH is the actual R wave peak location recorded in the MIT-BIH
annotation file.
Since the order of the filter used in this thesis is 100, the output waveform
92
Figure 5.1 Input waveforms: mit212from100.txt.
93
Table 5.1 mit212from100 extreme points and values
94
Figure 5.4 Output waveform: outMIT212from47200.txt.
95
The ECG waveforms (Figure 5.1 and Figure 5.3) are normal because the P
waves, QRS complexes, ST segments, T waves and U waves are normal. Each R
Table 5.1 and Table 5.2 show the positions of the zero crossing points in the
output waveform which corresponding to the R peaks in the input ECG wave.
Because of the filter delay, the output results lag the input by 50 ( M / 2) . From
Table 5.1 and Table 5.2, it can be seen that the N in the output waveform is
lagging about 50. The error between the zero crossing points obtained in the output
waves with the value recorded in the MIT-BIH annotation file is very small. It
proves that the algorithm for calculating the Hilbert transform of the original ECG
wave is correct. Note in the Table 5.1 and Table 5.2, the meaning of the letter in the
“MIT-BIH value” is the type of the beat recorded in the MIT-BIH annotation file.
fusion PVC. The details about the MIT-BIH annotation code are shown in the
Appendix A.
The files mit 213 _ 1 from67000.txt and mit 213 _ 1 from1450.txt are small
sections from another record, MIT213, in the MIT-BIH arrhythmia database. Figure
5.5 and Figure 5.7 show the ECG waveform. The outputs, i.e., the Hilbert transform
of the input wave, were illustrated in Figure 5.6 and Figure 5.8. It can be seen there
is an irregular heartbeat between N = 600 and 700 in Figure 5.5. This kind of beat
heartbeats originating from the ventricals of heart. PVCs are early or extra
heartbeats that commonly occur and are usually harmless in normal hearts, but can
96
cause problems in hearts with pre-exiting disease. A person with PVCs may or may
not feel the irregular heartbeat, usually as a skip heartbeat [25]. The characteristic
of PVCs is that there is no P wave and PR interval and the QRS complex is greater
than 0.12s.
97
Figure 5.6 Output waveform: outMIT213_1from67000.txt.
98
Figure 5.7 Input waveform: mit213_1from1450.txt.
99
Table 5.4 mit213_1from1450 extreme points and values
From the results obtained in Table 5.3 and Table 5.4, it can be seen that the
error for normal heartbeat and for the PVC beat are small and are acceptable.
Here other examples are given, the files mit 223 _ 1 from47700.txt and
mit 223 _ 1 from7900.txt are sections from the MIT 223 in the MIT-BIH database.
The input waves are shown in Figure 5.9 and Figure 5.11, the Hilbert transforms of
the input ECG waves are shown in Figure 5.10 and Figure 5.12. In this case, there
are a few irregular heartbeats, such as PVCs. In Figure 5.9, the PVCs happened
between N = 0 to 100 and N = 800 to 900. Table 5.5 and Table 5.6 show the
compared results.
100
Figure 5.9 Input waveform: mit223_1from47700.txt.
101
Table 5.5 mit223_1from47700 extreme points and values
102
Figure 5.12 Output waveform: outMIT223_1_from7900.txt.
103
In Figure 5.11, the PVC happened between N = 500 to 600. The R wave
peak is not that clear, there are two peaks and the extreme values are close together.
Table 5.5 and Table 5.6 record the R wave peaks in the input and output waveform.
From Table 5.5 and Table 5.6, it can be seen that the output results lag the input
As discussed in the Chapter 4, the points which are of interest are those zero
crossing points with the extreme value changing from negative to positive or from
positive to negative. Comparing the results shown in Table 5.1-Table 5.6 with the
data recorded in the MIT-BIH arrhythmia database, the error is small and is
acceptable. It illustrated that the algorithm and the program are correct and working
properly.
In the previous section, just small sections from the record of the MIT-BIH
contains 30 minutes of ECG with heartbeat recording. In this section, the whole
excerpt will be used to test. Every excerpt includes 649999 data samples.
MIT212 is the heart recording of an adult (31 years old). The predominant
104
MIT213 is the record of a 61year_old person’s heart; heart rate is 100-110
BPM. Predominant is normal but there are occasional APBs (Atrial Premature
Beats).
The entire excerpt from the MIT-BIH Arrhythmia database was tested by the
system discussed in this thesis. The Hilbert transform of this excerpt is obtained and
the R wave peaks are detected. Since the data is too long, just portion of the results
of MIT212, MIT213 and MIT223 were shown in Figure 5.13, Figure 14-15 and
105
Figure 5.13 The portion of results of MIT212.
106
Figure 5.14 The portion of results of MIT213.
107
Figure 5.15 The portion of results of MIT213.
108
Figure 5.16 The portion of results of MIT223.
109
Figure 5.17 The portion of results of MIT223.
110
The detection error rate and average error were calculated using the following
equations respectively:
FailedDetectionNumber
DetectionErrorRate = (5.2)
AcutralNumberOfBeats
⎛ k ⎞
⎜ ∑ locatedR − actualR ⎟
AverageError = ⎝ i =1 ⎠, (5.3)
K
where
From the detection error rate and the average error, it can be seen that the
results are closed to the data recorded in the MIT-BIH annotation file. The average
error in MIT 223 is bigger since MIT 223 records the heart beats of an 83 year old
person and there are a lot of PVCs, the beat by beat error is larger. That is why the
average error is larger than others. But the error is still acceptable (< 3 samples).
The results of the test illustrate the algorithm for calculating the Hilbert transform
111
Chapter 6 Summary and Conclusion
In the previous chapters, the information about the Holter monitoring system
and the process for calculating the Hilbert transform of an ECG signal are discussed
in detail. This final chapter summarises the results of the research and the contents
of the thesis.
6.1 Summary
The Holter ECG Monitoring System mainly consists of four parts: Input
the input processing is to calculate the Hilbert transform of the input ECG data.
and the concepts of pre-envelope and envelope of a real waveform given by the
Hilbert transform to judge whether the ECG wave is normal or abnormal. Lastly
data is compressed from the abnormal ECG wave and saved in the flash card. In
this thesis, only the first part of the Holter ECG monitoring system, i.e., Input
Processing is discussed.
112
The background of the Holter ECG Monitoring System was presented. The
Hilbert transform applications and the basic mathematics and properties of a Hilbert
waveforms, and has been widely used in the areas of communication systems
analysis. The resulting display of the Hilbert transformed data is similar to that
quick, precise segmentation of the incoming ECG into individual heartbeats and
also allows the detection of Q-, R-, S-, and T-wave complexes in the data.
In this thesis, four approaches to compute the Hilbert transform including the
the Remez Filter approach have been discussed in detail. The algorithms are
deduced and examples are also given for every approach. After comparing them in
running time and the ease of implementation, the Remez Filter approach which
was determined to be the best and is used in computing the Hilbert transform of the
ECG wave in this thesis. The results for every approach were shown in Chapter 3
In the software implementation part, as a first step, the filter order and the
frequency range are determined by analyzing a set of test results using MATLAB.
The remez function was used in MATLAB to test the Hilbert transform of the
ECG data.
113
In additional, a C program ( remez.c ) was developed to implement the
algorithm, i.e., uses the Remez exchange algorithm and Chebyshev approximation
theory to design a filter with the optimal fit between the desired frequency response
and actual frequency response. A main program that handles the input, sets up the
appropriate approximation problem and handles the output of the optimal filter
coefficients was included. Specifically remez.c has a build-in section for the more
common ideal filter types such as multi-band, bandpass filters, differentiators and
the Hilbert transform filters. All results including the order, frequency range and the
sequence. Using the coefficients achieved from remez.c and the input data, i.e., the
ECG data sequence, the Hilbert transform of the input ECG data was obtained. All
of the R wave peak, is essential in ECG analysis and is another task in this thesis.
In the system discussed in this thesis, the method of ECG waveform analysis uses
prototype two stage QRS detector was used based on the determination of a zero
crossing in the Hilbert transformed data of the original ECG waveform. The
positions of the zero crossing points that correspond to the R wave peaks are useful
114
A C program was developed to detect the QRS complex, in particular, to
detect the R wave peak used in ECG analysis. All the results were shown in
Chapter 4 and Chapter 5. The simulation results are also presented in Chapter 5.
The Nios embedded processor was introduced. SOPC Builder was used to be
development tool. Using SOPC builder, users can combine the Nios processor with
user logic and program it into an FPGA easily. All programs were run on the Nios
embedded processor. The results, i.e., the Hilbert transform of the ECG data
sequence, are almost the same as the results obtained in the C program except the
first 50 data samples. The first 50 data samples in the output sequence can be
ignored since the phase delay of the filter is 50. The results prove that the program
6.2 Conclusion
The data used in test were from standard ECG waveform records in the MIT-
BIH arrhythmia database. The performance of the chosen algorithm was tested. The
test results were compared with the annotation files recorded in the MIT-BIH
arrhythmia database. The detection error rate is smaller than 0.005. The average
error is smaller than 3 samples. The results were given in Chapter 5. The error is
acceptable. The results illustrated that the algorithm performed effectively with
115
References
http://medlib.med.utah.edu/kw/ecg/ecg_outline/Lesson1/index.html Accessed
February 2006.
March 2006.
[5] Merck& Co., Inc., “The Merck Manual of Health & Aging”, Available at:
http://www.merck.com/pubs/mmanual_ha/figures/fg47_1.html Accessed
March 2006.
[7] Wikipedia, the free encyclopedia, “Cauchy principal value”, Available at:
116
[8] Kunio Takaya, “Digital Signal Processing Electrical Engineering EE-880”,
[9] Mathias Johansson, M.Sc. thesis, “The Hilbert transform”, VaxJo University,
1999.
[10] Easy Fourier Analysis, “Signal processing & simulation newsletter”, Available
[12] Jose A. Inaudi and James M. Kelly, “Linear hysteretic damping and the Hilbert
May 1995.
[13] Holger Boche and Marcus Protzmann, “A new algorithm for the reconstruction
Instrumentation and Mesurement, Vol. 46. No.2, pp. 442-444, April 1997.
117
[18] Altera Corporation, “Nios II Development Kit Getting Started User Guide”,
http://www.techonline.com/community/ed_resource/feature_article/20365
http://documents.wolfram.com/applications/digitalimage/UsersGuide/FilterDes
http://search.cpan.org/src/MLEHMANN/PDL-Audio-1.1/remez.c Accessed
May 2005.
[23] The digital signal processing committee, “Programs for Digital Signal
1979.
[24] D. Benitez, P.A. Gaydecki, A. Zaidi, A.P. Fitzpatrick “The use of the Hilbert
July 2006.
118
Appendix A
A.1 Introduction
channel ECG with beat and rhythm annotations. Each digital record has been
copied from an analog recording made with an Avionics 445 two-channel recorder.
resolve disagreements.
The data base is recorded on twelve 2400-foot (730m) ANSI standard 9-track
tapes at 800 bpi, odd parity, with NRZI recording. A detailed catalog of the
The format is that which will be used for the American Heart Association
numbers.
119
An additional “0” annotation has been added to the AHA set to specify non-
beat annotations (e. g., rhythms, artifact).The “R” (R-on-T PVC) annotation is not
used.
Space allocated but unused in the AHA format annotation blocks is used to
specify rhythms and beat types more precisely than is allowed using the AHA
annotation codes alone. Atrial ectopic beats and conduction defects are among the
marks. The last file is terminated with two EOFs to indicate the end of the tape.
comprised of four files: an ID block file, a sample data file, an annotation file, and a
(Record 1) ID Block
(EOF)
Sample Data Blocks
(EOF)
Annotation Blocks
(EOF)
ID Block
(EOF)
(Record 2) ID Block
(EOF)
Sample Data Blocks
(EOF)
Annotation Blocks
(EOF)
ID Block
(EOF)
120
(Record3) Sample Data Blocks
(EOF)
Annotation Blocks
(EOF)
ID Block
(EOF)
(Record4) Sample Data Blocks
(EOF)
Annotation Blocks
(EOF)
ID Block
(EOF)
Multiple-byte Numbers
is referred to as byte i, the next most significant byte as byte ii, and so on. (The first
byte read from the tape in a given block is called byte 1.)
32-bit numbers are stored in the order: byte iii, byte iv, byte i, byte ii.
ASCII text
In the ID block and in certain annotation labels (see below) brief comments
are present. These are coded as ASCII characters, and should be read from the tape
in byte-sequential order.
TOCs
numbers. TOCs in the AHA database are given as the number of MILLISECONDS
121
from the beginning of the annotated segment of the record. In the MIT-BIH
database, TOCs are given as the number of SAMPLE COUNTS from the beginning
1000/360 (=2.777….).
ID block file
The first and fourth files in each record each consist of a single 512 byte ID
Bytes Use
1-8 record ID (8 ASCII characters)
9-10 number of annotations
11-16 unused
17-20 time of first sample in the annotated segment of the record
21-24 time of last sample in the annotated segment of the record
25-26 number of bytes of sample data, divided by 512 and rounded upward
27-32 unused
33-36 TOC-first annotation, relative to the beginning of the annotated segment
37-40 TOC-last annotation, relative to the beginning of the annotated segment
41-42 numbers of bytes of annotation data, divided by 512 and rounded upward
43-512 unused
In each record in the MIT-BIH database, the entire record has been annotated;
thus the time of the first sample is always zero. Each tape has exactly 649999
samples, and an end-of-sample-data mark, per channel (30 minutes and 5.444
seconds), and the annotated segment is considered to end after the end-of-sample-
data mark, so that the time of the last sample in the annotated segment is always
650000, and the number of bytes of sample data divided by 512 is always 5079
122
(649999 samples per channel, times 2 channels, times 2 bytes per sample, divided
by 512, rounded up). NOTE THAT THE UNITS OF TIME ARE SAMPLE
The second file in each record is the sample data file, which consists of
Each block contains 256 2-byte samples from each channel. Samples are
Byte Use
1 Channel 1, sample 1, byte i
2 Channel 1, sample 1, byte ii
3 Channel 2, sample 1, byte i
4 Channel 2, sample 1, byte ii
5 Channel 1, sample 2, byte i
M
1021 Channel 1, sample 256, bytei
1022 Channel 1, sample 256, byteii
1023 Channel 2, sample 256, bytei
1024 Channel 2, sample 256, byteii
The AHA database has been recorded using a 12-bit A/D converter with a
range of -10V to +10V, and preamp gain adjusted so that a QRS complex is
nominally 1V peak-to-peak, or about 200 ADC units. The MIT-BIH database has
been recorded using an 11-bit A/D converter with a range of -5mV to +5mV, and
the unamplified QRS complexes are nominally 1 mV, or about 200 ADC units; thus
the scales are the same though the ranges differ. Both positive and negative (two’s
complement, with sign extension to 16 bits) samples are recorded in the AHA
database; in the MIT-BIH database, all samples are positive (in the range of 0 to
2047).
123
Block 2540 contains the last fifteen samples for each channel. The end of the
sample data is marked in the last sample block by two consecutive sample values of
10000 (base 8) following the last samples. The remainder of the last sample block
Annotation file
The third file in each record is the annotation file, which consists of a variable
The AHA format leaves a number of unused bytes in each annotation label,
The last annotation block is padded with all ones (177 base 8) following the
last annotation. If there is no room following the last annotation, an entire block of
177s is written.
Annotation labels
124
*The ASCII text field is filled with zero bytes unless the MIT-BIH annotation code
The “R” code does not appear in the MIT-BIH database. An additional code,
“O” (117 base 8), has been defined to permit inclusion of rhythm labels, artifact
labels, and comments. “O” labels are never QRS labels, and may be ignored for the
The MIT-BIH annotation codes are not ASCII characters, but numbers
125
4 N aberrantly conducted beat
5 V premature ventricular contraction (PVC)
6 F fusion PVC ***
7 N nodal premature beat
8 N atrial premature bat (APB)
9 N nodal or atrial premature beat
10 E ventricular escape beat
11 N nodal escape beat
12 P paced beat
13 Q beat of indeterminate origin
14 O,U beginning of noise *
15 O end of noise *
16 O single QRS-like artifact
17-21 O reserved for future use **
22 O comment (text) annotation ***
23-24 O reserved for future use **
25 N left or right bundle branch block beat
26 O non-captured pacemaker spike
27 O axis shift
28 O rhythm onset (text) annotation ***
29-30 O reserved for future use **
31 O ventricular flutter wave
32 [ onset of ventricular flutter or ventricular fibrillation
33 ] end of ventricular flutter/fibrillation atrial ectopic beat
34 N atrial ectopic beat
35 N nodal ectopic beat
36 O missed beat
37 O blocked APB
38 O reserved for future use **
the code 14 “U”, no beats are labeled until the next code 15; otherwise, all beats are
labeled.
** Where codes designated “reserved for future use” appear, they should be
ignored.
*** “Text” annotations use the last six bytes of the annotation label for an ASCII
126
**** In the context of paced rhythm (tapes 102,104,107,217) annotation code 6 is
String Meaning
(AB atrail bigeminy
(AFIB atrial fibrillation
(AFL atrial flutter
(B ventricular bigeminy
(BI first degree heart block
(BII second degree heart block
(BIII third degree heart block
(IVR idioventricular rhythm
(N normal sinus rhythm
(NOD normal (A-V junctional) rhythm
(PAT paroxsysmal atrial tachycardia
(PREX pre-excitation (WPW)
(SVTA supraventricular tachyarrhythmia
(T ventricular trigeminy
(VFIB ventricular fibrillation
(VFL ventricular flutter
(VT ventricular tachycardia
Comment annotations
PSE pause
TS tape slippage
127
Appendix B
Consider a particularly effective and widely used algorithm procedure for the
design of FIR filters with generalized linear phase. Although only type I filters are
considered in detail, where appropriate results that apply to types II, III, and IV
and then to insert sufficient delay to make it causal. Consequently, consider he [n]
satisfying the condition of Eq. (1). The corresponding frequency response is given
by
L
Ae (e jω ) = ∑ h [n]e
n=− L
e
− jωm
, (2)
L
Ae (e jω ) = he [0] + ∑ 2he [n] cos(ωn). (3)
n =1
Note that Ae (e jω ) is a real, even, and periodic function of ω . A causal system can
128
h[n] = he [n − M / 2] = h[ M − n] (4)
H (e jω ) = Ae (e jω )e − jωM / 2 . (5)
L
Ae (e jω ) = ∑ a k (cos ω ) k , (7)
k =0
where the a k ’s are constants that are related to he [ n] , the values of the impulse
Ae (e jω ) = P ( x) x = cos ω , (8)
L
P ( x) = ∑ a k x k . (9)
k =0
polynomial of Eq.(7).
129
The key to gaining control over ω p and ω s is to fix them at their desired
values and let δ 1 and δ 2 vary. To formalize the approximation problem, define an
E (ω ) = W (ω )[ H d (e jω ) − Ae (e jω )], (10)
parameters into the design process. In this design method, the error function E (ω ) ,
Let FP denote the closed subset consisting of the disjoint union of closed
r
P ( x) = ∑ a k x k .
k =0
E P ( x) = WP ( x)[ DP ( x) − P ( x)].
E = max E P ( x) .
x∈FP
130
must exist at least (r + 2) values xi in FP such that x1 < x 2 < L < x r + 2 and such
The alternation theorem states necessary and sufficient conditions on the error
for optimality in the Chebyshev sense. Although the theorem does not state
explicitly how to find the optimum filter, the condition is phrased in terms of type I
From the alternation theorem, the optimum filter Ae (e jω ) will satisfy the
where δ is the optimum error and Ae (e jω ) is given by either Eq. (3) or Eq. (7).
⎡ a 0 ⎤ ⎡ H d (e 1 ) ⎤
jω
⎡ 1 ⎤
⎢1 x1 x12 L x1L
W (ω1 ) ⎥ ⎢ ⎥ ⎢ ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
−1 ⎥
⎢1 x x 22 L x 2L ⎢
⎢ a 1 ⎥ H d (e ) ⎥
jω 2
⎢ W (ω 2 ) ⎥ ⎢ ⎥ =⎢ ⎥,
2
(12)
⎢M M M M M ⎥ M
⎢ ⎥ ⎢ ⎥
⎢
(−1) L+2 ⎥ ⎢ ⎥ ⎢M ⎥
⎢1 x x L2+ 2 L x LL+ 2 ⎥ ⎢ ⎥ ⎢ ⎥
⎢⎣ W (ω L + 2 ) ⎥⎦ ⎣⎢δ ⎦⎥ ⎢⎣ H d (e L + 2 )⎥⎦
L+2 jω
where xi = cos ω i . This set of equation serves as the basis for an iterative algorithm
ω l +1 = ω s . The set of equations (12) could be solved for the set of coefficients a k
131
Specifically, Parks and McClellan found that for the given set of the extremal
L+2
∑b H k d ( e jω k )
δ= k =1
, (13)
L+2
bk (−1) k +1
∑
k =1 W (ω k )
where
L+2
1
bk = C (14)
i =1 ( x k − xi )
i≠k
coefficients a k that satisfy Eq. (12), with δ given by Eq. (13), then the error
formula to obtain
L +1
jω
∑ [d k /( x − x k )]C k
Ae (e ) = P(cos ω ) = k =1
L +1
, (15)
∑ [d
k =1
k /( x − x k )]
(−1) k +1 δ
C k = H d (e jωk ) − , (16)
W (ω k )
132
and
L +1
1 bk
dk = ∏ = . (17)
i =1 ( x k − xi ) ( x k − x L + 2 )
i≠k
the set of Eq. (12) for the coefficients a k . The polynomial of Eq. (15) can be used
and stopband. If E (ω ) ≤ δ for all ω in the passband and stopband, then the
In this algorithm all the impulse response values he [n] are implicitly varied
on each iteration to obtain the desired optimum approximation, but the values of
133
Initial guess of
(L+2) extremal frequencies
Calculate error E (ω )
and find local maxima
where E (ω ) ≥ δ
No
Unchanged
Best approximation
134