0% found this document useful (0 votes)
79 views

Lab 3 2023

This lab aims to design FIR and IIR filters to analyze biomedical signals like ECG, EMG, and EEG. Students will use signal processing software like MATLAB to implement digital filters and gain practical experience with biomedical signal processing techniques. FIR filters have exact linear phase response but require more coefficients, while IIR filters use fewer coefficients but have nonlinear phase response. Students will design different filter types like lowpass, highpass, bandpass and bandstop and analyze biomedical signals using the designed filters.

Uploaded by

Azlina Ramli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Lab 3 2023

This lab aims to design FIR and IIR filters to analyze biomedical signals like ECG, EMG, and EEG. Students will use signal processing software like MATLAB to implement digital filters and gain practical experience with biomedical signal processing techniques. FIR filters have exact linear phase response but require more coefficients, while IIR filters use fewer coefficients but have nonlinear phase response. Students will design different filter types like lowpass, highpass, bandpass and bandstop and analyze biomedical signals using the designed filters.

Uploaded by

Azlina Ramli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

FACULTY OF TECHNOLOGY ELECTRONIC ENGINEERING

NMJ 31303 DIGITAL SIGNAL PROCESSING IN BIOMEDICAL APPLICATION


SEMESTER 1 2022/2023

LAB 3 : DESIGN OF FINITE IMPULSE RESPONSE (FIR) FILTERS & INFINITE


IMPULSE RESPONSE (IIR) FILTERS FOR ANALYSIS OF BIOMEDICAL SIGNALS

(OPEN ENDED LAB)

LECTURER : DR LIM CHEE CHIN MARKS


:
:

REPORT [60] :
Student’s Particular:
Name
TOTAL:
Matrix No.

Programme

Group

Date of exp.

Received by :______________

Date :______________
NMJ31303 2023

Preface

This laboratory module is designed for students taking core course on NMJ 31303 Digital Signal
Processing in Biomedical Applications at the Faculty of Technology Electronic Engineering, UNIMAP.
The module is designed to provide hands on experience in processing of digital signals.

Three experiments are designed to help the students to practice writing programs using signal processing
software such as MATLAB and Octave, to implement some of the time domain, frequency domain
concepts on digital signals and design of analog and digital filters. Students are expected to have gained
adequate theoretical knowledge on each of the experiments before coming for the laboratory sessions.

At the end of the laboratory sessions the students would have acquired sufficient practical knowledge on
biomedical signal processing techniques which gives them a good foundation for further research on DSP
systems.
NMJ31303 2023

Laboratory Protocols and Instructions

1. Students should handle the Personal Computers and equipment with utmost care. Students should
not tamper the software and settings of the Personal Computer.

2. Students should be punctual to the lab sessions and should obtain prior permission from the lab
instructor before leaving the lab.

3. Students should watch through the uploaded video of lab session and have self-learning on the
experimental theory. Students should come prepared with the experimental theory for the lab and
viva sessions.

4. Students should be viva by demonstrate their exercise in software thru PC screen and interview
individually during the online lab session.

Submission of Lab Reports

1. Lab reports and video must be submitted in the same week of the lab class through Google
Classroom Assignment. Due date of submission is stated in google classroom. Late submission
will entitle reduction in marks allotted for reports.

2. All programs and theory should be handwritten / typing. Algorithms can be given as flow charts
but, must be neatly drawn in the report. Additional marks are given for neat reports.
NMJ31303 2023

Design of Finite Impulse Response (FIR) filters and Infinite Impulse Response
(IIR) for Analysis of Biomedical Signals

OBJECTIVE
To design and evaluate the efficacy of FIR and IIR filters for analyzing biomedical signals (ECG, EMG
and EEG, etc)

SOFWARE
Signal processing software such as MATLAB, Octave, Scilab and Signal Processing Toolbox

INTRODUCTION
A digital filter is a linear time invariant discrete time system. The FIR and IIR filters are of type of non-
recursive and recursive type respectively. In FIR filter design, the present output sample depends on the
present input sample and previous input samples. In IIR filter design, the present output sample depends
on the present input, past input samples and output samples. The Impulse response for realizable filter
and the stability condition must satisfy. Table 1 shows the advantages and disadvantages between two
filters.

Table 1. FIR versus IIR


FIR IIR
Advantages 1. Exact Linear Phase design 1. non-iterative manual design, using
possible standard design equations possible
2. Possible to design arbitrary- 2. For a given amplitude response
shaped frequency response. specification, generally lesser number
3. Better signal to quantization of tap coefficients are needed less
noise ratio. memory space to store tap coefficients.
4. filter is always stable

Disadvantages 1. Optimum design requires the 1. No control over phase response,


use of a computer iterative design Generally, non-linear phase response.
procedures 2. Manual design possible only for
2. For a given frequency response, standard filter characteristics: Lowpass,
more tap coefficients are generally Highpass, Bandpass and Bandstop.
needed more memory space
required to store tap coefficients.
NMJ31303 2023
Finite Impulse Response (FIR)
Difference equation of FIR filter generally appear in this form:
𝑦(𝑛) = 𝑏0 𝑥(𝑛) + 𝑏1 𝑥(𝑛 − 1) + 𝑏2 𝑥(𝑛 − 2) + ⋯ + 𝑏𝑀 𝑥(𝑛 − 𝑀)
Note that the present output 𝑦(𝑛) depends only on the present and past samples of inputs. It is not
dependent on the past output values.
present present past
output input inputs
⏞ =⏞
𝑦(𝑛) 𝑏0 𝑥(𝑛) + ⏞
𝑏1 𝑥(𝑛 − 1) + 𝑏2 𝑥(𝑛 − 2) + ⋯ + 𝑏𝑀 𝑥(𝑛 − 𝑀)
Because the present output depends on the present and past inputs, this system is called a non-recursive
system. It is obvious that the FIR filter is a subset of the more general IIR filter.

There are two types of realization structures of FIR:


1. Direct form
𝐻(𝑧) = 1 + 2𝑧 −1 − 3𝑧 −2 − 4𝑧 −3 + 5𝑧 −4

2. Cascade
5
𝐻(𝑧) = 1 + 𝑧 −1 + 2𝑧 −2 + 2𝑧 −3
2
1
𝐻(𝑧) = (1 + 2𝑧 −1 )(1 + 𝑧 −1 + 𝑧 −2 )
2
NMJ31303 2023
Infinite Impulse Response (IIR)
Difference equation of IIR filter generally appear in this form:
𝑦(𝑛) = 𝑏0 𝑥(𝑛) + 𝑏1 𝑥(𝑛 − 1) + 𝑏2 𝑥(𝑛 − 2) + ⋯ + 𝑏𝑀 𝑥(𝑛 − 𝑀) + ⋯
𝑎1 𝑦(𝑛 − 1) + 𝑎2 𝑦(𝑛 − 2) + ⋯ + 𝑎𝑁 𝑦(𝑛 − 𝑁)
Note that the present output 𝑦(𝑛) depends on not only the present and past samples of inputs, it also
depends on the past outputs.
present present past
output input inputs
⏞ =⏞
𝑦(𝑛) 𝑏0 𝑥(𝑛) + ⏞
𝑏1 𝑥(𝑛 − 1) + 𝑏2 𝑥(𝑛 − 2) + ⋯ + 𝑏𝑀 𝑥(𝑛 − 𝑀) + ⋯
𝑎1 𝑦(𝑛 − 1) + 𝑎2 𝑦(𝑛 − 2) + ⋯ + 𝑎𝑁 𝑦(𝑛 − 𝑁)

past
outputs

Because the present output depends on the past samples of outputs, this system is called a recursive system.

There are three types of realization structures of IIR:


1. Direct Form Type 1
𝒚(𝒏) = 𝒃𝟎 𝒙(𝒏) + 𝒃𝟏 𝒙(𝒏 − 𝟏) + 𝒃𝟐 𝒙(𝒏 − 𝟐) − 𝒂𝟏 𝒚(𝒏 − 𝟏) − 𝒂𝟐 𝒚(𝒏 − 𝟐)
𝒚(𝒏) + 𝒂𝟏 𝒚(𝒏 − 𝟏) + 𝒂𝟐 𝒚(𝒏 − 𝟐) = 𝒃𝟎 𝒙(𝒏) + 𝒃𝟏 𝒙(𝒏 − 𝟏) + 𝒃𝟐 𝒙(𝒏 − 𝟐)

2. Direct Form Type 2


𝒚(𝒏) = 𝒃𝟎 𝒙(𝒏) + 𝒃𝟏 𝒙(𝒏 − 𝟏) + 𝒃𝟐 𝒙(𝒏 − 𝟐) − 𝒂𝟏 𝒚(𝒏 − 𝟏) − 𝒂𝟐 𝒚(𝒏 − 𝟐)

3. Cascade
𝟏 + 𝟐𝒛−𝟏 (𝟏 + 𝟐𝒛−𝟏 ) (𝟏)
𝑯(𝒛) = =
(𝟏 + 𝟑𝒛−𝟏 )(𝟏 + 𝒛−𝟏 ) (𝟏 + 𝟑𝒛−𝟏 ) (𝟏 + 𝒛−𝟏 )
NMJ31303 2023

FUNCTIONS

Functions Description
[n,Wn] = calculates the minimum order of a digital or analog Butterworth filter
buttord(Wp,Ws,Rp,Rs) required to meet a set of filter design specifications
[n,Wp] = calculates the minimum order of a digital or analog Chebyshev Type I
cheb1ord(Wp,Ws,Rp,Rs) filter required to meet a set of filter design specifications.
[n,Ws] = calculates the minimum order of a digital or analog Chebyshev Type II
cheb2ord(Wp,Ws,Rp,Rs) filter required to meet a set of filter design specifications
[b,a] = butter(n,Wn,ftype) designs a lowpass, highpass, bandpass, or bandstop Butterworth filter,
depending on the value of ftype and the number of elements of Wn. The
resulting bandpass and bandstop designs are of order 2n.
[b,a] = designs a lowpass, highpass, bandpass, or bandstop Chebyshev Type I
cheby1(n,Rp,Wp,ftype) filter, depending on the value of ftype and the number of elements
of Wp. The resulting bandpass and bandstop designs are of order 2n.
[b,a] = designs a lowpass, highpass, bandpass, or bandstop Chebyshev Type II
cheby2(n,Rs,Ws,ftype) filter, depending on the value of ftype and the number of elements
of Ws. The resulting bandpass and bandstop designs are of order 2n
[n,Wn,beta,ftype] = finds the approximate order n and normalized frequency band
kaiserord(f,a,dev,fs) edges Wn.
‘f’ is vector of band edges that involves parameters of passband edge
and stopband edge.
‘a’ is vector specifying the desired amplitude on the bands defined by f,
typical values are 0 and 1.
‘dev’is a vector of maximum ripples in dB.
‘fs’ is sampling frequency.
b = fir1(n,Wn,ftype) designs a lowpass, highpass, bandpass, bandstop, or multiband filter,
depending on the value of ftype and the number of elements of Wn.
NMJ31303 2023
THIS LABORATORY ASSESMENT INVOLVES PART A, B AND CONCLUSION.
ALL PARTS must execute in LABORATORY and the answers must include in the
LABORATORY REPORT.
Execute in both MATLAB and Phyton programming

PART A: DESIGN IIR

Exercise 1: Estimation of order of IIR filter


Q1. Determine the lowest order of a digital IIR lowpass filter of Butterworth, Chebyshev Type 1 and
Chebyshev Type 2. The specifications are as follows:
Sampling rate = 40kHz Passband ripple = 0.5 dB
Passband edge frequency = 4kHz Minimum stopband attenuation = 40 dB.
Stopband edge frequency = 8kHz
Describe your results.
(4 Marks)

Q2. Determine the lowest order of a digital IIR bandpass filter of Butterworth, Chebyshev Type 1 and
Chebyshev Type 2. The specifications are as follows:
Sampling rate = 7kHz Passband ripple = 0.4 dB
Passband edge frequency = 1.4kHz and 2.1kHz Minimum stopband attenuation = 45 dB.
Stopband edge frequency = 1.05kHz and 2.45kHz
Describe your results.
(4 Marks)

Exercise 2: IIR filter design


Q1. Complete the magnitude response/gain response computation program below based on transfer function
of numerator and denominator in decibel (dB).

function [g,w]=gain(num,den)
%compute of magnitude response/ gain function in dB of a transfer function at 256 equally spaced points
%on the top half of the unit circle
%numerator = num; %denominator = den
%frequency values are returned in vector w
%gain values are returned in vector g
w=0:pi/255:pi;
h=freqz(num,den,w);
g=
(2 Marks)
NMJ31303 2023

Q2. Design the Butterworth bandstop filter based on the steps below with the given specifications.
Shows all the transfer function coefficients and write down the exact expression for the transfer function
generated. Does your design MEET the specifications?

The Steps:
Initialize specifications
Estimate the filter order
Design the filter
Display the transfer function
Compute the gain response
Plot the gain response for x-axis is 𝝎/𝝅 and y-
axis is Gain in dB

The specifications:
Passband edge frequency = 0.2 and 0.8
Stopband edge frequency = 0.4 and 0.6
Passband ripple = 0.4 dB
Stopband ripple = 50 dB
Sampling frequency = 2kHz

(10 Marks)
NMJ31303 2023

PART B: DESIGN FIR

Exercise 1: Estimation of order of FIR filter


Q1. Using appropriate function, estimate the order of a linear-phase lowpass FIR filter with the following
specifications:
Passband edge = 2kHz Passband ripple = 0.005
Stopband edge = 2.5kHz Stopband ripple = 0.005
Sampling rate = 10kHz.
(2 Marks)

Exercise 2: FIR filter design


Q1. Using the function fir1, design a linear phase FIR lowpass filter meeting with these specifications:
Passband edge = 2kHz Passband ripple = 0.005
Stopband edge = 2.5kHz Stopband ripple = 0.005
Sampling rate = 10kHz.
and plot its gain and phase responses. Show the filter coefficients in tabular form. Does your design meet
the specifications? If it does not, adjust the filter order until the design meets the specifications. What is
the order of the filter meeting the specifications?
(10 Marks)

Q2. Repeat Q1 using following windows: Hanning and Blackman.


(8 Marks)

Exercise 3:
Write a MATLAB program to design FIR bandpass filters
Length of the Filter = 51. http://kdd.ics.uci.edu/databases/eeg/eeg.full.html
This data arises from a large study to examine EEG correlates of genetic predisposition to alcoholism. It
contains measurements from 64 electrodes placed on the scalp sampled at 256 Hz. Download EEG signal
of subject 1(alcoholic) and subject1 (Normal). Consider the following 5 different frequency bands, delta
(0-4Hz), theta (4-8Hz), alpha (8-16Hz), beta (16- 32Hz) and gamma (32¨C 64Hz). Compute and tabulate
the mean, minimum, maximum, average, standard deviation, variance, energy and power of the filtered
signal of Normal and alcoholic subjects.
(15 Marks)

CONCLUSION
(5 Marks)
NMJ31303 2023

REFERENCES

[1] S.K. Mitra, ‘Digital Signal Processing: A Computer Based Approach’, Tata McGraw Hill, 2006.

[2] E.C. Ifeachor and B.W. Jervis, ‘Digital Signal Processing: A Practical Approach’ Prentice Hall,
Second Edition 2002

[3] Richard G. Lyons, ‘Understanding Digital Signal Processing’, Prentice Hall, Second Edition, 2004.

[4] J. G. Proakis and D. G. Manolakis, ‘Digital Signal Processing: Principles, Algorithms and
Applications’, 1989.

[5] www.mathworks.com

You might also like