Applied Biomedical Signal Processing: Filter Design and Implementation, Study notes of Electrical and Electronics Engineering

The instructions for a lab exercise in applied biomedical signal processing, focusing on filter design and implementation using matlab. Students are required to plot the frequency response of a discrete-time filter, filter a discrete-time signal, implement a filter to remove baseline wander, and implement a moving average filter. The necessary code and data files for completing the exercise.

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-x1e
koofers-user-x1e 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE-497/BME-491: Applied Biomedical Signal Processing
Laptop Day #3
Due at the end of class, December 15, 2006
Today we have the following goals
plot the frequency response of a discrete-time filter
filter a discrete-time signal
implement a filter to remove baseline wander
implement a moving average (MA) filter
At the end of class you should turn in two plots and answers to some questions.
1) Go to the class website and download the program laptop3.m and the data files ecg bn.dat
and ecg5.dat.
There are five input arguments to laptop3.m:
the name of the data file, in single quotes
the starting point (index) in the file, usually the first point in the file so this is usually a 1
the number of sample points in the file
the location of the pole in the filter used to remove the baseline wander
the order of the MA filter
2) Start Matlab, set the directly to where your program/data files are. To be sure everything is
ok, invoke the program as follows:
laptop3(0.8,21,’ecg_bn.dat’,1,3000);
If you have done everything correctly so far, it should plot the original signal.
3) We next want to implement a simple filter that will remove the baseline wander without
modifying the signal too much. In class we showed one such filter had the transfer function
H(z) = 1z1
1αz1
1 + α
2
Here αis the location of the pole we will use so the filter will (hopefully) remove the low fre-
quency components of the signal while leaving the remaining frequency components alone.
Matlab generally expects a filter to be of the form
H(z) = b1+b2z1+b3z2+... +bN+1zN
a1+a2z2+a3z2+... +aN+1zN
and to implement the filter in Matlab we enter the band acoefficients as vectors,
1
pf3

Partial preview of the text

Download Applied Biomedical Signal Processing: Filter Design and Implementation and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

ECE-497/BME-491: Applied Biomedical Signal Processing

Laptop Day

Due at the end of class, December 15, 2006

Today we have the following goals

  • plot the frequency response of a discrete-time filter
  • filter a discrete-time signal
  • implement a filter to remove baseline wander
  • implement a moving average (MA) filter

At the end of class you should turn in two plots and answers to some questions.

  1. Go to the class website and download the program laptop3.m and the data files ecg bn.dat and ecg5.dat.

There are five input arguments to laptop3.m:

  • the name of the data file, in single quotes
  • the starting point (index) in the file, usually the first point in the file so this is usually a 1
  • the number of sample points in the file
  • the location of the pole in the filter used to remove the baseline wander
  • the order of the MA filter
  1. Start Matlab, set the directly to where your program/data files are. To be sure everything is ok, invoke the program as follows:

laptop3(0.8,21,’ecg_bn.dat’,1,3000);

If you have done everything correctly so far, it should plot the original signal.

  1. We next want to implement a simple filter that will remove the baseline wander without modifying the signal too much. In class we showed one such filter had the transfer function

H(z) =

1 − z−^1 1 − αz−^1

1 + α 2

Here α is the location of the pole we will use so the filter will (hopefully) remove the low fre- quency components of the signal while leaving the remaining frequency components alone.

Matlab generally expects a filter to be of the form

H(z) =

b 1 + b 2 z−^1 + b 3 z−^2 + ... + bN +1z−N a 1 + a 2 z−^2 + a 3 z−^2 + ... + aN +1z−N

and to implement the filter in Matlab we enter the b and a coefficients as vectors,

b = [b1 b2 b3 ... bN]; a = [a1 a2 a3 ... aN];

Note that the lengths of the a and b vectors must be the same, which usually means you need to pad the a vector with zeros.

Determine the correct a and b vectors for our filter to remove baseline wander, and type it into laptop3.m. Your coefficients should be a function of the variable ‘alpha’ which is passed to the function.

  1. In order to filter the input signal using the filter coefficients we have determined, we will use the Matlab function filter, which is fairly easy to do. We just need to pass it the b and a vectors as well as the signal to be filtered. Let’s assume the signal to be filtered is an array called x and we want the filtered signal to be called p. Then we just type

p = filter(b,a,x);

Modify your Matlab code to so the input signal can be filtered using the filter you implemented in part 3. Call your filtered signal p.

  1. We also want to be able to plot the frequency response of our filter. There are many ways to do this, we will use the freqz function. For this function we pass it the a and b vectors, and it returns the frequency response (magnitude and phase) H(eiΩ) at selected frequencies Ω. Note that 0 ≤ Ω ≤ π. To use this we type

[H1,Omega1] = freqz(b,a);

Implement this in Matlab for your filter. Note that in order to convert this frequency to a real frequency we need to scale using freal = Ω π^1 f 2 s where fs is the sampling frequency and freal corresponds to the real frequency.

  1. Uncomment the plotting parts of the code at the bottom of laptop3.m, and run laptop3.m using α = 0.8 you should get plots like those shown in Figure 1. (There are more plots here that you have so far).

  2. We next need to implement the moving average filter. The input signal to this filter will be p, which was the output of our first filter, and the output of the filter will be y. The easiest way to implement this is with the Matlab code

a = zeros(1,order); a(1) = 1; b = ones(1,order)/order;

Implement this in latop3.m and put in the code to filter p to get y. Next put in code to determine the frequency response of the MA filter. Finally modify the code to plot all of the results. If you have done everything correctly you should get the same graph as in Figure 1 (if you use α = 0.8 and order = 21).