Sie sind auf Seite 1von 45

CHAPTER III

DIGITAL FILTER DESIGN TO DENOISE ECG SIGNAL

The current work used ECG sample from MIT-BIH Arrhythmia database instead
of acquiring ECG signal directly from a human subject. The signal is artificially
corrupted by adding noise. This chapter presents the digital filtering techniques to
obtain a noise free ECG signal using wavelet toolbox and their performances are
compared based on parameters like Signal to Noise Ratio (SNR), Error and Accuracy
which is a tedious task. However, the method based on SNR and Mean Square Error
(MSE) in MATLAB, to select the optimal order digital filter is more easier than using
wavelet toolbox. By using Power Spectrum Density (PSD) and Fast Fourier Transform
(FFT), the performance of optimal order filters is validated. A final summary report
on the study of complexity of the structure of optimal order filters is presented, which
is realized using MATLAB and analyzed.

3.1 INTRODUCTION

ECG signal is a non-stationary signal that includes valuable clinical


information, but frequently this information is corrupted by several noise such as
baseline noise, power line interference, electrode contact noise, motion artifacts,
instrumental noise and electrosurgical noise etc. In signal processing, filters play an
important role to remove and reduce the unwanted signals such as noise or extract the
information of the signals that lie within a certain frequency range. Two types of
digital filters used in biomedical signal processing are FIR filter and IIR filter
(Chandrakar et al.2013). MATLAB is the common software tool used to design the

54 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

digital filters. They are programmable, hence it helps to reduce the design cycle and
minimize the risk of design. Moreover, digital filters perform noiseless mathematical
operations (Wang 2007) but the biggest challenge in implementing digital filters in
hardware is to achieve specified speed of data processing at minimum hardware cost
(Chan 2010).
Many researchers have worked on the development of methods for reduction of
noise in ECG signal. Kaur et al.(2011) compared different approaches for removal of
baseline wander from ECG signal on the basis of PSD and SNR parameters using
MIT-BIH database. Sadabadia et al. (2007) proposed a mathematical algorithm for
suppressing of the high frequency (noise) and low frequency (base-line wandering)
noise from ECG signal. Mbachu et al. (2011) used digital FIR low pass, high pass and
Notch filters with Kaiser Window, Hanning Window, Hamming Window and
Rectangular Window. Sastryet al. (2012) removed the artifacts and compared them
using SNR and visual inspection of frequency response. Chavan et al. (2008) designed
Chebyshev-I and Chebyshev-II filters using MATLAB FDATool and acquired ECG
data from the instrumentation amplifier designed in the laboratory. The performances
of these filters were compared using frequency spectrum and then were realized in
MATLAB. Alfaouri and Daqrouq (2008); Kozaitis (2008); Joshi et al. (2013); Dliou
(2013); Hang and Liu (2011); Pratap et al. (2013); Dey et al. (2011); Singh and Yadav
(2010); Ashfanoor and Shanaz (2012) Mihov (2013); Rastogi and Mehra (2013);
Leelakrishna and Selvakumar (2013); Joy and Manimegalai (2013); Tarek et al.
(2012); Gupta and Chand (2013); Kumar and Mallik (2010); Bhogeshwar et al. (2014)
applied digital filter methods to cope with the noise artefact in ECG signal.
Removal of high frequency noise (20-1000 Hz) like EMG noise (caused by
muscle activity/tension) in the ECG signal is an important issue concerning the
denoising ECG signals researches. The conventional ECG is of 0.05-100 Hz but
higher frequencies are also present in ECG signal. In theory, the incoming ECG
signals must be sampled (digitized) at least at twice the rate of the highest frequency of
interest for the high frequencies signal retention; otherwise the signals are distorted.
This means that if the frequency range of interest is in the 150-250 Hz range, the
sampling rate must be at least 500 Hz. In practice a higher sampling rate is required,
and in most high frequency studies the sampling rate has been 1000 Hz or more.
Sadabadi et al. (2007) used both the high frequency (noise) and low frequency (base-

55 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

line wandering) noise removal techniques with 1000 Hz sampling frequency in their
study. Bortolan and Christov (2014) explored a filter that restrains sufficiently the
EMG noise (high frequency noise), with minimal distortion of high frequency content
of the QRS complex. Kansal(2011) suggested, the proper selection of filters is done
based on properties, design criteria, and their applications. Moreover, few researches
emphasised in selecting the optimal order of the digital filter for denoising ECG
signal.
Massachusetts Institute of Technology-Beth Israel Hospitals created
MIT-BIH Arrhythmia database in 1980. ECG recordings collected from a mixed
population (25 men aged 32 to 89 years and 22 women aged 23 to 89 years)
approximately 60% of the subjects were inpatients at Boston‟s Beth Israel Hospital
(BIH) (Moody and Mark, 2001). To save the storage space, they adapt universal
standard format and store in sealed file. Due to the representative case and abundant
annotations MIT-BIH has become benchmark database. The current study used ECG
signal to carry out the research from the available stored ECG signal database instead
of taking real time acquired signal from human object as it was easy and a time saving
method. The ECG signal imported from MIT-BIH database for analysis is a 100m.mat
ECG data sample. The selection of optimal order digital filter for each category is
rarely available in literature. In this chapter the optimal order digital filters for all
categories have been obtained for FPGA implementation.

3.2 METHODOLOGY

The following section discusses the import and denoising of ECG signal
(100m.mat) using IIR and FIR filters and their performances are compared using
wavelet toolbox. The work flow graph of denoising and analysis of ECG signal is
shown in Figure 3.1.The annotated ECG signals are described by a matrix (.mat), text
header file (.hea); a binary file (.dat) and binary annoted file (.atr) and information
about the signal (.info) file. The recording of the ECG signals 100m.mat (Male of 69
years) is done in digitised form at 360 samples per second per channel with 11-bit
resolution over a 10-mV range. The imported ECG signal “x” is the original ECG
signal with no noise. The loaded ECG signal as shown in Figure 3.2, is then artificially
corrupted by adding random noise, white Gaussian noises and a 50-Hz power line

56 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

interference. Figure 3.3 shows the artificially corrupted signal i.e. “x1”, which is used
as an input to the various digital filters to carry out this research work. The filtered
signal “y” is the output of digital filter which is for analysis and information
extraction. In the present study for denoising ECG signal using various low pass IIR
and FIR digital filters are designed in MATLAB platform and their performance is
compared.
Start

Import ECG data sample from MIT-BIH


Arrhythmia database to MATLAB

Add artificial noise to data sample

Design FIR & IIR filter in MATLAB

Use wavelet toolbox to examine statistical


parameters like mean, mode, standard deviation

Calculate Signal to Noise Ratio, Error and Accuracy

Compare the performance of digital filters

End

Figure 3.1 Work flow graph for denoising & analysis of ECG signal
The following steps are followed for denoising ECG signal.
Step 1: MIT-BIH Arrhythmia database ECG signal 100m.mat is loaded („x‟ as shown in
Figure 3.2).

Figure 3.2 Original signal 100m.mat

57 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Step 2: Artificial noise is generated by adding random, Gaussian noise and 50Hz
sinusoidal signal to the original signal. A corrupted ECG signal „x1‟ is shown in Figure 3.3.

Figure 3.3 Artificial corrupted ECG signal with noise

Step 3: Various ECG de-noising techniques using IIR digital filters like Butterworth
filter, Elliptic filter, Chebyshev-I and II and FIR filters like Zero phase filter,
Hamming window and Rectangular window are developed with the help of MATLAB
(R2011a).
Step 4: The statistical parameters like mean, median and standard deviation of the
signals are examined using wavelet toolbox to check the performance of the digital
filters.
Step5: The performances of filters are compared by calculating SNR, error and
accuracy using (Eqn.3.1-3.3).

𝑀𝑒𝑎𝑛 (3.1)
𝑆𝑖𝑔𝑛𝑎𝑙 𝑡𝑜 𝑁𝑜𝑖𝑠𝑒 𝑟𝑎𝑡𝑖𝑜 =
𝑆𝑡𝑎𝑛𝑑𝑎𝑟𝑑 𝐷𝑒𝑣𝑖𝑎𝑡𝑖𝑜𝑛

𝑆𝑡𝑑. 𝐷𝑒𝑣𝑖𝑎𝑡𝑖𝑜𝑛 𝑥 − 𝑆𝑡𝑑. 𝐷𝑒𝑣𝑖𝑎𝑡𝑖𝑜𝑛 (𝑦) (3.2)


𝐸𝑟𝑟𝑜𝑟 = 𝐴𝑏𝑠 × 100
𝑆𝑡𝑑. 𝐷𝑒𝑣𝑖𝑎𝑡𝑖𝑜𝑛 (𝑦)
Where “x” is original signal and “y” is the filtered signal

𝐴𝑐𝑐𝑢𝑟𝑎𝑐𝑦 = 100 − 𝑒𝑟𝑟𝑜𝑟 (3.3)

The optimal order digital filter selection using wavelet toolbox for conversion of
MATLAB code into Verilog for implementation on FPGA was tedious so, the following
approach was adopted.

58 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

The following section elaborates the complete process for selection of


optimal order digital filter for denoising of high frequency noise. The design
methodology involves filter design script to be written separately using in-built
functions for IIR & FIR digital filters; a separate noisy signal („x1‟) is generated and
put in filter design script as input. After processing the above signal, the denoised
signal „y‟ as output is sent to MATLAB. This helps in conversion of the MATLAB
code into Verilog for FPGA implementation, which is discussed in the next chapter.
Design steps for selection of optimal order digital filter and analysis of their hardware
complexity is shown in Figure 3.5.

Following steps are required for selection of optimal order filter.

Step 1: MIT-BIH database ECG signal 100m.mat is loaded („x‟ as shown in Figure
3.2).
Step 2: The loaded ECG signal is normalized as per the information given in
100m.info file („xx‟ as shown in Figure 3.4).

Figure 3.4 Normalised original signal 100m


Step 3: Artificial noise is generated by adding random, Gaussian noise and 50Hz
sinusoidal signal.
t_noise= Random noise + Guassian noise + 50 Hz Sinusoidal signal
Step 4: A simple high pass filter is used to filter the low frequency noise and retain the
high frequency noise (100Hz -250 Hz) from generated t_noise with the following
specifications:
(i) Stop band frequency = 100Hz
(ii) Pass band frequency = 250Hz
(iii) Sampling frequency = 1000 Hz
(iv) Stop band attenuation=60dB
(v) Pass band ripple=1dB
59 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

The removal of high frequency noise requires a higher order filter, which inherently
is a complex structure, but ensures better performance.

Start

Load MIT-BIH 100m.mat ECG signal

Normalize the loaded ECG signal

Generate artificial noise

Design high pass filter of the specifications to


retain high frequency noise (100Hz – 250Hz)

Couple high frequency noise with original signal


to obtain corrupted signal

Design low pass various IIR & FIR filters to


remove high frequency noise

Create quantized filter

Set CoefficientsDataType property

Set PersistentMemory graphic property

Select filter structure

Examine SNR & MSE for each order (Hit & trial)

Select optimal order digital filter with maximum


SNR & minimum MSE

Perform validation of optimal order digital filter


based on PSD & FFT

Analyze hardware complexity of optimal


order digital filters

End

Figure 3.5 Design steps to select optimal order digital filters

60 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Step 5: The high frequency noise is coupled with original signal to obtain a corrupted
noisy signal „x1‟ (Figure 3.6).

Figure 3.6 Noisy ECG signal (addition of high frequency noise)


Step 6: Low pass IIR and FIR filters are designed using standard MATLAB in built
functions to remove the high frequency artificially generated noise, with the basic
following specifications.
(i) Cutoff frequency = 100Hz (0.2 Normalized)
(ii) Sampling frequency = 1000 Hz
(iii) Pass band ripple = 1dB
(iv) Stop band attenuation = 60 dB
(v) N= order of filter.
Step 7: The quantized filter is created, by setting the designed filter object Hd to fixed-
point mode using Hd. Arithmetic= „fixed‟.
Step8: In the fixed-point filter, to minimize the hardware used in, the
CoefficientsDataType property is set to 16 bit word length for the coefficients in
MATLAB.
Step9: PersistentMemory graphic property of the filter object Hd is set to „true‟ using
set command, to use nonzero initial conditions for Hd. When it is false (default), the
initial conditions for the filter are set to zero.
Step10: Filter structure is selected to implement the filters. By default, FIR filters use
direct-form structure and IIR filters use direct-form II filters with Second Order
Section (SOS).
Step11: The evaluation parameters are examined in MATLAB, based on mean square
error (MSE) and signal to noise ratio (SNR) for each order. The filter with maximum
SNR and minimum MSE is selected as an optimal order filter.

61 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Step12: The performances of the optimal order digital filters are validated visually,
based on Power Spectral Density (PSD) and Fast Fourier Transform (FFT).
Step13: The hardware complexity of IIR and FIR filters is analyzed in terms of
number of multipliers, adders and states (delays). The task is accomplished using
Realize Model in FDATool for a given specification.

3.3 SIMULATION STUDY

MATLAB based simulation provides qualitative analysis for performance of


different filters. The following section presents MATLAB simulation results of the
digital filters used for denoising the ECG signal based on evaluation parameters SNR,
error and accuracy using Wavelet toolbox.The original and filtered ECG signals were
imported into wavelet toolbox and the statistical parameters of the signals were
examined in terms of mean, median and standard deviation. The statistics of the
original signal and noisy signal are depicted in Figures (3.7 and 3.8) respectively.

Figure 3.7 Statistics of original signal

Figure 3.8 Statistics of noisy signal

62 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

3.3.1 Results of Low Pass IIR Digital Filters Using Wavelet Toolbox

This sub-section presents the comparative analysis of the performance of


various IIR filter techniques for de-noising of ECG signal.

A. Butterworth Filter

Most commonly used digital filter for motion analysis is Butterworth filter,
which is fast and simple because of frequency based filtering. This filter is designed to
have as flat a frequency response as possible in the pass band and rolls off towards
zero in stop band. This filter has a slower roll-off unlike the Chebyshev filter which
has steeper roll-off, and so, requires higher order to implement a particular stop band
specification. Low pass Butterworth filter is designed by the command [b,a]=butter
(N, wn,'low') having sample frequency of 500Hz and order 10 to get desired result.
The filtered signal along with its statistical parameters is shown in Figures (3.9 and
3.10).

Figure 3.9 Output of Butterworth filter

Figure3.10 Statistics of filtered signal (Butterworth filter)


63 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

B. Elliptic Filter
Chebyshev filter obtains better selectivity than Butterworth filter by allowing
ripples in the pass band. The performance of Elliptic filter is further improved by
having equiripple frequency responses in both the pass band and the stop band as
compared to Chebyshev filters. Elliptic filter is designed with sampling frequency 500
Hz with MATLAB command [b, a] = ellip (N, Rp, Rs, Wn, 'ftype') of order 3to get
desired result. The required minimum order of a digital elliptic filter can be
determined with [N, Wn] = ellipord (Wp, Ws, Rp, Rs). Elliptic filtered signal and its
statistical results are shown in Figures (3.11 and 3.12).

Figure 3.11 Output of Elliptic filter

Figure 3.12 Statistics of filtered signal (Elliptic filter)

64 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

C. Chebyshev-I Filter
The Chebyshev response is a mathematical strategy for achieving a faster roll-
off allowing ripple in the frequency response. Analog and digital filters using this
approach are called Chebyshev filters. There are two types of Chebyshev filters.
Chebyshev-I low pass filter has an all-pole transfer function having gain equiripple in
the passband and monotonically decreasing in the stopband. A Chebyshev-II low pass
filter has both poles and zeros, its passband is monotonically decreasing, and it has
equiripple stop band. Chebyshev-I filter is designed with the MATLAB command
[b,a]=cheby1(N,Rp,Wn,'ftype') with sampling frequency 500Hz. The minimum order
of Chebyshev-I required to achieve a given set of specifications can be determined
with [N,Wn]=cheb1ord (Wp,Ws,Rp,Rs). A Chebyshev-I filtered signal and its
statistical parameters are shown in Figures (3.13 and 3.14).

Figure 3.13 Output of Chebyshev-I filter

Figure 3.14 Statistics of filtered signal (Chebyshev-I filter)

65 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

D. Chebyshev-II Filter

The Chebyshev- II filter response is often referred to as the Inverse Chebyshev


response. The gain of a Chebyshev-II filter has a monotonically varying gain in the
pass band and is equiripple in the stop band. Chebyshev-II filter is designed with the
MATLAB command [b,a]=cheby2 (N,Rs,Wn,'ftype') with sampling frequency 500Hz,
The minimum order of digital Chebyshev-II required to achieve a given set of
specifications can be determined with [N,Wn]=cheb2ord (Wp,Ws,Rp,Rs). A
Chebyshev-II filtered signal and its statistical parameters are shown in Figures (3.15
and 3.16).

Figure 3.15 Output of Chebyshev-II filter

Figure 3.16 Statistics of filtered signal (Chebyshev-II filter)

66 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

The parametric evaluation of SNR, error and accuracy based on the mean, median and
standard deviation of all the low pass IIR filters has been calculated using Eqns. (3.1 to
3.3) and given in Table 3.1.
Table 3.1 Parametric evaluation of original and filtered signal of various low pass IIR digital filters

Evaluation Original Filtered Signal


Parameter Signal Butterworth Elliptic Chebyshev-I Chebyshev-II
Mean 960 960.1 381.2 381.2 960.1
Median 955 957.3 378.6 378.5 957
Std. Deviation 33.05 19.58 19.13 19.13 25.93

Signal to Noise Ratio 39.03 25.13 25.15 37.02


Error (%) 32.39 33.78 33.81 23.83
Accuracy (%) 57.5 56.21 56.18 76.15

3.3.2 Results of Low Pass FIR Digital Filters Using Wavelet Toolbox

The effects of various FIR filter techniques for de-noising of ECG signal are
as follows:

A. Hamming Window

The Hamming Window provides good side lobe attenuation as compared to


rectangular Window. The Window is optimised to minimize the maximum side lobe,
giving it a height about one-fifth that of the Hanning Window. The filter with
Hamming Window is designed with MATLAB command fir1 and order of 23. A
Hamming Window filtered signal and its statistical parameters are shown in Figures
(3.17 and 3.18).

Figure3.17 Output of Hamming Window

67 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.18 Statistics of filtered signal (Hamming Window)

B. Rectangular Window

The Rectangular Window provides smallest main lobe width but also gives the
highest peak of side lobe. Therefore, Rectangular Window is not widely used in
digital signal processing applications.

Figure 3.19 Output of Rectangular Window

Figure 3.20 Statistics of filtered signal (Rectangular Window)

68 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

FIR filter with Rectangular window is designed in MATLAB using command fir1 of
order 10. A Rectangular window filtered signal and its statistical parameters are shown
in Figures (3.19 and 3.20).

C. Zero Phase Low Pass Filter

Zero phase filtering retains the features in the filtered signal as those featured in
the original signal along with reduced noise of the signal. In case of ECG signal, it
preserves the QRS complex.Zero-phase digital filtering is implemented in MATLAB
using command y=filtfilt (b,a,x). Filtfilt function minimizes starting and ending
transients by comparing initial conditions. A Zero phase low pass filtered signal and
its statistical parameters are shown in Figures (3.21 and 3.22).

Figure 3.21 Output of Zero phase filter

Figure 3.22 Statistics of filtered signal (Zero phase filter)

69 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

The parametric evaluation of SNR, error and accuracy of the low pass FIR filters
using Window technique based on the mean, median and standard deviation has been
calculated using Eqns. (3.1 to 3.3) and given in Table 3.2.

Table 3.2 Parametric evaluation of original and filtered signal of low pass FIR digital filters

Evaluation Original Filtered Signal


Parameter Signal Hamming Rectangular Zero phase filter
Mean 960 956.9 958.8 853.3
Median 955 955 955.5 839.2
Std. Deviation 33.05 63.32 38.6 33.19

Signal to Noise Ratio 13.87 23.83 23.98


Error (%) 88.89 13.36 0.311
Accuracy (%) 11.10 86.63 99.58

SNR
60

50

40

30

20
SNR
10

0
Butterworth Elliptic Filter Chebyshev Chebyshev Hamming Rectangular Zero phase
filter type-I type-II window window filtering

Figure 3.23 Comparison of SNR of different filtering techniques

120.00%

100.00%

80.00%

60.00%
Error

40.00% Accuracy

20.00%

0.00%
Butterworth Elliptic Filter Chebyshev Chebyshev Hamming Rectangular Zero phase
filter type-I type-II window window filtering

Figure 3.24 Comparison of error and accuracy of different filtering techniques

70 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

The graphical charts as shown in Figures (3.23 and 3.24) give a glance of how SNR,
error and accuracy varies for different IIR and FIR filters. However, wavelet toolbox is
tedious to find the optimal order filter for denoising ECG signal. So, coding is done in
MATLAB to further analyze the parameters for selection of optimal order digital filter.

3.3.3 Results of Low Pass Optimal Order IIR Digital Filters

The following sub-section presents the MATLAB simulation results for the
selection of the optimal order IIR filters based on SNR and MSE by calculating them
using Eqns. (3.1 and 3.4) in MATLAB as shown in Table 3.3 and graph in Figure
3.25.The performances of the optimal order digital filters are validated visually using
PSD and FFT. The structural realization of the optimal order filters is also presented.
1 𝑁
𝑀𝑆𝐸 = 𝑁 𝑖=1(𝑥 − 𝑦)2 (3.4)

where “N” is the length of the ECG signal.


IIR filter consists of forward path as well as feedback path, both contributing to the
output. A way to express an IIR filter is a Z-transfer function with numerator
coefficients and denominator coefficients (Dixit and Gupta 2012). Each output sample
is a sum of a new input and earlier input values and subtraction of previous values, all
multiplied by their respective coefficients. Computationally, feedback subtraction
equals to addition with inverted coefficient values. Based on the equation of digital
filters, a basic block diagram is drawn (Bokde and Choudhary 2015). In Direct form-
II, the poles of transfer function H(Z) are realized first followed by the zeros
second.Moreover, it is easier to analyze the noise region of a signal by plotting it in the
frequency domain i. e. amplitude spectrum (FFT) and PSD.

Table 3.3 Selection of optimal order IIR digital filters


Order Butterworth Chebyshev-I Chebyshev-II Elliptic
(N)
SNR MSE SNR MSE SNR MSE SNR MSE

1 -1.2323 0.1997 -6.1372 0.6192 0.0031 0.1522 -6.1372 0.6192

2 7.1573 0.0289 6.5615 0.0333 2.9633 0.0760 6.6173 0.0329

3 10.2507 0.0289 10.2193 0.0133 9.2392 0.0179 10.3936 0.0137

5 9.8850 0.0153 8.5689 0.0370 10.1903 0.0133 9.2665 0.0178

7 8.6791 0.0203 6.0937 0.0370 5.7306 0.0301 8.2508 0.0225

10 6.2697 0.0355 3.3330 0.0531 -0.0681 0.1527 8.8576 0.0197

71 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.25 Selection of optimal order IIR digital filters

A. Butterworth Filter
The task of filtration of noisy ECG signal with this technique is evaluated by
calculating SNR and MSE in MATLAB. It is observed from Table 3.5, that for each
filter, as the order (N) increases, the SNR increases with decreasing MSE, it means
performance of filter increases with rising complexity of filter structure. Table 3.3
shows that the optimal order of the Butterworth filter, at which the SNR is 9.8850
(maximum) and MSE is 0.0153 (minimum) is N = 5. Further increasing the order
beyond 5, the MSE increases thereby reversing the results. Comparing both the
parameters order in order of N=5 & 7 along with visual inspections, the order N= 5
gives the best result.
The waveform of denoised signal after filtering with Butterworth filter is shown in
Figure 3.26. The graphs of PSD and FFT of original ECG (x), noisy ECG signal (x1)
and Butterworth filtered signal (y) for best order N=5 are shown in Figures (3.27 and
3.28).

Figure 3.26 Butterworth filtered signal (N=5)

72 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.27 PSD of original, noisy and Butterworth filtered ECG signal (N=5)

Figure 3.28 Amplitude spectrum of Butterworth filter for N=5 (FFT)

From Figure 3.27, it is clearly seen that the noisy signal has more power beyond the
frequency of 100 Hz unlike the original signal. PSD of Butterworth signal shows that
power before filtration exhibits -38.7dB at 100Hz and after filtration it removes high
frequency noise and power at 100 Hz is -44.42 dB which further drops to -72.85dB
beyond 100 Hz. The results indicate that the higher frequency noise is removed,
which agrees well with the study by Chavan et al.(2008).
The task is further accomplished using Realize Model in FDATool as shown in
Figure 3.29 to analyze the hardware complexity of the Butterworth filter. With the
help of these basic building block elements (multipliers, adders and delays) a signal
flow diagram is generated, which can be used to write an algorithm and implement in
the digital computer. This information helps in determining the implementation cost of
the filters.

73 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.29 Filter structure realization

Figure 3.30 (a) Structure of Butterworth filter (N=5)

Figure 3.30 (b) Structure of subsystem of Butterworth filter

74 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.30(c) Structure of subsystem1 of Butterworth filter

Figure 3.30(d) Structure of subsystem2 of Butterworth filter

Figure 3.31 Structure information of Butterworth filter

Figure 3.30 (a), (b), (c) and (d) present the structure realization of Butterworth filter
(N=5) in terms of adders, multipliers and delays. Figure 3.31 gives structure
information report which shows Direct form-II, SOS (second-order section) filter

75 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

structure of order N and length of filter is M assuming M=N with (i) number of
multipliers (M+N+1): 10 (ii) number of adder (M+N): 10 (iii) number of states
(delays) (max (M, N): 5 (iv) number of section: 3. (www.ee.cityu.edu.hk and Proakis
2007)

B. Chebyshev-I Filter

Table 3.3, shows that the optimal order for Chebyshev-I where N=3 gives
desirable results i.e. maximum SNR (10.2193) and minimum MSE (0.0133), which is
used for further research. Figure 3.32 shows the waveform of denoised signal after
filtering.

Figure 3.32 Chebyshev-I filtered signal (N=3)

Figure 3.33 PSD of original, noisy and Chebyshev-I filtered ECG signal (N=3)

The graphs of PSD and FFT in MATLAB are shown in Figures (3.33 and 3.34). PSD
shows that beyond 100Hz the contamination of noise is prominent. The noisy signal
has more power beyond the frequency of 100 Hz unlike the original signal. The power
of signal before and after filtration exhibits -38.7dB and -41.74 dB at 100Hz

76 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

respectively and further drops to -74.54 dB beyond 100 Hz indicating the removal of
high frequency noise.Structure realization of Chebyshev-I filter using MATLAB is
depicted in Figure 3.35 (a), (b) and (c).

Figure 3.34 Amplitude spectrum of Chebyshev-I filter for N=3 (FFT)

Figure 3.35 (a) Structure of Chebyshev-I filter (N=3)

Figure 3.35 (b) Structure of subsystem of Chebyshev-I filter

Figure 3.35(c) Structure of subsystem1 of Chebyshev-I filter

77 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.36 Structure information of Chebyshev- I filter

Figure 3.36, gives structure information report of Chebyshev-I filter which shows
Direct form-II, SOS (second-order section) filter structure of order N and length of
filter M=N with (i) number of multipliers (M+N+1): 6 (ii) number of adder (M+N): 6
(iii) number of states (delays) (N): 3 (iv) number of section: 2.

C. Chebyshev-II Filter

Table 3.3, shows that the optimal order for Chebyshev-II where N=5 gives best
filtration results i.e. maximum SNR (10.1903) and minimum MSE (0.0133). The
filtered signal of Chebyshev-II filter is shown in Figure3.37.

Figure 3.37 Chebyshev-II filtered signal (N=5)

78 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

The graphs of PSD and FFT after applying to Chebyshev-II IIR filter are shown in
Figures (3.38 and 3.39).It is clearly seen that the noisy signal has more power beyond
the frequency of 100 Hz. PSD of Chebyshev-II filtered signal shows that frequency
spectrum of signal before and after filtration exhibits -38.7dB and -40.68 dB
respectively at 100 Hz and further drops to -76.05 dB beyond 100 Hz indication the
removal of high frequency noise.

Figure 3.38 PSD of original, noisy and Chebyshev-II filtered ECG signal (N=5)

Figure 3.39 Amplitude spectrum of Chebyshev-II filter for N=5 (FFT)

Figure 3.40 (a), (b), (c) and (d) shows structure realization of filter. Figure 3.41shows
structure information report of Chebyshev-II filter which shows Direct form-II, SOS
(second-order section) filter structure of order N and length of filter is M=N with (i)
number of multipliers (M+N+1) : 10 (ii) number of adder (M+N) : 10 (iii) number of
states (delays) (N) : 5 (iv) number of section : 3.

79 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.40 (a) Structure of Chebyshev-II filter (N=5)

Figure 3.40 (b) Structure of subsystem of Chebyshev-II filter

Figure 3.40 (c) Structure of subsystem1 of Chebyshev-II filter

Figure 3.40 (d) Structure of subsystem2 of Chebyshev-II filter

80 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.41 Structure information of Chebyshev-II filter

D. Elliptic Filter

Table 3.3, shows that the optimal order for Elliptic Filter where N=3, gives a
desirable results i.e. maximum SNR (10.3936) and minimum MSE (0.0137). Figure
3.42 shows the waveform of denoised signal after filtering. The graphs of PSD and
FFT are shown in Figures (3.43 and 3.44) which clearly shows that the noisy signal
has more power beyond the frequency of 100 Hz unlike the original signal. PSD of
Elliptic filter shows that power before and after filtration exhibits -38.7dB and -41.72
dB at 100Hz which further drops to -72.32 dB beyond 100 Hz indicating removal of
high frequency noise.

Figure 3.42 Elliptic filtered signal (N=3)

81 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.43 PSD of original, noisy and Elliptic filtered ECG signal (N=3)

Figure 3.44 Amplitude spectrum of Elliptic filter for N=3 (FFT)

The structure realization of Elliptic filter shows in Figure 3.45(a), (b) and (c).
Structure information report of Elliptic filter is given in Figure 3.46 which shows
Direct form-II, SOS (second-order section) filter structure of order N and length of
filter is M=N with (i) number of multipliers (M+N+1): 6 (ii) number of adder
(M+N):6 (iii) number of states (delays) (N) : 3 (iv) number of section : 2.

Figure 3.45 (a) Structure of Elliptic filter (N=3)

82 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.45 (b) Structure of subsystem of Elliptic filter

Figure 3.45 (c) Structure of subsystem1 of Elliptic filter

Figure 3.46 Structure information of Elliptic filter

83 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Summary of number of basic elements for all optimal order IIR filters is shown in
Table 3.4

Table 3.4 Summary of IIR digital filters structure information

SN Type of Order Multiplier Adder States Multiplication Addition Per


Filter Per Input sample Input Sample
1 Butterworth 5 10 10 5 10 10

2 Chebyshev-I 3 6 6 3 6 6

3 Chebyshev-II 5 10 10 5 10 10

3 Elliptic 3 6 6 3 6 6

The primary advantage of IIR filters over FIR filters is that they typically
serve the purpose of filtration for a given set of specifications with a much lower order
than a corresponding FIR filter. Study of IIR filters shows that Chebyshev-I, II and
Elliptic filter perform good role in denoising ECG signal at order N = 3, 5 and 3
respectively having almost same noise power of filtered signal at 100Hz. In case of
Butterworth filter noise removal is not good as compared to others.

3.3.4 Results of Low Pass Optimal Order FIR Digital Filters

The following sub-section presents the MATLAB simulation results for the
selection of the optimal order FIR filters based on SNR and MSE by calculating them
using Eqns. (3.1 and 3.4) in MATLAB as shown in Table 3.5 and graph in Figure
3.47.The performances of the optimal order digital filters are validated visually using
PSD and FFT. The structural realization of the optimal order filters is also presented.
Moreover, it is easier to analyze the noise region of a signal by plotting it in the
frequency domain i. e. amplitude spectrum (FFT) and PSD.
„N‟ is the order of the filter which specifies the highest power in Z-transform
representation of FIR filter. Also it represents number of zeros of Z polynomial,
M=N+1 is length of filter which specifies number of impulse response sample in FIR
filter. If the filter underestimates the order N, then it doesn‟t meet the specifications;
therefore, trying a higher order such as N+1, N+2 and so on to meet the specifications
(www. mathworks.com).

84 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Table 3.5 Selection of optimal order FIR digital filters using Window technique
Order Kaiser Hamming Hanning Bartlett
(N)
SNR MSE SNR MSE SNR MSE SNR MSE

2 -3.7366 0.3563 -13.6820 3.5098 -5.6768 5.5560 -5.6768 5.5560

3 0.0609 0.1383 3.5098 0.7339 -8.8333 1.1395 -8.8333 1.1395

5 3.7786 0.0500 0.1535 0.1351 -1.5991 0.2173 0.3062 0.1369

7 9.8263 0.0157 5.9050 0.0386 3.7823 0.0500 6.5023 0.0337

10 9.8217 0.0157 9.1201 0.0183 8.8116 0.0198 7.6927 0.0256

15 6.9332 0.0303 8.0661 0.0235 8.0593 0.0235 7.8513 0.0237

20 6.0528 0.0373 6.3319 0.0350 6.3329 0.0339 6.0825 0.0371

25 3.3997 0.0533 3.6225 0.0519 3.6167 0.0519 3.5609 0.0526

Figure 3.47 Selection of optimal order FIR digital filters

A. Kaiser Window

Kaiser Window for designing FIR filter is a flexible window and widely
used for spectrum analysis. The Kaiser Window function uses a ripple parameter, β
which allows the designer to trade-off the transition width against ripple, which is
considered at β=3 (default is 0.5) in this study. As beta increases, width of main lobe
increases while decreasing the amplitude of the side lobes (i.e. increases the
attenuation).Table 3.5suggests, the optimal order for Kaiser Window is at N=10 as

85 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

shown by shaded portion. The waveform of denoised signal after filtering is shown in
Figure 3.48.

Figure 3.48 Kaiser Window filtered signal (N=10)

Figure 3.49 PSD of original, noisy and Kaiser Window filtered ECG signal (N=10)

Figure 3.50 Amplitude spectrum of Kaiser Window filter for N=10 (FFT)

86 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.51 Structure of Kaiser Window (N=10)

87 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.52 Structure information of Kaiser Window

From Figure3.49, it is clearly seen that the PSD of Kaiser Window filtered signal at
100 Hz is -41.01 dB, which further drops to -65.77 dB indicating the removal of the
high frequency components.The graph of FFT is shown in Figure 3.50.
The direct form structure for N order low pass FIR filter consists of N shift
registers and adders;N+1multipliers(Sharma and Dalal2014). It is the most common
structure used to realize non-recursive filters. Based on the equation of FIR filter, a
block diagram using basic elements is generated as shown in Figure 3.51 suggesting
the requirements of multipliers, adders and registers for realization. Figure 3.52 gives
structure information report which shows Direct form filter structure of order N and
length of filter is M=N+1 with (i) number of multipliers (N+1) : 11 (ii) number of
adder (N): 10 (iii) number of states (delays) (N): 10 (iv) filter length: 11
(www.ee.cityu.edu.hk; Proakis 2007).

B. Hamming Window

Hamming Window provides good side lobe attenuation as compared to


rectangular window. The Window is optimised to minimise the maximum side lobe,
giving it a height about one-fifth that of the Rectangular Window. The waveform of
filtered Hamming Window signal is shown in Figure 3.53. Hamming Window gives
better results at N=10 which is depicted in Table 3.5 by the shaded portion. From
Figure 3.54, it is clearly seen that the PSD of Hamming Window filtered signal at 100
Hz is -46.86 dB, which further drops to -73.46 dB indicating the removal of the high
frequency components.

88 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.53Hamming Window filtered signal (N=10)

Figure 3.54 PSD original, noisy and Hamming Window filtered ECG signal (N=10)

Figure 3.55 Amplitude spectrum of Hamming Window filter for N=10 (FFT)

89 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

The graph of FFT is shown in Figure 3.55. The structure of Hamming Window (N=10)
in terms of adders, multipliers and delays is presented in Figure 3.56. Figure 3.57
gives summary of structure information report which shows Direct form filter
structure of order N and length of filter is M=N+1 with (i) number of multipliers
(N+1): 11 (ii) number of adder (N): 10 (iii) number of states (delays): 10 (iv) filter
length: 11.

Figure 3.56 Structure of Hamming Window (N=10)

90 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.57 Structure Information of Hamming Window (N=10)

C. Hanning Window

Hanning Window gives better results at N=10 which is depicted in Table


3.5 by the shaded portion. The waveform of Hanning Window filtered signal is shown
in Figure 3.58.

Figure 3.58 Hanning Window Filtered signal (N=10)

Figure 3.59 PSD of original, noisy and Hanning Window filtered ECG signal (N=10)

91 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

From Figure 3.59, it is clearly seen that the PSD of Hanning Window filtered signal at
100 Hz is -44.89 dB, which further drops to -80.08 dB indicating the removal of the
high frequency components. The graph of FFT is shown in Figure 3.60.

Figure 3.60Amplitude spectrum of Hanning Window filter for N=10 (FFT)

Figure 3.61 Structure of Hanning Window (N=10)

92 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.61 presents the structure of Hamming Window (N=10) in terms of adders,
multipliers and delays. Summary of structure information report gives in Figure 3.62
which shows Direct form filter structure of order N and length of filter is
M=N+1with (i) number of multipliers (N+1) : 9 (ii) number of adder (N): 8 (iii)
number of states (delays) : 10 (iv) filter length : 11. As per the structure realization, the
Hanning Window should have N adder i.e. 10; N+1 multiplier i.e. 11, against 8 adders
and 9 multipliers as per the summary, but a slightly changed in shape of the filtered
signal waveform.

Figure 3.62 Structure information of Hanning Window

D. Bartlett Window

Bartlett Window gives better results at N=15 which is depicted in Table 3.5
by the shaded portion. The waveform of Bartlett Window filtered signal is shown in
Figure 3.63.

Figure 3.63 Bartlett Window filtered signal (N=15)

93 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

From Figure 3.64, it is clearly seen that the PSD of Bartlett Window filtered signal at
100 Hz is -46.89 dB, which further drops to -76.56 dB indicating the removal of the
high frequency components. The graph of FFT is shown in Figure 3.65.

Figure 3.64 PSD of original, noisy and Bartlett Window filtered ECG signal (N=15)

Figure 3.65 Amplitude spectrum of Bartlett Window filter for N=15 (FFT)

94 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.66 Structure of Bartlett Window (N=15)

95 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

Figure 3.67 Structure information of Bartlett Window

Figure 3.66 presents the structure of Bartlett Window (N=15) in terms of adders,
multipliers and delays. Summary of structure information report (Figure 3.67) which
shows Direct form filter structure of order N and length of filter is M=N+1 with (i)
number of multipliers (N+1) : 14 (ii) number of adder (N): 13 (iii) number of states
(delays): 15 (iv) filter length:16. As per the structure realization, the Bartlett Window
should haveN+1 multipliers i.e. 16 and N adders i.e. 15 against 14 multipliers and 13
adders as represented in the summary and less SNR and high MSE (Table 3.5) as
compared to other window techniques. The summary of filter structure elements of
FIR filters with different windows is shown below in Table 3.6.

Table 3.6 Summary of FIR digital filters structure information

S.N. Type of Window Order Multiplier Adder States Filter


length
1 Kaiser 10 11 10 10 11
2 Hamming 10 11 10 10 11
3 Hanning 10 9 8 10 11
3 Bartlett 15 14 13 15 16

3.4 CRITICAL ANALYSIS

The current study used ECG signal (100m.mat) from MIT-BIH Arrhythmia
database instead of acquiring real time ECG signal. The ECG signal was artificially
corrupted with different types of noise. ECG denoising is achieved using various IIR
and FIR designed filters in MATLAB and their performance is compared based on
SNR, error and accuracy using wavelet toolbox. The objective of the research is to

96 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

implement digital filter code on FPGA platform. Since, the above technique does not
help much in selecting the optimal order digital filter and for conversion of MATLAB
code into Verilog for FPGA implementation. Therefore, the optimal order digital
filters are selected using parameters like SNR and MSE in MATLAB for denoising
only high frequency noise. It affects the QRS complex in ECG signal. The
performance of the optimal order filter is validated using PSD and FFT.It is impossible
to obtain a complete noise free ECG signal and any attempt made to remove the total
noises present, may distort the main ECG signal. Therefore, with a tolerable range of
presence of noise in the ECG signal after filtering is adequate enough for clinical
interpretations by medical experts (Zaman 2012).

3.5 CONCLUSIONS

From the simulation results of the digital filters used for denoising ECG
signal based on SNR, error and accuracy using wavelet toolbox, it is found thatthe
Butterworth filter is the best filter based on SNR (39.03) but gives a distorted filtered
ECG signal due to nonlinear phase response (Kaur et al. 2011), which causes loss of
valuable information despite having high SNR values.Zero phase filter is the best filter
based on accuracy (99.58 %).The Zero-phase low pass filter gives a much enhanced
ECG signal with better quality and preserves the shape of the ECG signal especially
the amplitudes of sharp Q, R and S peaks.But the above approach is tedious for
selection and implementation of optimal order filter for denoising ECG signal on
FPGA. To overcome this problem, an attempt has been made in MATLAB. The major
conclusions are drawn from this attempt are as follows:

(i) Various IIR and FIR digital filters are designed in MATLAB for denoising
ECG signal. By calculating SNR and MSE in MATLAB, optimal order digital filters
are selected for FPGA implementation and are validated using PSD and FFT.
(ii) The complexity of optimal order digital filters structure is also checked in
terms of multipliers, adders and delays in MATLAB and their performance is
compared based on the number of basic elements, PSD and visual inspections.
(iii) From PSD graphs and Table 3.4, it is obvious that the Chebyshev-I and
Elliptic IIR filter requires low filter order for a given specification to denoise ECG
signal hence requires less number of multiplier, adder and delays. Elliptic filter gives

97 | P a g e
Chapter-III Digital Filter Design to Denoise ECG Signal

better performance as compared to Chebyshev-I as can be seen from PSD graphs and
visual inspections.
(iv) From Table 3.6, it is seen that the Kaiser, Hamming and Hanning Window
FIR filter require low filter order for a given specification to denoise ECG signal
hence require less number of multipliers, adders and delays. Hanning Window gives
undesirable results. Kaiser Window gives better performance as compared to others as
can be seen from PSD graphs and visual inspections.

This chapter critically analyzed various IIR and FIR filters design to select the
optimal order filters. Further to study the complexity of filter design on FPGA
platform, synthesis and analysis of selected optimal order digital filter is done on
FPGA using Xilinx ISE 13.1which is discussed in the next chapter.

98 | P a g e

Das könnte Ihnen auch gefallen