ecg signal processing

Upload: benazir-begam

Post on 10-Oct-2015

37 views

Category:

Documents


3 download

DESCRIPTION

signal

TRANSCRIPT

ECG SIGNAL PROCESSING

Project oneGroup #5

David KebedeArchana JagannatamMustafa IbrahimIntroduction

This project deals with the signal processing of the ECG signal. Here we apply Fast Fourier Transform(FFT), which is an effective way to compute the Discrete Fourier Transform to both the given ecg and noise_ecg signal. We make the DC component of the FFT output as zero. Then the FFTSHIFT is applied, this shifts zero frequency components to center of the spectrum.

A notch filter rejects a narrow frequency and leaves the rest of the spectrum slightly changed. A notch filter is commonly used in audio applications to suppress noise. In this project we are asked to design a notch filter at two different values of Q=6 and Q=60 with 3dB bandwidth, then apply this noise filter to cleanup noise_ecg signal.

Methods

First of all we downloaded the ecgdata.mat from the course website. This m-file contains the clean signal, ecg and the distorted signal, noise_ecg which is obtained by adding power interference of 60Hz into ecg. Then the FFT is applied to both the signals with the DC component of FFT output as zero. Given that f0=60Hz and fs=360Hz. A plot of magnitude versus frequency is plotted within the range of fs/2 to fs/2.

Matlab code for ecg signal:fs=360; %360Hz is the sampling ratefo=60; %60Hz is the added power interference to obtain the "ecg" and %"noise_ecg"n=1:1024; xn=ecg; %set xn equal to the ecg signalxnfft=fft(xn,1024); xnfft(1)=0; % X[1]=0 to eliminate the huge DC components from signal xn=fftshift(xnfft);f=linspace(-fs/2,fs/2,1024); %to create equal spacingplot(f,abs(xnfft)); %to plot the magnitude of spectrum versus frequency xlabel(frequency(Hz));ylabel( magnitude );title( Plot for the magnitude versus frequency spectrum of ecg signal);grid; %include grid linesMatlab code for noise_ecg signal:fs=360; %360Hz is the sampling ratefo=60; %60Hz is the added power interference to obtain the "ecg" and %"noise_ecg"n=1:1024; xn=noise_ecg; %set xn equal to the noise_ecg signalxnfft=fft(xn,1024); xnfft(1)=0; % X[1]=0 to eliminate the huge DC components from signal xn=fftshift(xnfft);f=linspace(-fs/2,fs/2,1024); %to create equal spacingplot(f,abs(xnfft)); %to plot the magnitude of spectrum versus frequency xlabel(frequency(Hz));ylabel( magnitude );title( Plot for the magnitude versus frequency spectrum of noise_ecg signal);grid; %include grid lines

Notch filter designing:Matlab code for Q = 6:x=noise_ecg;a=[.9202 -.83984];b=[1 1 1];y=filter(b,a,x);plot(y)xlabel('frequency(Hz)');ylabel('magnitude');title(' notch filter for Q=6');

Matlab code for Q = 60:x=noise_ecg;a=[.9917 -.9827];b=[1 1 1];y=filter(b,a,x);plot(y)xlabel('frequency(Hz)');ylabel('magnitude');title(' notch filter for Q=60');Calculation:

Given values: f0 = 60Hz, fs=360Hz, Q=6, Q=60

w0 =(2*pi*f0)/fs = (2*pi*60)/360 = pi/3 = 1.0471975512= 1.047

w = w0/Q %when Q=6= 1.0471975512 / 6 = 0.174532925199=0.175b = 1 / [1+tan(w/2)] = 0.919924318134 = 0.9199w = w0/Q %when Q=60= 1.0471975512 / 60 = 0.01745329252=0.0175b = 1 / [1+tan(w/2)] = 0.9913506 = 0.9914

Designing the notch filter:

b*[1-2cos(w0z^-1)+z^-1] H(z) = ---------------------------------------------[1-2bcos(w0z^-1) + (2b-1)z^-1]

b*[1 - 2cos(w0*e^-jw) + e^-jw] H(jw) = -------------------------------------------------[1-2bcos(w0*e^-jw) + (2b-1)e^-jw]

% when Q=6

0.9199*[1 - 2cos(w0*e^-jw) + e^-jw] H(jw) = --------------------------------------------------------------------[1-(2*0.9199)*cos(w0*e^-jw) + (2*0.9199 -1)e^-jw]

% when Q=60

0.9914*[1 - 2cos(w0*e^-jw) + e^-jw] H(jw) = --------------------------------------------------------------------[1-(2*0.9914)*cos(w0*e^-jw) + (2*0.9914 -1)e^-jw]

Results

Conclusion

In this project we leaned how to design a notch filter to be able eliminate unwanted noise obtained while taking measurements.While the task of applying the FFT function was straight forward, we were challenged with the design of the notch filter. However, after many tries we feel we have designed the notch filter which is able to filter out the noise. Based on this project we feel we have some understanding on how this type of filter can be useful in ecg measurement where there may be great deal of noise interference.