Lab 3 2023
Lab 3 2023
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
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.
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.
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.
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
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)
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
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