SIGNAL PROCESSING Prezentacja multimedialna współfinansowana przez Unię Europejską w ramach Europejskiego Funduszu Społecznego w projekcie pt. Innowacyjna dydaktyka bez ograniczeń - zintegrowany rozwój Politechniki Łódzkiej - zarządzanie Uczelnią, nowoczesna oferta edukacyjna i wzmacniania zdolności do zatrudniania osób niepełnosprawnych Politechnika Łódzka, ul. Żeromskiego 116, 9-924 Łódź, tel. (42) 631 28 83 www.kapitalludzki.p.lodz.pl
Digital filters 2 Digital signal processors (DSP), programmable circuits x(n) Digital filter y(n) h(n) - impulse response x(n) y(n) y(n) = x(n) h(n)
Signal processing 3 analog (anty-aliasing) filtering sampling A/D Digital processing D/A sensor transducer Amplifier fm f 2 f s M Sprectral methods Correlation methods Filtering Compressing Analog processing
Digital filters 4 Why to filter the signal? to reduce noise (eg. from the mains network) to change the spectral characteristic of the signal (preemphasis, deemphasis) to filter out the components of intrest from the given signal (detection)
Signal smoothing by filtering.3 smoothing filters 5.2.1 -.1 -.2 -.3 -.4 -.5 -.6 -.7 11 12 13 14 15 16 17 18 19
Uo/Ui An analogue low-pass filter example 6 1.9.8.7 Filter amplitude transfer function -3dB.77 U i U o.6.5.4.3.2.1 Amplitude transfer function: 1-2 1-1 1 1 1 U U o i 1 1 RC 2 f[hz] f c =?
Frequency characteristics ideal filters 7 A(f) High-pass A(f) Low-pass f f A(f) Band-pass A(f) band-stop f f
Frequency characteristics 8 Low-pass filter (eg. antialiasing filter, noise reduction) A(f) Pass band f p f s Transient band Stop band f High-pass filter A(f) (eg. preemphasis) f
Frequency characteristics 9 A(f) Band-pass filter (eg. feature detection) Band-stop fiter A(f) f (eg. mains interference reduction) 5 Hz f
Frequency characteristics - examples 1 A(f) Low-pass filter (noise reduction) f 15 15 1 1 5 5 V V 2 4 6 8 1 2 4 6 8 1
Frequency characteristics - examples 11 A(f) High-pass filter (eg. mean subtraction) f 15 1 5 1 5 V 2 4 6 8 1-5 V -1-15 2 4 6 8 1
Frequency characteristics - examples 12 Narrow band-pass filter A(f) (eg. feature detection) 15 1 6 4 2 f 5 V 2 4 6 8 1-2 2 4 6 8 1
Frequency characteristics - examples 13 A(f) Band-stop filter (eg. Reduction of noise of precise frequency) 5 Hz f 16 15 14 13 12 11 1 9 2 4 6 8 1 14 13 12 11 1 9 2 4 6 8 1
Filter types 14 A Plot filter characteristics: B C Filter LP filter HP filter BP filter?
Application of filters to ECG processing 15 lowpass (radio noise reduction, reduction of skeletal muscles activity noise) highpass (elimination of izoelectric line migration, f g =.5 Hz, see. ecg_mit.mat ) bandpass (ECG feature detection, eg. P, T, QRS waves) bandstop (mains network interference reduction, f=5 Hz)
Digital filters FIR i IIR 16 Another division: 1.8 Finite Impulse Response (FIR).6.4.2 5 1 15 2 1 Infinite Impulse Response (IIR) co called recursive filters.8.6.4.2 5 1 15 2
Digital filters FIR i IIR 17 The following elementary functional operators are used in the design of a digital filter : Summation Multiplication by a constant Unit delay u 1 (n) u 2 (n ) n u n u n y 1 2 y(n) u(n) c y(n) u(n) z -1 y(n) yn cun yn un 1
The idea of digital filtering Moving average coefficients x(n) b Autoregression coefficients a y(n) =1 18 z -1 t z -1 t x(n-1) b 1 a 1 y(n-1) z -1 t t z -1 x(n-2) b 2 a 2 y(n-2) z -1 t z -1 t x(n-m) b M a N y(n-n)
Finite impulse response (FIR) filter - example 19 x(n) b =.5 LP: y n.5xn.5xn 1 x(n-1) z -1 t b 1 =.5 HP: y n.5xn.5xn 1 BP:?
Infinite response filter (IIR) - example 2 y n a yn 1 xn 1 Feedback loop x(n) y(n) a 1 y(n-1) a1 y(n-1) t
21 which is equivalent to a difference equation: Difference equation of a digital filter M k N k k n x k b k n y k a N k M k k n y k a k n x k b n y a 1 a[]=1
Difference equation of a digital filter 22 y M n bk xn kak yn k k N k1 If all a(k) coefficients are equal zero, then the difference equation defines a FIR filter and an IIR filter otherwise.
Finite response filter (FIR) - example 23 x(n) b =.5 LP: y b b 1 n.5xn.5xn 1 x(n-1) z -1 t b 1 =.5 HP: y b b 1 n.5xn.5xn 1 BP:?
Finite response filter (FIR) low pass filter 24 1 Impulse response.5 h L [.5.5] 5 1 15 2 25 3 35 4 45 5 1 Transfer function.5 H L =FFT(h L ) 5 1 15 2 25 3 35 4 45 5 N/2+1 f s /2
Finite response filter (FIR) high pass filter 25 1 Impulse response h H [.5.5] -1 1 5 1 15 2 25 3 35 4 45 5 Transfer function.5 H H =FFT(h H ) 5 1 15 2 25 3 35 4 45 5 N/2+1 f s /2
Filters in a cascade connection 26 x(n) h L h H y(n) x(n) h B y(n) h B =h L *h H h B =h L *h H H B ()= H L ()H H ()
Finite response filter (FIR) band pass filter 27.5 Impulse response h B [.25.25] -.5 1 5 1 15 2 25 3 35 4 45 5 Transfer function.5 H B =FFT(h B ) 5 1 15 2 25 3 35 4 45 5 N/2+1 f s /2
Simple FIR filter example 28 Moving average filter equation is given: y 1 5 n xn 4 xn 3 xn 2 xn 1 xn Determine the vectors of coefficients a and b for this filter. Solution (simple low pass FIR filter): a=[1]; b=[.2.2.2.2.2];
Simple FIR filter example 29 What is the impulse response of this filter: y 1 5 n xn 4 xn 3 xn 2 xn 1 xn Answer: h=[.2.2.2.2.2]; Important conclusion: For FIR filters the filter coefficients are equal to filter s impulse response
radiany Amplituda Simple FIR filter example 3 3 Phase characteristic Charakterystyka fazowa 1 Amplitude characteristic Charakterystyka amplitudowa 2 1.8.6 a zero of the filter -1.4-2.2-3 2 4 6 8 1 f [Hz].2 2 4 6 8 1 f [Hz] Impuse response of the filter.15.1.5 5 1 15 2
Simple FIR filter example 31 Exercise (cont.): Observe the amplitudes and phase shifts of the output characteristics of the filter for the following inputs: sinusoid with f=1 Hz sinusoid with f=5 Hz sinusoid with f=2 Hz Confirm that filtering (convolution) in time domain is equivalent to multiplication of spectrum of the impulse response of the filter with the spectrum of the signal.
Simple FIR filter example 32 1 1 Hz.8.6.4.2 -.2 -.4 -.6 -.8-1.1.2.3.4.5.6.7.8.9 1
Simple FIR filter example 33 1 5 Hz.8.6.4.2 -.2 -.4 -.6 -.8-1.1.2.3.4.5.6.7.8.9 1
Simple FIR filter example 34 1 2 Hz.8.6.4.2 -.2 -.4 -.6 -.8-1.1.2.3.4.5.6.7.8.9 1
Simple FIR filter example 35 2 input signal 1.5 1.5 -.5-1 -1.5-2.1.2.3.4.5.6.7.8.9 1
Linear phase condition for FIR filters 36 FIR filters may be designed so that their phase characteristic is linear. For this purpose the symmetry condition for the filter coefficients is to be fulfilled. hm k hk for k,1,, M hm k hk for odd or even M! What is the advantage of the linear filter phase characteristic? The delay of the signal on the output is independent on its frequency.
Linear phase constant delay of all frequencies 37 /4 phase delay s(t)=sin(t) t d time delay s(t)=sin(2t) /2 phase delay For linear phase filters all frequencies are delayed by the same time interval!
Linear phase condition for FIR filters 38 hm k hk hm k hk for k,1,, M discrete time discrete time
Wyj Wyj Phase distortion 39 x we sin 1t sin2t x wy sin1t 2 sin 2t 2 2 2 1.5 1.5 1 1.5.5 -.5-1 -.5-1.5-1 -2.1.2.3.4.5.6.7.8.9 1 [sek] -1.5.1.2.3.4.5.6.7.8.9 1 [sek] Nonlinear phase distortion (eg. significant distortion of the acoustic signal)
Phase (degrees) Magnitude Response (db) Phase distortion - example 4 3 2 1-1.1.2.3.4.5.6.7.8.9 1 Normalized frequency (Nyquist == 1) -2-4 -6-8.1.2.3.4.5.6.7.8.9 1 Normalized frequency (Nyquist == 1)
Other FIR filter examples 41 Exercise cont.: Determine the characteristics of the filters of the following impulse response: h=.25*[1 2 1], so called von Hann filter (or Gaussian filter) h=[1-2 1], ~ second derivative of the signal
FIR filter design from scipy.signal import firwin 42 Where f is a normalised frequency f=<,1>, where 1 corresponds to fs/2
FIR filter design - example 43 M=4 no. of taps (filter order) f off =.7*fs/2 3dB fs/2 fs
IIR filter design - example 44 -db -> Butterworth filter len(coeff[])=16 len(coeff[1])=17-3db -> fs/2-6db ->
Filter implementation 45 a[]=1 45
IIR and FIR filters comparison 46 FIR Stable (from definition) Simple design condition for linear phase easy to satisfy Steep characteristic possible for very high orders of the filter Finite precision of filter coefficients is not a significant problem IIR Can be unstable Complex design Nonlinear phase Very steep characteristic possible for low orders of the filter Problems with implementation due to finite precision of filter coefficients.
Adaptative filters 47 Successive signal samples x = 1 x(n)... x(n-k) x(n-p) w w 1 w P-1 w (n) y(n) d(n) Target function: E[d(n) w T x] = [(d(n) - y(n)) 2 ] = E[ 2 ] min
Adaptative noise reduction 48 signal source noise source s(t) = x(t) + v(t) n(t) (so called reference input) adaptative filter + w S _ v(t) ^ weight adaptation rule t e e(t) = ^ x(t) t
Adaptative noise reduction 49 Minimal e(t) corresponds to the most effective (according to the minimum mean square error) noise reduction: e( t) s( t) vˆ( t) x( t) v( t) vˆ( t) E[ e 2 ] E[ x 2 ] 2E[ x( v vˆ)] E[( v vˆ) 2 ] E[ x 2 ] = signal and noise are not correlated
Adaptative noise reduction - application 5 After cancelling mathernal ECG Source: Widrow, B. ; Glover, J.R., Jr. ; McCool, J.M. ; Kaunitz, J. ;Williams, C.S. ; Hearn, R.H. ; Zeidler, J.R. ; Eugene Dong, Jr. ;Goodlin, R.C., Adaptive noise cancelling: Principles and applications, Proceedings of the IEEE Volume: 63, Issue: 12, 1975
Adaptative filtering application 51 Adaptative filters are mainly applied to filtering of nonstationary signals, eg: In reduction of noise from the mains network and from electrical surgical instruments (f~12 Hz) In reduction of the energy of the ECG signal of a mother during registration of ECG signal of a fetus As a prediction model of biological signals in detection of their disturbances (eg. Ventricular fibrillation detection implantation of defibrillators)
Synchronous averaging of the signal 52 Lowpass filters are not effective for smoothing the signals in which the noise frequency band overlaps the significant frequency components of the signal. x t st nt A(f) signal A(f) signal S noise N Frequency spectra of the signal and noise f S N noise f
Synchronous averaging of the signal Idea of synchronious averaging 53 Synchronizing signal
Synchronous averaging of the signal 54 Synchronious averaging of the signal is efficient under the following conditions: deterministic components of the signal should occur periodically (not necessarily at regularly spaced intervals) distrubance signal should be a random signal, uncorrelated with the deterministic components of the signal. there should be a possibility to detect signal features necessary for synchronization of the successive cycles.
Synchronous averaging of the signal xˆ 1 N N n 1 x n 55 x 1 x 2 x 3 x N x ^
Synchronous averaging of the signal 56 Standard deviation of the signal: Standard deviation of noise: s n Signal to noise ratio: After N averagings: SNR N N s n SNR s 1 2 1 1 n SNR impovement after N averagings: N 1 1 2 3 4 5
Synchronous averaging of the signal 57 Applications: sub-noise signal detection ( s << n ) (telecommunications) EEG electric evoked potentials analysis, ie. Analysis of potentials of the several microvolts amplitude, generated within the brain due to periodic stimulation by: light (visual evoked potentials), sound (auditory evoked potentials) or touch (touch-evoked potentials).
Touch-evoked potentials 58 M. F. El-Bab, COGNITIVE EVENT RELATED POTENTIALS DURING A LEARNING TASK, PhD, University of Southampton, UK.
Median filtering 59 Median the middle element of the orderly sequence, eg.: x(n)={1, 5, -7, 11, -25, 3,, 11, 7} Sequence sorting: x s (n)={-25, -7,, 1, 3, 5, 7, 11, 11 } Middle element
Median filtering of signals 6 sorting M=2m+1=5 Discrete time M=5
Median filtering of signals 61 x n med 3 (x n ) 2 5-1 7 3-15 9 1 2 6-9 -1 12 25 7 Direction of median mask movement 2 2 5 3???? 6 6?
Median filtering - example 62 4 39 38 37 36 x(t) y=med(x) 35 34 33 32 M=7 31 2 4 645 4 8 1 12 14 16 35 3 25 2 y=x-med(x) 15 1 5-5 2 4 6 8 1 12 14 16
Digital filters - summary 63 1. Idea of filtering 2. Frequency characteristic of a filter 3. Ideal filters 4. Implementable filters 5. Difference equation 6. FIR and IIR filters 7. Linear phase and phase distortion 8. Filter design and signal filtering 9. Adaptative filtering 1. Median filtering (nonlinear filtering)
SIGNAL PROCESSING Prezentacja multimedialna współfinansowana przez Unię Europejską w ramach Europejskiego Funduszu Społecznego w projekcie pt. Innowacyjna dydaktyka bez ograniczeń - zintegrowany rozwój Politechniki Łódzkiej - zarządzanie Uczelnią, nowoczesna oferta edukacyjna i wzmacniania zdolności do zatrudniania osób niepełnosprawnych Politechnika Łódzka, ul. Żeromskiego 116, 9-924 Łódź, tel. (42) 631 28 83 www.kapitalludzki.p.lodz.pl