Development of Filters
Development of Filters
Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong
Contents Page
Page
1) Objectives
1 1 2
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.
Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong
Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong
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=[
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
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:
Therefore [ ]
Addding poles to make the function more stable, [ ] Hence, [ ] [ ] Therefore, net transfer function,
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
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
Therefore, [ [ [ =
(where
][ ] ] [
] ]
Hence, [
(where
] ]
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)
0.12
0.14
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)
-100
0.1
0.6
0.7
11
Development of Filters for Processing ECG Signals Formal Laboratory Report Lee Zhirong
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