Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecturer: Dr Igor Khovanov Office: D207 Syllabus: Biomedical Signal Processing. Examples of signals. Linear System Analysis. Laplace.

Similar presentations


Presentation on theme: "Lecturer: Dr Igor Khovanov Office: D207 Syllabus: Biomedical Signal Processing. Examples of signals. Linear System Analysis. Laplace."— Presentation transcript:

1 Lecturer: Dr Igor Khovanov Office: D207 i.khovanov@warwick.ac.uk Syllabus: Biomedical Signal Processing. Examples of signals. Linear System Analysis. Laplace Transform. Transfer Function. Frequency Response. Fourier Transform. Discrete Signal Analysis. Digital (discrete-time) systems. Z-transform. Noise removal. Filtering. Digital Filters design and application. Case Study. ES97H Biomedical Signal Processing 1

2 2 Noise removal. Filtering Removing noise from a signal probably is the most frequent application for signal processing of biomedical signals. The distinction between noise and desired signal is an heuristic judgment that must be determined by the user. Often the distinction is obvious-for example, 50-Hz or 60-Hz interference in recording or temperature-related drift. The task is removal of the noise with the least possible distortion of the desired signal. One of the basic techniques is frequency filtering.

3 3 Noise sources. Electronic noise or noise of measurements. Mainly thermal nature, so the noise has a broad spectrum. Structured noise. EM waves pollution and power supply interference. Often one can specify a frequency band or unique frequency of such signals. An acquisition procedure of bio-medical objects. Moving artifacts. Physiological interference. Biomedical object is a complex conglomeration of several systems and processes. EMG related to coughing, breathing, affecting the ECG Maternal ECG getting added to the fetal ECG of interest ECG interfering with the EEG

4 4 Example. ECG signal High-frequency noise in the ECG

5 5 Example. ECG signal Motion artifact in the ECG

6 6 Example. ECG signal Power-line interference in ECG signals

7 7 Example. ECG signal Power spectrum of ECG signal. It is expected that the bandwidth of interest of the ECG signal is in the range 0.05 -100 Hz.

8 8 Example. ECG signals interference Signal from the woman's chest Signal from the abdomen of a woman.

9 9 Example. ECG artifact in EMG recording When an electromyogram (EMG) is recorded from muscles on the torso, the electrocardiogram (ECG) is commonly superimposed on the EMG signal because of the physical proximity of the heart and the large electrical amplitude of the ECG compared to many EMG signals. Measured signal Power spectrum Dashed line corresponds to ECG Solid line corresponds to EMG

10 10 ElectroEncephaloGram (EEG) frequency bands

11 11 A typical acquisition scheme includes filters Analogue filter (circuit) ADC Digital filter Computer code Engineering task to design  Analogue filters  Digital filters

12 Lecturer: Dr Igor Khovanov Office: D207 i.khovanov@warwick.ac.uk Syllabus: Biomedical Signal Processing. Examples of signals. Linear System Analysis. Laplace Transform. Transfer Function. Frequency Response. Fourier Transform. Discrete Signal Analysis. Digital (discrete-time) systems. Z-transform. Filtering. Analogue Filters design and application. Case Study. ES97H Biomedical Signal Processing 12

13 13 Filter Types and Classifications Analogue filters are defined over a continuous range of frequencies. The ideal amplitude (magnitude) spectral characteristics of filters The ideal characteristics are not physically realizable.

14 14 Low-pass analogue filter The transfer function

15 15 High-pass analogue filter The transfer function

16 16 Band-pass analogue filter The transfer function

17 17 Band-stop (elimination) analogue filter The transfer function

18 18 Low−Pass Analogue Filter Prototypes There are transformations, using which we can derive high−pass and the other types of filters from a basic low−pass filter. The first step in the design of an analogue low−pass filter is to derive a suitable amplitude (magnitude)−squared function Not all magnitude−squared functions can be decomposed to the transfer functions H(s) and H(-s). It can be only even functions of , positive for all , and proper rational functions (i.e. the largest power in the denominator is equal to or larger than that of the numerator). General form. a and b are coefficients; k is the order of the filter

19 19 Low-pass filter. Attenuation rate A general form of the magnitude-squared function for low-pass filters and at high frequencies can be approximated as Take the square root of both sides Take the common log10 of both sides and multiplying by 20 or in dB per decade: The filter order defines attenuation rate

20 20 From the magnitude-squared function to the transfer function Consider the given function The zeros s  ±j1, poles are s  ±2 and s  ±3. There is no restriction on the zeros but, for stability, we select the left−half s−plane poles. From the transfer function we can specify a model of the filter in the form of ODEs and then in the form of circuits.

21 21 Butterworth Analogue Low−Pass Filter Design The Butterworth low−pass filter has the following magnitude−squared function is  C is the cut-off frequency (3dB) Location of the poles for the transfer function All Butterworth filters have the property that all poles of the transfer functions that describes them, lie on a circumference of a circle of radius  C, and they are 2  /2k radians apart.

22 22 The frequency response of the Butterworth filter is maximally flat (has no ripples) in the passband, and rolls off towards zero in the stopband. When viewed on a logarithmic Bode plot, the response slopes off linearly towards negative infinity. Butterworth Analogue Low−Pass Filter Design Attenuation for different values of k

23 23 Chebyshev Type I Analog Low−Pass Filter Design The Chebyshev Type I low−pass filter magnitude−square function is defined as the Chebyshev polynomials C k (x) has a polynomial representation  is a parameter chosen to provide the desired pass−band ripple,  is a constant chosen to determine the desired DC gain, k denotes both the degree of the Chebyshev Type I polynomial and the order of the filter,  C is the cutoff frequency. This filter produces a sharp cutoff rate in the transition band.

24 24 Chebyshev Type II Analog Low−Pass Filter Design The Chebyshev Type II low−pass filter magnitude−square function is defined as It has the ripple in the stop−band as opposed to Type I which has the ripple in the pass−band

25 25 Elliptic Analog Low−Pass Filter Design The elliptic, also known as Cauer filters, are characterized by the low−pass magnitude−squared function where R k represents a rational elliptic function used with elliptic integrals. Elliptic filters have ripple in both the pass−band and the stop−band.

26 26 High−Pass, Band−Pass, and Band−Elimination Filter Design Transformation methods have been developed where a low−pass filter can be converted to another type of filter simply by transforming the complex variable s. These transformations are listed in the Table, where  C is the cutoff frequency of a low−pass filter.

27 27 Analogue Filters comparison Advantages / Disadvantages of different types of filters.

28 Lecturer: Dr Igor Khovanov Office: D207 i.khovanov@warwick.ac.uk Syllabus: Biomedical Signal Processing. Examples of signals. Linear System Analysis. Laplace Transform. Transfer Function. Frequency Response. Fourier Transform. Discrete Signal Analysis. Digital (discrete-time) systems. Z-transform. Filtering. Digital Filters design and application. Case Study. ES97H Biomedical Signal Processing 28

29 29 Digital Filters A digital filter is essentially a computational process (algorithm) that converts one sequence of numbers x[n] representing the input, to another sequence y[n] that represents the output. Thus, a digital filter, in addition of filtering out desired bands of frequency, can also be used as a computational means of performing other functions such as integration, differentiation, and estimation. The input−output difference equation The properties of digital filters are specified by the transfer function H(z) in z-domain. Therefore, the design of a digital filter to perform a desired function, entails the determination of the coefficients a i and b i.

30 30 Classification of digital filters Digital filters are classified in terms of the duration of the impulse response, and in forms of realization. 1. Impulse Response Duration a.An Infinite Impulse Response (IIR) digital filter has infinite number of samples in its impulse response h[n] b.A Finite Impulse Response (FIR) digital filter has a finite number of samples in its impulse response h[n] 2. Realization a. In a Recursive Realization digital filter the output is dependent on the input and the previous values of the output. In a recursive digital filter, both the coefficients a i and b i are present. IIR filters b. In a Non−Recursive Realization digital filter the output depends on present and past values of the input only. In a non−recursive digital filter, only the coefficients b i. are present, i.e., a i =0. FIR filters

31 31 From analogue to digital filters Three well known transformation methods are the following: 1. The Impulse Invariant Method which produces a digital filter whose impulse response consists of the sampled values of the impulse response of an analogue filter. 2. The Step Invariant Method which produces a digital filter whose step response consists of the sampled values of the step response of an analogue filter. 3. The Bilinear Transformation which uses the transformation to transform the left−half of the s−plane into the interior of the unit circle in the z−plane.

32 32 A low-pass filter with 3 dB cutoff frequency at 20 Hz and attenuation of at least 20 dB for frequencies greater than 40 Hz. The sampling frequency 200 Hz. From analogue to digital filters. Example Analogue filter Digital filter MATLAB provides us with all the functions that we need to design digital filters using analogue prototypes. After specification of coefficients a and b we can perform filtering y=filter(a,b,x)

33 33 Comment on filtering using FFT Ideal characteristics 1. Perform FFT 2. Modify Fourier coefficients 3. Perform inverse FFT

34 34 Digital filter Filtering is performed via the input-output difference equation Filter properties are defined by the coefficients a and b. The frequency response of the filter is determined via the transfer function as That is via Fourier transform of the coefficients.

35 The frequency response of the filter is 35 FIR digital filter Filtering is performed via the input-output difference equation Filter properties are defined by the coefficients b only. Advantages  always stable  linear phase shifts  initial transients that are of finite durations  extension to 2-dimensional applications is straightforward. The downside of FIR filters is that they are less efficient in terms of computer time and memory than IIR filters. The most typical is moving average

36 36 FIR digital filter design The inverse operation, going from a desired frequency response to the coefficient function, b i, is known as filter design. The coefficients can be found from the inverse Fourier transform of the desired frequency response: Example. FIR low-pass filter based on the spectrum of an ideal filter. f C is the cutoff frequency f S is the sampling frequency L is the length filter The ideal filter requires infinite length filter.

37 37 FIR digital filter design Example. FIR low-pass filter based on the spectrum of an ideal filter. Coefficients b[n] length L=64 for two cut-off frequencies

38 38 FIR digital filter design Example. FIR low-pass filter based on the spectrum of an ideal filter. The amplitude spectrum of two filters with different lengths.

39 39 Window functions and their Fourier transform Rectangular window Triangular window

40 40 Window functions and their Fourier transform Hann window Hamming window

41 41 Window functions and their Fourier transform Nuttall window http://en.wikipedia.org/wiki/Window_function

42 42 FIR digital filter design Example. FIR low-pass filter based on the spectrum of Hamming window instead of an ideal rectangular filter. The amplitude spectrum of two filters with different lengths.

43 43 FIR digital filter design Example. Filtration of EEG signal Frequency spectrum of EEG data using the FFT. The dashed line is the frequency response of band- pass filter.

44 44 FIR digital filter design Example. Filtration of EEG signal

45 45 FIR digital filter design MATLAB signal processing toolbox GUI (some functions) Design is a specification the coefficients a and b for functions y=filter(a,b,x) y=filtfilt(a,b,x) Step 1. Understand what should the frequency response of the filter we design be. Depends on the given problem. Note, that the frequency response can be checked via function [h,w] = freqz (b,a,n,fs); b and a are filter coefficients; n is number of points in the frquency response; 2 k is recommended; fs is the sampling frequency; h is complex frequency response; the amplitude response can be calculated as abs(h) and the phase response as angle(h) ; w is frequency vector.

46 46 FIR digital filter design Step 2. Calculation of b filter coefficients; (a)FIR filter design using the window method. b = fir1(n,wn,’ftype’,window); n is the order of the filter; wn specifies cut-off frequency(ies) ftype specifies filter type (low-pass, high-pass etc) window specifies different window function like Hamming and many others (b) FIR arbitrary shape filter design using the frequency sampling method. b = fir2(n,f,A,options) f and A specify the desired amplitude response (In other words, plot(f,A) would show the desired magnitude frequency curve.) f  [0:1]

47 47 FIR digital filter design Step 2. Calculation of b filter coefficients; (a)FIR filter design using the window method. b = fir1(n,wn,’ftype’ window); % Design a window-based bandpass % filter with cutoff frequencies of 5 and 15 Hz. % Assume a sampling frequency of 100 Hz. % Filter order = 128 clear all; close all; fs = 100; % Sampling frequency order = 128; % Filter order wn = [5 15]/(fs/2); % Specify cut-off frequencies b = fir1(order,wn); % On line filter design, Hamming window (default) [h,freq] = freqz(b,1,512,100); % Get frequency response plot(freq,abs(h),’k’); % Plot frequency response xlabel(’Frequency (Hz)’); ylabel(’H(f)’);

48 48 FIR digital filter design The frequency response of the designed filter

49 49 FIR digital filter design Step 2. Calculation of b filter coefficients; (a)FIR filter design without specification in advance of the order [n, fo, ao, w] = remezord (f,A,dev,Fs); The input arguments, f, A and dev specify the desired frequency response curve in a somewhat roundabout manner. Fs is the sampling frequency. The output arguments include the required filter order, n, the normalized frequency ranges, fo, the frequency amplitudes for those ranges, a0, and a set of weights, w, that tell the next stage how to assess the accuracy of the fit in each of the frequency ranges. b = remez (n, fo, ao, w,’ftype’);

50 50 FIR digital filter design Example. Design a bandstop filter having the following characteristics: a passband gain of 1 (0 db) between 0 and 100, a stopband gain of −40 db between 300 and 400 Hz, and an upper passband gain of 1 between 500 and 1000 Hz. Maximum ripple for the passband should be ±1.5 db. Assume fs = 2 kHz. %Matlab script rp_pass = 3; % Specify ripple tolerance in passband rp_stop = 40; % Specify error tolerance in passband fs = 2000; % Sample frequency: 2 kHz f = [100 300 400 500]; % Define frequency ranges a= [1 0 1]; % Specify gain in those regions % Now specify the deviation converting from db to linear dev = [(10^(rp_pass/20)-1)/(10^(rp_pass/20)+1) 10^(-rp_stop/20).... (10^(rp_pass/20)-1)/(10^(rp_pass/20)+1)]; % Design filter [n, fo, ao, w] = remezord(f,a,dev,fs) % Determine filter order b = remez(n, fo, ao, w); % Determine filter coefficients freqz(b,1,512,fs); % Plot filter frequency response

51 51 FIR digital filter design Example. The amplitude and phase response of the designed filter

52 The frequency response of the filter is 52 IIR digital filter Filtering is performed via the output difference equation Advantages The primary advantage of IIR filters over FIR filters is that they can usually meet a specific frequency criterion, such as a cutoff sharpness or slope, with a much lower filter order (i.e., a lower number of filter coefficients). The design of analogue filters (Butterworth, Chebyshev, Elliptic) can be used. The major disadvantage of IIR filters is that they have nonlinear phase characteristics. ! However the function filtfilt by filtering data in direct and opposite directions effectively produces zero phase shift. Filter properties are defined by the coefficients b and a.

53 53 IIR filter design Step 2. Recursive Yule–Walker filter design using the least-squares method (time domain) [b,a] = yulewalk(n,f,A) n is the order of the filter; f and A specify the desired amplitude response (In other words, plot(f,A) would show the desired magnitude frequency curve.) f  [0:1]

54 54 IIR filter design Example. Compare 12th-order IIR and FIR band-pass filter with Cut-off frequencies of 0.25 and 0.5. % Matlab script close all; clear all; n = 12; % Filter order f = [0.25.25.6.6 1]; % Specify desired frequency response A = [0 0 1 1 0 0]; [b,a] = yulewalk(n,f,A); % Construct Yule–Walker IIR Filter h = freqz(b,a,256); b1 = fir2(n,f,A); % Construct FIR rectangular window filter h1 = freqz(b1,1,256); plot(f,A,’k’); % Plot the ideal “window” freq.response hold on w = (1:256)/256; plot(w,abs(h),’--k’); % Plot the Yule-Walker filter plot(w,abs(h1),’:k’); % Plot the FIR filter xlabel(’Relative Frequency’);

55 55 IIR filter design Example. Compare 12th-order IIR and FIR band-pass filter with Cut-off frequencies of 0.25 and 0.5.

56 56 IIR filter design Step 2. Design analogue filter types [n,wn] = buttord(wp, ws, rp, rs); % Butterworth filter [n,wn] = cheb1ord(wp, ws, rp, rs); % Chebyshev Type I filter [n,wn] = cheb2ord(wp, ws, rp, rs); % Chebyshev Type II filter [n,wn] = ellipord(wp, ws, rp, rs); % Elliptic filter Inputs wp and ws are the passband and stopband frequencies relative to f s /2; rp is the passband ripple in db; rs is the stopband ripple also in db. For the Butterworth rp is the maximum attenuation in the passband and rs is the minimum attenuation in the stopband. Outputs n is the required filter order; wn is the actual −3 db cut-off frequency.

57 57 IIR filter design Step 2. Design analogue filter types (Continuation) [b,a] = butter(n,wn,’ftype’) % Butterworth filter [b,a] = cheb1(n,rp,wn,’ftype’) % Chebyshev Type I filter [b,a] = cheb2(n,rs, wn,’ftype’) % Chebyshev Type II filter [b,a] = ellip(n,rp,rs,wn,’ftype’) % Elliptic filter Inputs n is the required filter order; wn is the actual −3 db cut-off frequency relative to f s /2;. rp is the passband ripple in db; rs is the stopband ripple also in db. Outputs a and b are coefficients of the filter

58 58 IIR filter design Example. Compare the amplitude response of 8th-order lowpass filters using the Butterworth, Chebyshev Type I and Chebyshev Type II, and Elliptic filters. Cutoff frequency is 200 Hz and a sampling frequency is 2 kHz. For all filters, the passband ripple should be less than 3 db and the minimum stopband attenuation should be 60 db.


Download ppt "Lecturer: Dr Igor Khovanov Office: D207 Syllabus: Biomedical Signal Processing. Examples of signals. Linear System Analysis. Laplace."

Similar presentations


Ads by Google