Biosignal filtering and artifact rejection
Biosignal processing, 521273S
Autumn 2012
Motivation
1) Artifact removal: for example – power line
– non-stationarity due to baseline variation
– muscle or eye movement artifacts in EEG or ECG
– Solution?: epoch rejection due to artifacts
Motivation
2) Enhancement of useful information – bandpass filtering
– finding certain signal waveforms such as eye blinks from EEG or QRS complexes from ECG
– smoothing for illustrative purposes
FIR
• Finite impulse response (FIR) filter
– Stable
– Simple to implement
– Linear phase response • Symmetrical impulse
response
• All frequencies have the same amount of delay – no phase distortion
1
0
)()()(N
k
knxkhny
1
0
)()(N
k
kzkhzH
Source: http://www.netrino.com/Publications/Glossary/Filters.php
FIR structure
FIR
Lowpass filter, order 44 (N=45), positive symmetry. fs=256 Hz, Fp=13 Hz, Rp=4 dB, Fs=19 Hz, Rs=38 dB
0 5 10 15 20 25 30 35 40 45-0.04
-0.02
0
0.02
0.04
0.06
0.08
0.1
0.12
0 20 40 60 80 100 120-800
-600
-400
-200
0
Frequency (Hz)
Phase (
degre
es)
0 20 40 60 80 100 120-100
-50
0
50
Frequency (Hz)
Magnitude (
dB
)
Characteristics: passband, transition band, stopband, ripple, attenuation, sampling frequency
IIR
• Infinite impulse response filters
– Feedback system
– Normally fewer coefficients that with FIR
– Used for sharp cut-off (notch filters for example)
– Can become unstable or performance degrade if not designed with care
– Pole-zero diagram
– Nonlinear phase characteristics causes phase distortion altering harmonic relationhips – frequency components have different time delays (often undesirable)
M
k
k
k
N
k
k
k
M
M
N
N
zb
za
zbzb
zazaazH
1
0
1
1
1
10
1...1
...)(
M
k
k
N
k
k
k
knybknxaknxkhny100
)()()()()(
Source: http://www.triplecorrelation.com/courses/fundsp/iiroverview.pdf
Smoothing: averaging filter
• Average of sliding window of size N samples – FIR filter
1
0
)(1
)(N
k
knxN
ny
Smoothing: Hanning filter
]21[
4
1)( 21 zzzH
Smoothing: Butterworth lowpass filtering
Butterworth lowpass filter
- Select suitable order and cutoff frequency
Synchronized averaging
• Filter noise by averaging several signals containing the same events – Often simple/complex pulses
• Signals must first be time-synchronized
Averaging of flash visual ERP’s from EEG
Notch/comb filter
• Often used for 50/60 Hz power line artifact filtering
• Narrow stop-band in basic and harmonic frequencies
• Be careful with the aliased harmonics
• Can be implemented as FIR or IIR
Ruha et al. (1997)
Notch/comb filter
Filtering result Original signal
Trend removal (detrending)
• High-pass filtering
– time-domain: difference filter
– frequency-domain: DFT
• Trend removal with other methods
– Savitzky-Golay filter
– IPG-FMH (in-place growing – FIR median hybrid)
Difference filtering, version 1
First-order difference operator: T=sampling interval )]1()([
1)( nxnx
Tny
Difference filtering, version 2
Modified first-order difference operator: - T=sampling interval - Additional pole inserted at zero frequency to steepen the transition band
1
1
995.01
11)(
z
z
TzH
)1(995.0)]1()([1
)( nynxnxT
ny
Detrending: Butterworth highpass filter
Select suitable order and cutoff frequency
Savitzky-Golay filter
• S-G filters are called polynomial or least-squares smoothing filters
• Fits a polynomial of given degree optimally to a signal window
• In a sliding time window (frame), a polynomial curve is fitted to signal, and its middle value in the frame is taken as a smoothened value
• Decomposes the signal into a trend signal and residual signal – The trend component can be interpreted as
the useful signal component or the noise component, depending on the application
• Can be realized as a fast FIR filter
0 200 400 600 800 1000 1200 1400 1600 1800 2000-4
-2
0
2
4ORIGINAL
0 200 400 600 800 1000 1200 1400 1600 1800 2000-4
-2
0
2
4POLYNOMIAL ORDER 3, FRAME SIZE 21
0 200 400 600 800 1000 1200 1400 1600 1800 2000-4
-2
0
2
4POLYNOMIAL ORDER 3, FRAME SIZE 41
IPG-FMH • In-place growing FIR-median hybrid filters
(IPG-FMH) are based on median filtering and FIR-filtering – Median filter: takes the median value within a
signal window as filter output value
• Has robust nature against noise
• Pulses longer than root signal are detected reliably, shorter pulses are removed
• Suitable also for trend estimation of signals
• Preserves sharp edges in trend better than linear low-pass filter
• Attenuates wide-band noise effectively
Wichman et al. (1990)
Wiener filtering
• Optimal filter that takes into account statistical characteristics of signal and noise processes
• Noise spectrum S and desired signal spectrum Sd must be known or estimated
)(
)(1
1)(
dS
SW
-
LMS adaptive filtering (least mean square)
• Situation: an interfering signal component is summed to the actual biosignal
• Filter aims to subtract the interfering signal x from the “noisy” biosignal y
• The interference signal x is usually measured independently and simultaneously with another sensor device
• In an ideal situation, the interference signal x is identical to the interference component in y; only the amplitude and sign must be determined before subtraction (one filter weight is enough)
• Sometimes only a correlated version of the interference can be measured; the filter adapts the interference signal shape optimally to the interference signal component that appears in y (many filter weights are needed)
• Be careful with the possible delay between the interference signal and biosignal
1
0
, )(n
i
ikkkkLMS xiwye
ikkLMSikki xeww ,)1( 2
W x e
y (EEG+EOG)
(EEG) (EOG)
-
LMS adaptive filtering (least mean square)
• Based on steepest descent optimization algorithm, where the n filter weights are updated at every sample iteratively according to local gradients on error surface
• Learning rate parameter
– 0 < < 1/lmax
– lmax : largest eigenvalue of data correlation matrix
– should be adaptive if data is nonstationary
• Proper initialization of filter weights is important – E.g., letting the filter adapt for a while
without outputting anything (works on-line)
– E.g., running filter backwards in time to initialize (works off-line)
1
0
, )(n
i
ikkkkLMS xiwye
ikkLMSikki xeww ,)1( 2
W x e
y (EEG+EOG)
(EEG) (EOG)
Example: removing respiration effects from heart rate data
Example: removing ocular artifacts from EEG
1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2
x 104
-150
-100
-50
0
50
100
150
1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2
x 104
-150
-100
-50
0
50
100
150
1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2
x 104
-600
-400
-200
0
200
400
Adaptive filtering of ECG
Selected references
Journal articles on two trend detectors • Wichman R, Astola JT, Heinonen PJ, Neuvo YA (1990) FIR-Median Hybrid Filters with excellent
transient response in noisy conditions. IEEE Trans. Acoust., Speech, Signal Processing 38:2108-2117.
• Original Savitsky-Golay paper: http://pubs.acs.org/cgi-bin/archive.cgi/ancham/1964/36/i08/pdf/ac60214a047.pdf
Books on signal processing basics • Ifeachor EC, Jervis BW. Digital Signal Processing: A Practical Approach. Addison-Wesley,
reprint 1996, pp. 279-287, 375-383, 550-551, 561-563, 697-706.
• Orfanidis, SJ. Introduction to Signal Processing. Prentice-Hall, Englewood Cliffs, NJ, 1996, pp. 434-441.