0% found this document useful (1 vote)
175 views

Development of Filters

This document describes the design of notch filters to remove power line interference from ECG signals. Notch filters are required because power line noise occurs at 50/60Hz, which is within the bandwidth of ECG signals. The document outlines the process of designing digital IIR notch filters using pole-zero placement. Code is provided in MATLAB to design single and double notch filters at 50Hz and 100Hz for an ECG signal sampled at 500Hz. Results show the frequency responses of single notch filters for different values of r, which controls sharpness. Discussion explains how increasing r results in narrower bandwidth around the notch frequency.

Uploaded by

Wilson Chan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
175 views

Development of Filters

This document describes the design of notch filters to remove power line interference from ECG signals. Notch filters are required because power line noise occurs at 50/60Hz, which is within the bandwidth of ECG signals. The document outlines the process of designing digital IIR notch filters using pole-zero placement. Code is provided in MATLAB to design single and double notch filters at 50Hz and 100Hz for an ECG signal sampled at 500Hz. Results show the frequency responses of single notch filters for different values of r, which controls sharpness. Discussion explains how increasing r results in narrower bandwidth around the notch frequency.

Uploaded by

Wilson Chan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

NANYANG TECHNOLOGICAL UNIVERSITY

AY2011/2012 Yr 3 / SEMESTER 1 BG3701

Development of Filters for Processing ECG Signals


FORMAL REPORT
Name Matriculation Number Group Date of Experiment : : : : Lee Zhirong U0921774A GP3 September 19st, 2011

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Contents Page
Page

1) Objectives

2) Introduction Electrocardiogram Power-Line Noise Interference Notch Filter

1 1 2

3) Equipment and Materials

4) Design Procedures

5) Matlab Code

6) Results Notch Filter to Suppress 50Hz Component Notch Filter for Removing 2 Notches

5 9

7) Discussion Effect of Different r Values Why is Notch Filter Required? Why use Zero Pole Placement Method Other Notch Filter Designs

11 12 12 12

8) Conclusion

13

9) References

13

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Objectives
This experiment aims to result in a design of a notch filter to remove power line interference that is present in ECG Signals

Introduction
Electrocardiogram An electrocardiogram is a test which is a thransthoracic interpretation of the electrical activity of the heart. It translates the activity into signals of line tracing consisting of spikes and dips. The main components of a normal beating heart are shown on the left. The recorded electrical activity is the result of the stimulation of a natural electrical process which results in the heart contracting and pumping blood through the heart and into the lungs and the body. The ECG has many practical purposes. With a plot of the hearts electrical activity, it ca n pinpoint the cause of unexplained chest pains, find the causes of symptoms of heart diseases such as irregular heartbeats or acute diseases such as hypertrophied which is the result of the heart chamber walls being too thick. For the purpose of signal filtering, it is crucial to note that the bandwidth of interest is 0.05100Hz as it contains all the important wave forms.

Power-Line Noise Interference There are 3 types ore predominant noise in ECG signals. Baseline Wander Noise (BW), Power line interference and electromyographic interference (EMG). The former 2 are shown are the left. From the graphs, you can observe that the noise contaminated signals are very different actual ECG signals. Hence, for ECG signals to be readable and interpreted, these interferences have to be removed. The Power-Line interference is the most significant source of them all. Power-line interferences arise due to the power cables carries AC current at 50/60Hz which powers the 1

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

ECG recording equipment. Since significant ECG signals are in the range of 0.05-100Hz, the electromagnetic wave from these power cables will interfere with the cables carrying ECG signals from the patients to the monitoring equipment hence distorting the signals and making them hard to interpret.

Notch Filter

The Power-Line noise is special in a way because it has a frequency of 60Hz which is within the bandwidth of an ECG signal (0.05-100Hz). Hence, simple filters such as a low pass filter or high pass filter is not suitable as that would mean sacrificing portions of an ECG signal. This would result in an incomplete ECG signal and affect the accuracy of detection of heart problems. Hence, a notch filter is required. A notch filter passes all frequencies except those in a stop band centered on a center frequency. Hence, to eliminate the Power-line noise, it is ideally done with a notch filter with a center frequency which matches that of the noise (60Hz) and a small stop band. A small stop band is required to reduce the possibility of eliminating other frequencies which contain ECG signals. In this experiment, we are designing a digital IIR notch filter with pole-zero placement technique. We will be illustrating the technique as well as results. We will be exploring how r-value affects the notch filter as well as discussing about the filter, the designing technique used as well as other kinds of notch filters.

Equipment and Materials


X1 Computer with good processor X1 Matlab software

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Design Procedures: Illustration


Here are the summarized steps to design a notch filter which is used to remove periodic interferences.

Initialise the notch and sampling frequencies

Find the zero locations

Find the transfer function

Find DC gain and filter coefficients

Obtain frequency response

Initialize Notch and Sampling Frequencies


1. Define the notch frequency, fn The notch frequency is the frequency that you want to suppress with the designed filter. In this experiment, its 50Hz 2. Define the Sampling Frequency, fs The sampling frequency is the number of samples per unit time taken from a continuous signal to construct a discrete signal to be used in signal filtering. As a thumb rule, the sampling frequency must fulfill the Nyquist theorem. This means that fs must be atleast twice fo. If not, clipping may occur which results in inaccurate response. For human ECG signal, the recommended sampling frequency is 400-1000Hz

Find Zero Location


3. Calculate the frequency at which the filter is required to have zeros. Use the formula: Convert to degrees using the relation: 1 radian = 57.295

4. Calculate the zero locations, Z1 and Z2 Use the formula:

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Find Transfer Function


5. Calculate the transfer function using Z-transform Use the formula:

Find DC Gain (G) and filter coefficients (a and b)


6. Calculate G, which is used to make the gain at DC unity and find the net transfer function. Use the formula: Hence, the net transfer function can be obtained where

7. The filter coefficients can be obtained from H(Z) Put into a form where Hence, the filter coefficients after gain adjustment are: ] b=[ ] a=[

Obtain Frequency Response


8. Finally, the frequency response is obtained which is given by at

Matlab Code
The notch filter can also be designed using matlab with the following code sequence. X=ecg(2000) %loading ECG signal with 20000 samples fs=1000; %Sampling frequency fn=50; %notch frequency r=0.85; %to improve sharpness of the notch, poles are placed with the unit circle near to unity. To do that, change the r value. %frequency at which zeros are needed and zeros calculation wz=2*pi*fn/fs; c=cos(wz); %filter coefficients bnotch=[1,-2*c,1]; anotch=[1,-2*r*c,r*r]; %calculate and plot frequency response y=filter(bnotch,anotch,x); freqz(bnotch,anotch) 4

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Results: Notch Filter to suppress 50Hz component


Design a comb or notch filter to suppress the 50Hz frequency component. The sampling frequency is Fs= 500Hz. Find H(z). (Use ECG signal; r = 0.85, 0.9, 0.95, 0.99)

The frequencies at which zeros are needed are: = 0.2 So the zero locations are: Z1=*cos(1)+jsin(1)] Z2= Z1=[cos(1)+jsin(1)] Therefore, the transfer function is:

The net transfer function is [ [ When z=1, H(z)=1 [ ] ] ]

Therefore [ ]

Addding poles to make the function more stable, [ ] Hence, [ ] [ ] Therefore, net transfer function,

Therefore, the filter coefficients are, [ ] [ ] 5

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

r=0.85
Code >> x= ecg(20000); Fs= 500; Fn= 50; r=0.85; wz=2*pi*Fn/Fs; c=cos(wz); bnotch=[1,-2*c,1]; anotch=[1,-2*r*c,r*r]; y=filter(bnotch,anotch,x); freqz(bnotch,anotch)

Graph

r=0.9
Code >> x= ecg(20000); Fs= 500; Fn= 50; r=0.9; 6

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

wz=2*pi*Fn/Fs; c=cos(wz); bnotch=[1,-2*c,1]; anotch=[1,-2*r*c,r*r]; y=filter(bnotch,anotch,x); freqz(bnotch,anotch)

Graph

r=0.95
Code >> x= ecg(20000); Fs= 500; Fn= 50; r=0.95; wz=2*pi*Fn/Fs; c=cos(wz); bnotch=[1,-2*c,1]; anotch=[1,-2*r*c,r*r]; y=filter(bnotch,anotch,x); freqz(bnotch,anotch)

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Graph

r=0.99
Code >> x= ecg(20000); Fs= 500; Fn= 50; r=0.99; wz=2*pi*Fn/Fs; c=cos(wz); bnotch=[1,-2*c,1]; anotch=[1,-2*r*c,r*r]; y=filter(bnotch,anotch,x); freqz(bnotch,anotch) Graph

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Results: Notch Filter for removing 2 notches


Implement notch filter for removing two notches, F1 = 50 Hz and F2 = 100Hz with a sampling frequency of 500Hz. Write a MATLAB program for this, referencing the above code. (r=0.95) Try including poles to get a perfect cutoff. (Hint: 2 notches are to be rejected/suppressed) Given: F1 = 50Hz, F2 = 100Hz, Fs = 500Hz

For H1(Z) to depress 50Hz frequency,

Z11=*cos(1)+jsin(1)] Z21= Z11=*cos(1)+jsin(1)]

For H2(Z) to depress 100Hz frequency:

Z12=*cos(1)+jsin(1)] Z22= Z12=*cos(1)+jsin(1)]

Therefore, [ [ [ =
(where

][ ] ] [

] ]

Hence, [
(where

H(z) with poles, [ [ Hence, (

] ]

r r

) , where ) , where

] ]

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Similarly,

Therefore,

So, [ Matlab Code x = ecg(20000); Fs = 500; F1 = 50; F2 = 100; r = 0.95; w1 = 2*pi*F1/Fs; w2 = 2*pi*F2/Fs; c1 = cos(w1); s1=sin(w1) c2 = cos(w2); s2=sin(w2) bnotch = [1,-2*(c1+c2),(2+4*c1*c2),-2*(c1+c2), 1]; anotch = [1, -2*r*(c1 + c2), 2*r*r*(1 + 2*c1*c2), - 2*r^3*(c1 + c2),r^4]; y = filter(bnotch, anotch, x); freqz(bnotch, anotch) Graph ]

10

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Discussion
1. Effects of Different r Values
10 0
Magnitude (dB)

-10 -20 -30 -40 0.1

r = 0.99 r = 0.95 r = 0.90 r = 0.85

0.12

0.14

0.16 0.18 0.2 0.22 0.24 Normalized Frequency ( rad/sample)

0.26

0.28

0.3

From the combined graphs of exercise 1 shown in the diagram above, when r is increased closer and closer towards r=1, the notch becomes sharper. The bandwidth becomes 100 narrower. This shows that the filter is becoming more and more specific. This is expected as the r value is50 defined as the radius of the poles. Hence, the closer the r value goes to 1, the narrower the bandwidth as the poles are closer to the unit circle. A r r = 0.99 must be value more than 1 will cause the filter to be unstable. Hence, the pole radius r = 0.95 0 smaller than 1.
Phase (degrees)

r = 0.90

Magnitude (dB)

r = 0.85 A larger r value (<1) is better to filter off the single powerline interference frequency -50 10 component. As the interference frequency is inside the range of the ECG signal, a large bandwidth (smaller0r value) is not ideal. The is because a large bandwidth will cause other frequencies around the null (powerline frequency) to be severely attenuated. And hence the -100 -10 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 r = 0.99 inference is within the range of the interference frequency, the ECG signal may be distorted.
-20 r = rad/sample) 0.95 Normalized Frequency ( r = 0.90

Ideally, when r approaches unity (1), the filter is ideal. However, practically, too close a r r = 0.85 -30 value to 1 is not desirable too as the response may begin to have over and undershoot that -40 of the notch and the frequency that is supposed to be rejected may be destroys the integrity 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 Normalized Frequency ( rad/sample) amplified.
100

50
Phase (degrees)

r = 0.99 0 r = 0.95 r = 0.90 r = 0.85 -50

-100

0.1

0.2 0.3 0.4 0.5 Normalized Frequency ( rad/sample)

0.6

0.7

11

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

2. Why is notch filter required?


As repeated throughout this report, a notch filter is required to filter ECG signals mainly due to power line interference. Power line interference is noise caused by AC current running in wires that powers the ECG devices. The frequency of the AC current is 50/60Hz. It is within the bandwidth of ECG signals that we observe and hence may distort the signal. As the bandwidth of ECG signals are 0.05-100 Hz, other filters such as low pass filters cannot be moved. As using low pass filters (<60Hz) will result in the blurring of the QRS complex and affect the PQ and ST segments. Hence, it is ideal to use a notch filter which only removes the component of interest (power line noise frequency) without distorting or eliminating other components.

3. Why use zero pole placement method?


Zero pole placement method is used this technique is the easiest way to design a IIR notch filter. It is also the most effective method. As illustrated by this lab process, you only need to have matlab, simple calculus and algebraic solving to obtain the frequency response. However, this method also have some constrains- asymmetric and uncontrollable gain. The specific type of filter we used is called the Type II IIR notch filter. In this type, the zeros also line on the unit circle with angles equal to the notch frequency. However, the poles are not on the same radial line as zeros but near it.

4. Other notch filter designs


Notch filter designs can be classified into many categories. Firstly, by the length of impulse response: finite impulse (FIR), infinite impulse response (IIR). Secondly, by the number of frequencies the filter can reject: fixed notch filters, tunable notch filters, adaptive notch filters. Thirdly, by the methods for IIR and FIR filter design: analog filter transformation, all pass filter implementation, pole-zero placement technique. Fourthly, by the design method: optimal FIR filter design, frequency sampling, sparse FIR notch filter design, windowed Fourier series approach, using Bernstein polynomial.

12

Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong

Conclusion
This experiment illustrates the simplicity and efficiency of a notch filter design using zero pole placement method. This can be done using calculus, algebra, Z-transform together with matlab. The notch filter is especially important to eliminate power line noise interference in ECG signals. This is due to the noise frequency (50Hz) being in the range of significant ECG signals (0.05Hz to 100Hz). Hence, a low pass or high pass filter will distort critical ECG signals. The zero pole placement method is simple and effective to eliminate power line noise interferences in ECG signals. Increasing the r value (approaching r=1) will make the notch sharper with a small bandwidth resulting in a more specific filter. However, too close an r value to 1 may not be recommended as it may leave some parts of the noise interference untouched due to its high specificity. However, generally, the closer r is to 1, the better the noise filter is.

References
http://www.webmd.com/heart-disease/electrocardiogram http://www.webmd.com/heart/ekg-components-and-intervals http://en.wikipedia.org/wiki/Electrocardiogram http://www.nobelprize.org/educational/medicine/ecg/ http://www.springerimages.com/Images/Mathematics/1-10.1007_s10916-009-9289-2-6 http://www.netdoctor.co.uk/health_advice/examinations/ecg.htm http://www-k.ext.ti.com/SRVS/Data/ti/KnowledgeBases/analog/document/faqs/q.htm http://tempest.das.ucdavis.edu/mmwave/notch_filter/notchfilter.htm http://www.adinstruments.com/solutions/attachments/pr-signalfilters-05a.pdf http://en.wikipedia.org/wiki/Notch_filter http://djj.ee.ntu.edu.tw/Notch_Filter.pdf http://en.wikipedia.org/wiki/Q_factor http://www-k.ext.ti.com/SRVS/Data/ti/KnowledgeBases/analog/document/faqs/notch.htm Embedded signal processing with the Micro Signal Architecture By Woon-Seng Gan, SenMaw Ku

13

You might also like