Biomedical Instrumentation File: Submitted By: Preeti Gupta

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

BIOMEDICAL

INSTRUMENTATION
FILE

SUBMITTED BY:
PREETI GUPTA
EXPERIMENT NO. 1
Aim: Write a MatLab code to perform the following filtering actions
1. Remove frequencies above 90 hz.
2. Remove frequencies below 0.5hz
3. Remove frequencies between 50 to 60 hz

Theory:
In this experiment we use butterworth filter in low, high and bandpass configuration to perform
the required task. It is assumed that a total of 1280 samples are taken in 1 second. Hence we can
get the sampling frequency which is used to normalize the cutoff frequency of the respective
filter.

A low pass filter is used to remove the frequencies above 90hz. The output from butter function
is used in the filter function to get the desired plot. Similarly high pass filter is used to remove
frequencies below 0.5 hz and band pass filter is used to remove frequencies between 50 to 60 hz.

MatLab code:
close all;
val=val(1,1:500);
plot(val); %%plotting the ecg filter
f=1280; %%assuming the samples are taken in 1 sec

%% 1.) to remove frequency above 90


f_low=90/(f/2);
%where f is the sampling freqency and f_low is the normalized freq
n=4;
[b,a]=butter(n,f_low,'low') ;
p= filter(b,a,val);
figure();
plot(p);

%% 2.) to remove frequency below 0.5


f_high=0.5/(f/2);
[d,c]=butter(n,f_high,'high') ;
% the above step involves designing of the high pass filter, n is the order
q= filter(d,c,val);
figure();
plot(q);

% 3.) to remove frequency b/w 50 and 60


f1=50/(f/2);
f2=60/(f/2);
f=[f1,f2];
[f,e]=butter(n,f,'stop');
% the above step involves designing of the filter, n is the order
r= filter(f,e,val);
figure();
plot(r);

OUTPUT

Input signal
Output after removing frequencies above 90hz.

Output after removing frequencies below 0.5hz.


Output after removing frequencies between 50 to 60 hz.
EXPERIMENT NO. 2
Aim: Write a MatLab code to perform denoising of signal by wavelet technique.
Theory:
This exercise involves the use of wavelet toolbox. Firstly the threshold value is found using the
ddencmp function. This is the used to de-noise the signal with 3 different techniques- Symlets,
daubechies and biorthogonal in wdencmp function. Finally the signal to noise ratio is found out
for each of the techniques.

MatLab code:
%%% ECG SIGNAL DENOISING BY THRESHOLDING ITS DWT COEFFICIENTS
val=val(1,:);

%%loading the ecg signal


ecg=val;
L=length(ecg);

% NOISY ECG SIGNAL


ecgN=ecg+160*randn(1,L);
%% WAVELET DECOMPOSITION
% Default values for denoising using a wavelet
[THR,SORH,KEEPAPP]=ddencmp('den','wv',ecgN);

% decomposition up to level 3
level=3;

% De-noising by thresholding SYM4(Symlets) detail coefficients


[ecgC,CecgC,LecgC,PERF0,PERFL2]=wdencmp('gbl',ecgN,...
'sym4',level,THR,SORH,KEEPAPP);

% De-noising by thresholding db4(Daubechies) detail coefficients


[ecgC1,CecgC1,LecgC1,PERF01,PERFL21]=wdencmp('gbl',ecgN,...
'db4',level,THR,SORH,KEEPAPP);

% De-noising by thresholding Biorthogonal detail coefficients


[ecgC2,CecgC2,LecgC2,PERF02,PERFL22]=wdencmp('gbl',ecgN,...
'bior2.4',level,THR,SORH,KEEPAPP);

%%finding the snr in db for all the three cases


snr1 = 10*log10(sum(ecgC.^2) ./ sum(ecgN.^2));
snr2 = 10*log10(sum(ecgC1.^2) ./ sum(ecgN.^2));
snr3 = 10*log10(sum(ecgC2.^2) ./ sum(ecgN.^2));
Output
EXPERIMENT NO. 3
Aim: Write a MatLab code to perform Fourier transform of the given signal
Theory:
In mathematics, the Fourier transform (often abbreviated FT) is an operation that transforms one
complex-valued function of a real variable into another. In such applications as signal
processing, the domain of the original function is typically time and is accordingly called the
time domain. The domain of the new function is typically called the frequency domain, and the
new function itself is called the frequency domain representation of the original function. It
describes which frequencies are present in the original function.

In this experiment we use the fft function in matlab to perform the discrete Fourier transform.
The signal is given as input to the fft function and the absolute value is plotted.

MatLab code:
x=val(1, :);
y=fft(x);
z=plot(abs(y));

Output
EXPERIMENT NO. 4
Aim: Write a MatLab code to calculate the number of R-peaks in the given signal.
Theory:
In this experiment, we calculate the number of R-peaks in the given ECG signal. The heart-beat
could also be calculated if the time duration for supplied ECG signal is known, by just dividing
that R-peak count with the time duration.

To calculate the number of R-peaks in the signal, an optimum value for threshold is chosen
according to the input wave (e.g for the ECG wave input used, threshold has been taken to be
150).
Then, a count variable is initiated to zero and whole ECG signal is traversed using a simple loop
checking each value for:
i) greater then the threshold;
ii) current value is larger than the previous value; and
iii) current value is larger than the next value
If the all the above conditions are met, the value of count is increased, and loop is continued.

Finally, we will have number of R-peaks in the count variable.

MatLab code:
count=0;
b=size(val,2);
threshold=150;
x=val(1,:);
for j=1:1:b
if x(j)>threshhold & x(j+1)<x(j) & x(j-1)<x(j)
count=count+1;
end
end

Output
EXPERIMENT 5
AIM: Simulation of respiratory system in MatLab using SIMULINK.
THEORY:
The airways are divided into two categories: the larger or central airways and the smaller or
peripheral airways, with fluid mechanical resistances equal to Rc and Rp, respectively. Air that
enters the alveoli also produces an expansion of the chest wall cavity by the same volume. This
is represented by the connection of the lung CL, and the chest wall Cw compliances in series.
However a small fraction of the volume of air that enters the respiratory system is shunted away
from the alveoli as a result of the compliance of the central airways and gas compressibility. We
account for this effect by placing a shunt compliance, C, in parallel with CL and Cw.

The pressures developed at the different points of this lung model are:

Pao at the airway opening,

Paw in the central airways,

PA in the alveoli &

Ppl in the pleural space. These pressures are referenced to P0, the ambient pressure, which can be
set to zero.

Suppose the volume flow-rate of air entering the respiratory system is Q, then the objective here
is to derive a mathematical relationship b/w Pao and Q.

Simply by applying the Kirchhoff’s laws then taking the inverse Laplace of the resulting
differential equation and putting the values of various pulmonary parameters we have the
transfer function as:
Q (s ) s 2+ 420 s
= 2
P ao ( s ) s +620 s +4000

You might also like