0% found this document useful (0 votes)
8 views17 pages

Lec 49

The tutorial discusses the application of Butterworth low pass filters to clean noisy ECG signals sampled at 1000 Hz. It compares four filter configurations with varying cutoff frequencies and orders, assessing their effectiveness in preserving the ECG signal while suppressing high-frequency noise. The optimal filter configuration identified was an order of 8 with a cutoff frequency of 40 Hz, which provided the best signal-to-noise ratio (SNR) and output quality compared to synchronous averaging.

Uploaded by

Ram Dangi
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)
8 views17 pages

Lec 49

The tutorial discusses the application of Butterworth low pass filters to clean noisy ECG signals sampled at 1000 Hz. It compares four filter configurations with varying cutoff frequencies and orders, assessing their effectiveness in preserving the ECG signal while suppressing high-frequency noise. The optimal filter configuration identified was an order of 8 with a cutoff frequency of 40 Hz, which provided the best signal-to-noise ratio (SNR) and output quality compared to synchronous averaging.

Uploaded by

Ram Dangi
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/ 17

Biomedical Signal Processing

Prof. Sudipta Mukhopadhyay


Department of Electrical and Electronics Communication Engineering
Indian Institute of Technology, Kharagpur

Lecture - 49
Tutorial - I (Contd.)

So, now we are going for the third problem of the tutorial one. So, here the problem is that
again we have the noisy signal that is ECG sampled at 1000 hertz and we are trying with
Butterworth filter low pass filter to actually remove the high frequency noise. We have here
four different options, we look at the different options. The first option is order two cut off
frequency 10 hertz; that means, order is low that means, it will have a smooth transition and
cut off frequency is also very low.

(Refer Slide Time: 01:04)

Second is we have model order increase to 8 and that the cut off frequency is also increased
to 20, then keeping the model order same cut off frequency increased to 40, then 70. So, cut
off frequency is increase means in a low pass filter that we are allowing more and more high
frequency part. So, we have to see that how it helps to preserve the signal component, that is,
ECG signal in hand and how it is successful in blocking the high frequency noise ok. So, that
is the task at hand.
(Refer Slide Time: 02:00)

So, the next instruction is to compare the results using each of the 4 Butterworth filters
individually with those obtained by synchronous averaging. The synchronized averaging is
been taken as a gold standard in this case and for that we would like to see that how we can
actually get the output ok.

Next is we would compute the signal to noise ratio that is SNR. It compute the SNR here of
the above cases considering the best output as the reference signal. So, we will take out of the
4 cases, the best one as the reference with respect to that will compute the SNR ok.
(Refer Slide Time: 03:08)

So, the first is we need to get the signal; so for that, we have the signal given here and here
we have got the code now. Again we remind you that we need to keep the input signal and the
MATLAB code in the same directory . So, with that we proceed.

(Refer Slide Time: 03:53)

So, now the first thing as a part of the solution is to look at the basic structure of the
Butterworth filter ok.
So, Butterworth filter of order n here is the formula, we are getting the magnitude in the
frequency domain of the signal for a nth order filter. So, low pass filter we get and we make
use of actually MATLAB to get the help of it to compute the Butterworth filter and that
makes the task easy for us.

(Refer Slide Time: 04:54)

So, first we need to look at the input signal with high frequency noise. So, we know now by
now we know the game that what we have do first we need to load the signal in a variable.
Here that variable is ‘x’, then we need to note down that frequency of sampling ‘fs’, then take
the length of the signal that means how many samples are there in that signal and with respect
to that we can actually calculate the time axis ok.

How do we do that we compute the number of samples. So, it will look like a ramp, the index
is increasing and multiply with one by sampling frequency, one by sampling frequency will
give us the sampling interval and then we create a pane, by this figure command and then
issue the command for plot. So, we get this plot here with sufficient amount of high
frequency noise. So, this is the signal we need to clean with the Butterworth filter or low pass
Butterworth filter.
(Refer Slide Time: 06:24)

So, let us proceed towards it. So, first let us see how the magnitude and the phase response of
the Butterworth filter looks like ok. So, we have the advantage of MATLAB, it is already
implemented. So, to use that we need to keep few things in mind that we need the sampling
frequency that is one variable. Next is the cut off frequency, the first choice was that the cut
off frequency should be set to 10 hertz. So, we set ‘fc’ the cut off frequency variable as 10
and the model order should be 2. So, we have taken a variable ‘n’ to provide the model order
of the Butterworth filter.

And then we issue a command ‘butter’ which will provide us the numerator coefficients and
the denominator coefficients for this IIR filter ok. So, it is not a FIR filter. So, we need both.
So, for that the variable, we have given the first variable is the order of the filter. Next, we are
giving the cut off frequency as a fraction of half of the sampling frequency ok; that means, if
we look at the graph that both side, if we take the normalised frequency, it is minus 0.5 to 0
and 0 to 0.5 in the right hand side. So, to take care of that fact, we are taking half of the
sampling frequency and what part of that 0.5 that cut of frequency is we are taking that
fraction and then the last command ‘low’ it is suggesting that we are looking for a low pass
filter ok.

So, you can get these things much better and, in more detail, if you issue the command help,
you can look at the manual of MATLAB. For the plot of magnitude and phase, first we create
that pane with the command ‘figure’, then like the previous case, we have used the command
that ‘freqz’ and we pass these variables, first is b is numerator polynomial coefficient, a is the
denominator polynomial coefficient, L is the number of samples we need; that we are giving
the same as the number of samples in the time domain, but it could be some other value, it
need not be same as the number of samples in the time domain signal and fs is the that
sampling frequency ok. So, that is the command actually we are using and with that here we
get two things; one is frequency as well as the phase ok, both we can get in the form of plot
and we have given it in the figure here.

What we get; that cut off frequency is 10; that means, somewhere here up to that the
amplitude is constant 0 to 10, after that there is a very slow decrease that means the transition
is not very sharp and the filter order is responsible for that, we have only order is two and the
phase it has some discontinuity at that part and then it is constant nothing much to note in the
phase part.

(Refer Slide Time: 11:07)

Next, we look at that it more clearly in a bigger way, we see that magnitude and the phase
plot, and then we would change the cut off frequency and the order, go for the second case
where we have the model order is 8 and the cut off frequency is also increased. So, with an
increase in a cut off frequency, we can see this constant portion more clearly and it has come
up to 20 hertz, it is constant up to that after that there is a decrease and the decrease is more
pronounced ok.

If we look at that at 400 hertz, what was the decrease? If we go to the previous case; we
would be able to appreciate that that it was actually less than 50 the decrease in the previous
case when the model order is two.

(Refer Slide Time: 12:16)

Now though the cut off frequency has moved towards the right the decrease is much more
pronounced and I think, it is about minus 100 here. However, in a phase part there is not
much thing to note, but only thing; what we can get the knee position is changing with the cut
off frequency ok. So, that is the change.
(Refer Slide Time: 12:45)

Now, the third one is that we have the cut off frequency at 40. So, it has moved here up to this
point, that is, it is constant and then it is decreasing.

(Refer Slide Time: 13:16)

So, and then we go for the cut off frequency 70. So, it is coming up to this point constant and
that we will see that there is some impact that probably it has gone little higher than minus
100. So, as cut off frequency is moving right that the suppression is not that prominent, but
the model order has more impact that we can get, and then knee point also that from where it
is becoming constant that is also moved, that is come near the 70. So, these are the different
cases we get.

Now, we need to look at that how the output signal is affected by the change in the magnitude
spectrum and the phase spectrum of the Butterworth filter. So, for that first we need to filter
the ECG signal; that noisy ECG with each of the butter Butterworth filters, one at a time.

(Refer Slide Time: 14:25)

So, for that; here we show the code for once case that already we have loaded the signal. So,
that part is there ok. So, first part of it that loading the single, then noting the sampling
frequency, the length of it, and the time axis that is there, and then we plot that in the top row
of the pane using the ‘figure’ and the ‘subplot’ command ok. So, we use that ‘plot’ command
for that.

Now, next part is to calculate the output and the already we have computed the numerator
polynomial coefficient and the denominator polynomial coefficients, ‘b’ and ‘a’ for the
Butterworth filter. So, we make use of that and use the command ‘filter’ and the third
variable is the input signal that is noise corrupted ECG and with that we get the output what
we stored as the output one.

So, we plot that signal here and we try to appreciate that what is the change ok. So, as we see
here that the signal looks pretty clean in terms of suppression of noise, this is the case where
our cut off frequency is 10 hertz and model order is 2, but the signal looks like a little bizarre
or distorted that you can get, if you look at the amplitude of the signal, the input amplitude,
say it is varying from minus 2 to plus 2, here it is reduced, it is minus 1 to plus 1 kind of thing
that is one thing.

Another thing if you just take that if you assume that no somewhere something is wrong with
the scaling if we assume that then I would request to look at the relative amplitude of the say
R and the T, then gap between these two has reduced ok

So, what that signifies that everyone can have their own interpretation and then at the end, we
need to see that from the trend that which one is correct. My interpretation is because the cut
off frequency is low, we lost a good part of the ECG signal or the part which had some high
frequency component of the ECG signal is lost and thereby we lost the amplitude of the QRS
complex and that is the reason for reduction of the height of the QRS complex ok.

So, let us move forward and here another thing that after doing this experiment, we found that
for order equal to 8 and cut off frequency has 40 hertz, we could get the best results. So, that
is taken as the reference signal for computing the SNR in this case ok. So, that will come later
that and let us see that how the outputs that come.

(Refer Slide Time: 18:43)

So, first case; we have taken the Butterworth filter with cut off frequency 10 hertz and model
order equal to 2 and with that when we compare the output of the Butterworth filter, we see
that SNR is 8.57 ok.

(Refer Slide Time: 19:17)

So, it is not a very good one and we look at that next case that frequency is 20 hertz and
model order is increased. We see there is an increase in the QRS complex value, it has
become more than one which was about one earlier and SNR also is increased ok.

(Refer Slide Time: 19:53)


Now, we get that for the cut off frequency 40 hertz and model order 8, we see that some
undulations are there and probably there the details of the signal and signal has got actually
the amplitude, if you look at the amplitude, here it is about 2.5, here the same height it has
got ok. So, that the lower side amplitude also we get the same thing that. So, we can actually
tell that this is closest to the original signal and that is why we have taken that as a reference
ok; however, we find that the details part of that thing is there and the undulation that is there
in the signal that is not of that high frequency. So, we actually assume or accept that as a part
of the signal.

(Refer Slide Time: 21:00)

Next, we move for cut off frequency as 70, a big jump model order remains the same as 8. In
this case, what we find that there is not much change in the signal height though it may look a
little better and probably QRS complex is close to the original signal, but a lot of noise is
keeping in, but still it is better than probably at the cut off frequency equal to 20 and the SNR
also tells as the same thing ok.

If we go back, we can see that the reference signal and the previous two values was about 8.5,
then near 12 then reference signal that is and now it is becoming 16. So, it is better than that,
but we get the high frequency noises are creeping in because we are getting a lot of
undulation there in the signal and that is the reason we have chosen the cut off frequency 40
is a better choice because in this case, though we are preserving more high frequency
component of the signal we are allowing part of the noise signal to creep in which is not a
good thing to do ok. So, that is why we do not take that cut off frequency 70 hertz as a good
choice or the right choice.

(Refer Slide Time: 22:51)

Now, let us compare with the synchronous average output ok. First thing, we get that we have
just taken a cycle; at the top, we have the noisy signal, here in the middle, we have the
Butterworth filter output and the below is the synchronous average output taking that as a
reference we are comparing and we have that cut off frequency 10 and model order equal to 2
for that we see the signal is very smooth; that means, noise suppression operation is very
effective, but we lost some part of the high frequency part and that is evident here looking at
QRS peak that is becoming evident ok.
(Refer Slide Time: 23:56)

So, now let us go for the next case we get the next part that is the cut off frequency is moved
to 20 and model order to 8, again suppression is we would say, it is very good same as the
synchronous average or maybe even better smooth signal we are getting and there is some
improvement in the QRS complex shape, the height has increased, but still it is much farther
and wider compared to the original QRS complex as well as the synchronous average ok.

(Refer Slide Time: 24:40)

Now, we are going for the part where we have taken it the reference that is 40 hertz cut off
frequency there we see that now the synchronous average output that QRS complex and the
Butterworth filter output they looks very close. So, that is the reason, we have told that cut off
frequency as 40 and the model order of the Butterworth filter order as 8 is giving us the best
signal ok.

(Refer Slide Time: 25:23)

So, as we proceed further, we go for cut off frequency 70. Now we get the smoothing has
become impaired in this case ok. So, this things would be more clear if we go back through
the slides. If we look back that we see that here that undulations are yet to come, some
change in shapes or details are there in the signal ok, if we go back further cut off frequency
is 20, it is very smooth, for 10 also it is very smooth ok.

Now, at 70 though the QRS complex shape it looks again very good it looks very close to the
synchronous averaging. We are getting lots of undulation in other places that is if you look at
this position beyond T, before T or even the part of the T and P; we see a lot of undulations
are there that suggest that the noise suppression has not been that effective, the cut off
frequency has become too high and the noise has started creeping in ok.
(Refer Slide Time: 26:56)

So, now we would look for the summary of this experiment. So, first thing what we note that
the Butterworth filter with cut off frequency ‘fc’ less than 40 hertz gives us distorted output
ok; why this distortion because the component of the single is lost, some part of the signal
energy is also lost.

Next is that we have ‘fc’ equal to 70 has some high frequency noise present and as the noise
is creeping in the signal, it comes in the pass band of the signal. So, we are getting noisy
output. So, that is not a right thing to have, then what we get that the middle part is the best
when we have that cut off frequency is in between that is we have taken 40 and model order
is 8, we get the best result and for that we have taken synchronized averaging as the reference
for us ok.

So, what we get in this experiment that we know that high frequency noise can be eliminated
by Butterworth filter or low pass Butterworth filter successfully, but we need to be very
careful in selecting the two things we need to appropriately select the cut off frequency so
that we will not lose part of the signal of the interest, at the same time it is low enough to
eliminate the noise signal. And we would also look at that model order of the Butterworth
filter which should not be very low, if it is very low then the attenuation at the high frequency
would be very small.
So, for an effective low pass filtering, it should have sufficient model order and we found
model order 8 is good enough for this purpose with that we would like to conclude that the
problem number three of tutorial one.

Thank you.

You might also like