outline - kmuttwebstaff.kmutt.ac.th/~sarawan.won/biosignal/biosignal2008.pdf · some matlab tools...

26
Introduction to Biosignal Processing Outline Overview of Signals Measurement Systems -Filtering -Acquisition Systems (Quantisation and Sampling) Digital Filtering Design Frequency Domain Characterisations - Fourier Analysis - Power Spectral Density Analysis Time-Frequency Analysis - Spectrogram

Upload: nguyennhi

Post on 11-Mar-2018

229 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

OutlineOverview of Signals

Measurement Systems

-Filtering-Acquisition Systems (Quantisation and Sampling)

Digital Filtering Design

Frequency Domain Characterisations

- Fourier Analysis- Power Spectral Density Analysis

Time-Frequency Analysis

- Spectrogram

Page 2: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

What is a signal ?

Physical quantity, varying as a function of an independent variable, which carries information

Introduction to Biosignal Processing

Examples of Biomedical Signals

The electrocardiogram (ECG)

Source: http://medicalimages.allrefer.com/

Page 3: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Examples of Biomedical Signals

The electromyogram (EMG)

Introduction to Biosignal Processing

Examples of Biomedical Signals

The electroencephalogram (EEG)

Page 4: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Applications of Biosignal Processing

Introduction to Biosignal Processing

Uniform (periodic) sampling. Sampling frequency fs = 1/ T

Continuous-Time and Discrete-Time

Continuous Discrete)(tV )(][ ktVkV ≡

Types of Signals

Page 5: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Deterministic and Stochastic

Types of Signals

Deterministic

Stochastic

Introduction to Biosignal Processing

Typical Measurement Systems

Acquisition Signal processing

Information extractionInterpretation

Page 6: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Signal Acquisition System

Signal Conditioning

e.g. - Amplifier- Filter

A/D

Analog-to-digital converter

Sensors/Transducers

Sensors/transducers : to pick-up the physical quantity to an electrical signal

Amplifier : to amplify a small-amplitude electrical signal to range of several volts

Analog filter : to remove high frequencies (anti-aliasing)

A/D converter : to convert continuous signal to a discretised and quantised version

Introduction to Biosignal Processing

FilteringIdeal filters let frequency components over the passband pass through undistorted, while components at the stopband are completely cut off.

Filteru y

Filter Types

Page 7: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

FilteringFilter properties are described in terms of frequency response and graphically in the form of a Bode plot

mmm

m

m

m

nnn

n

n

n

bdtdub

dtudb

dtudba

dtdya

dtyda

dtyd

++++=−−−− −−

−−

11

1

1011

1

1 ......

The Laplace Transform

ωjs =)( ωjH

LTI-Systemu y

Frequency Response Function

Introduction to Biosignal Processing

FilteringBode Plot

10-1

100

101

102

-90

-45

0

Pha

se (d

eg)

Bode Diagram

Frequency (rad/sec)

-50

-40

-30

-20

-10

0

Mag

nitu

de (d

B)

21)(+

ωj

jH

rad/sec 2=uω

o45H(j2)

0.3536)2(

−=∠

=jH

bode(tf(1,[1 2]))

Page 8: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

FilteringFilter Bandwidth

The width of the positive frequency range in which the magnitude response is greater than or equal to 0.707 (3 dB attenuation) of the peak magnitude of a frequency plot

-3 dB

Introduction to Biosignal Processing

Filtering

Filter Order & Sharpness of the roll-off

Source: http://www.freqdev.com/guide/analog.html

Page 9: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Filtering

Analog Filter Implementation

Introduction to Biosignal Processing

Analog-to-Digital (A/D) Conversion

Analog signal

Anti-aliasingFilter

Sampling Quantisation Digital signal

A/D

Page 10: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Analog-to-Digital (A/D) Conversion

0 1 2 3 4 5 6 7 8 9 100

1

2

3

4

5

6

7

8

9

10

Sample

x(t)

Analog signal

Anti-aliasingFilter

Sampling Quantisation Digital signal

A/D

Introduction to Biosignal Processing

Analog-to-Digital (A/D) Conversion

0 1 2 3 4 5 6 7 8 9 100

1

2

3

4

5

6

7

8

9

10

Sample

x(t)

Analog signal

Anti-aliasingFilter

Sampling Quantisation Digital signal

A/D

Page 11: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Analog-to-Digital (A/D) Conversion

0 1 2 3 4 5 6 7 8 9 100

1

2

3

4

5

6

7

8

9

10

Sample

x(t)

Analog signal

Anti-aliasingFilter

Sampling Quantisation Digital signal

A/D

Introduction to Biosignal Processing

Sampling

An analog signal can be exactly recovered from its samples if the signal is sampled at a sampling rate of fs > 2fmax, where fmax is the highest frequencycontained in the signal

Example

)100cos()300sin(10)50cos(3)( ttttx πππ −+=If

what is the minimum sampling rate which guarantees no loss information ?

Sampling Theorem

Page 12: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Sampling

What if fs < fmax Aliasing

A 8 Hz-signal, sampled at 10 Hz, appears as 2 Hz

Introduction to Biosignal Processing

How to Prevent AliasingUse sufficiently high sampling frequency

Place an analog anti-aliasing filter in front of the sampler to reject 2/sFF >

0 0.5 1 1.5 2-1.5

-1

-0.5

0

0.5

1

1.5(a) 1-Hz sine + 60-Hz noise

time (sec)0 0.5 1 1.5 2

-1.5

-1

-0.5

0

0.5

1

1.5(c) prefiltered (a) with ωp = 20 rad/sec

time (sec)

0 0.5 1 1.5 2-1.5

-1

-0.5

0

0.5

1

1.5(b) 28 Hz sampled (a)

time (sec)0 0.5 1 1.5 2

-1.5

-1

-0.5

0

0.5

1

1.5(d) 28 Hz sampled (c)

time (sec)

p

pfilter s

sGω

ω+

=)(

Page 13: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Anti-Aliasing Filter

Avoid designing an anti-aliasingfilter ‘too tight’ against half the sampling frequency

In practice, the cut-off frequency (fc) of the filter may be selected a little above fmax. Then, select sampling rate fs > 3fc

Introduction to Biosignal Processing

Digital Filtering

)(...)1( ...)(...)2()1()(

10

21

mkubkubbnkyakyakyaky

m

n

−++−+++−−−−−−−=

)()(

...1...

)()(

11

110

zAzB

zazazbzbb

zUzY

nn

mm =

++++++

= −−

−−

H(z) - Transfer function

General form

z-transform

Page 14: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Digital Filtering

IIR and FIR filters

Infinite Impulse Response (IIR) filter:Response is a function of both current and past inputs and past outputs

Finite Impulse Response (FIR) filter: Response is a function of current and past inputs only

∑=

−=m

ii ikubky

1

)()(

∑∑==

−+−=m

ii

n

ii ikubikyaky

11

)()()(

Introduction to Biosignal Processing

Digital Filtering

IIR vs FIR filters

Pros Cons

IIR

FIR

Requiring a much lower filter order than FIR filters to achieve a specific frequency criterion

Nonlinear phase characteristics

Always being stableHaving linear phase shifts

less efficient in terms of computer time and memory than IIR because of their nonrecursive nature

Page 15: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Digital Filtering Design

Passband and stopband attenuation

Transition width(s)

ωp – Passband edge frequency

ωs – Stopband edge frequency

Introduction to Biosignal Processing

Some Digital Filters

Source: http://en.wikipedia.org/wiki/Digital_filter

Page 16: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Some MATLAB Tools for filter design

Frequency Response/Filter Analysis: freqz, fvtool

FIR: fir1, fir2, firls, remez

IIR: butter, cheby1, cheby2, ellip, yulewalk

Filter Design & Analysis GUI: fdatool

Introduction to Biosignal Processing

FDATool

Page 17: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Frequency Domain Characterisation

In physiological systems information is often more readily expressed in the frequency domain

Why frequency domain?

Noise and information are often more easily separated in frequency domainthan in time domain

Some algorithms are more efficient when implemented in the frequency domain, e.g. computation of convolution in frequency domain

Introduction to Biosignal Processing

The Fourier Transform (FT) method

Any signal may be presented as a series of sinusoids of different frequencies, each with an amplitude and phase.

Frequency Domain Analysis

Continuous Time Fourier Transform

∫∞

∞−

−⋅= dtetxfX ftj π2)()(

∫∞

∞−

⋅= dfefXtx ftj π

π2)(

21)(

Page 18: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Example

ttttx ⎟⎠⎞

⎜⎝⎛−⎟

⎠⎞

⎜⎝⎛−⎟

⎠⎞

⎜⎝⎛−=

25cos0162.0

23cos0450.0

2cos4052.0)( πππ

0 1 2 3 4 5 6 7 8-0.5

-0.4

-0.3

-0.2

-0.1

0

0.1

0.2

0.3

0.4

0.5

Time (sec)

x(t)

2/π 2/3π 2/5πfrequency (rad/sec)

Mag

nitu

de

Frequency Domain Analysis

Harmonics 1, 3 and 5

Introduction to Biosignal Processing

Example

Frequency Domain Analysis

Source: D. Simpson, Tutorial on Biomedical Signal Processing

EEG signal

Page 19: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Discrete Fourier Transform (DFT)

Frequency Domain Analysis

The frequency spectrum of a signal is numerically computed using its time samples, providing a discrete spectrum

∑−

=

−⋅=

1

0

2

][)(N

n

Nnkj

enxkXπ

∑−

=

⋅=1

0

2

)(1][N

n

Nnkj

ekXN

nxπ

frequencies 1,...,1,0, −=⋅= NkNfkf s

k

In practice, DFTs are computed using a high-speed algorithm, known as the Fast Fourier Transform (FFT)

Introduction to Biosignal Processing

Example: FFT with N=1024, fs=10 Hz

Frequency Domain Analysis

Ts=0.1; %sampling time Tst=[0:499]*Ts; %time vectorx=cos(2*pi*t/10)+0.5*sin(2*pi*t/5); %signal xN=1024; % no. of computational pointsX=abs(fft(x,N)); %magnitude of FFT of xX=X(1:N/2+1);F=[0:N/2]/N/Ts;figure;subplot(211);plot(t,x); xlabel('Time(sec)')subplot(212);plot(F,X); xlabel('Frequency (Hz)'); ylabel('Amplitude')

0 5 10 15 20 25 30 35 40 45 50-2

-1

0

1

2

Time(sec)

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 50

100

200

300

Frequency (Hz)

Am

plitu

de

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.50

50

100

150

200

250

Frequency (Hz)

Am

plitu

de Nff s /=∆

Page 20: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Power Spectral Analysis

Frequency Domain Analysis

Frequency (Hz)

Pow

er/H

z

describes how the power of a signal is distributed with frequency

Parseval’s theorem

dffXdttxE ∫∫∞

∞−

∞−

== 22 )()(

where E – the average energy of x(t)

x[n]offunction ation autocorrel theof )( FTfPx =

Power Spectrum

Introduction to Biosignal Processing

Estimate PS using FFT

Power Spectral Estimation

s

kkx fN

fXfP

⋅=

2)()(ˆ

at x[n]of DFT theis )( kfXwhere

The periodogram method

1,...,1,0, −=⋅= NkNfkf s

k

Page 21: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

WindowingPower Spectral Estimation

Extracting a segment of a signal in time is the same as multiplying the signal with a rectangular window

Source: http://www.ee.ic.ac.uk/pcheung/teaching/ee2_signals/

Introduction to Biosignal Processing

Spectral Leakage

Power Spectral Estimation

Original Signal

Window

WindowedSignal

0 0.1 0.2 0.3 0.4 0.5-90

-80

-70

-60

-50

-40

-30

-20

-10

Frequency (kHz)

Pow

er/fr

eque

ncy

(dB

/Hz)

Sine frequency100 Hz + noise

Page 22: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

How to reduce leakage

Power Spectral Estimation

Sine frequency100 Hz + noise

0 0.1 0.2 0.3 0.4 0.5-90

-80

-70

-60

-50

-40

-30

-20

-10

Frequency (kHz)

Pow

er/fr

eque

ncy

(dB/

Hz)

Using a window type which smoothes the edges of the signal

Modified periodogram methodCommonly used windows:• Hamming windows• Hanning windows• Barlett windows• Blackman windows• Kaiser windows

Introduction to Biosignal Processing

Estimate PS by Welch’s method

Power Spectral Estimation

It reduces noise in the estimated power spectra in exchange for reducing the frequency resolution

Divides the data several segments, possibly overlapping, performs an FFTN each segment, computes the power spectrum, then averages these spectra

Averaging Overlap Averaging

Source: http://www.ave.kth.se/education/msce/TSOVM/courses/SD2130/

Page 23: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

ExamplePower Spectral Estimation

0 50 100 150 200 250 300 350 400 450 500-40

-35

-30

-25

-20

-15

-10

-5

0

5

10

Frequency (Hz)

Pow

er/fr

eque

ncy

(dB

/Hz)

Periodogram Power Spectral Density Estimate

0 50 100 150 200 250 300 350 400 450 500-25

-20

-15

-10

-5

0

5

10

Frequency (Hz)

Pow

er/fr

eque

ncy

(dB

/Hz)

Welch Power Spectral Density Estimate

% Generate datafs = 1000; % Sampling frequencyt = (0:0.3*fs)./fs; % 301 samplesA = [2 8]; % Sinusoid amplitudesf = [150;140]; % Sinusoid frequenciesxn = A*sin(2*pi*f*t) + 5*randn(size(t));

% PeriodogramHs = spectrum.periodogram('rectangular');psd(Hs,xn,'Fs',fs,'NFFT',1024);

% Welch’s spectral estimate for 3 segments with % 50% overlapHs = spectrum.welch('rectangular',150,50);figure;psd(Hs,xn,'Fs',fs,'NFFT',1024);

Introduction to Biosignal Processing

Time-Frequency Analysis

Fourier analysis assumes stationarity of the signal, e.g. its statistical properties do not change

Many signals - particularly those of biological origin - are not stationary.

Extract both time and frequency information from the signal

Page 24: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Short-Term Fourier Transform (STFT) – The Spectrogram

Divide signal into ‘stationary’ segments.

Perform Fourier transform on a window of data that slides along the time axis→ time-frequency function that describes the frequency distribution near time τ

))()((),( ττ −⋅= twtxFTfSTFT

The spectrogram is given by the magnitude of the STFT of the function

{ } 2),()( τfSTFTtxmSpectrogra =

Introduction to Biosignal Processing

Short-Term Fourier Transform (STFT) – The Spectrogram

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

A linear chirp, starting @ DC and crossing 150 Hz at t=1 sec

Page 25: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

Short-Term Fourier Transform (STFT) – The SpectrogramThe time-frequency tradeoff: we cannot simultaneously obtain arbitrarily high resolution along both the time and frequency axes. Shortening the data length (N) to improve time resolution will reduce frequency resolution (≈ fs/N)

Time

Freq

uenc

y

N = 50

0 2 4 6 8 10 12 14 16 180

20

40

60

80

100

120

140

160

180

200

Time

Freq

uenc

y

N = 800

0 2 4 6 8 10 12 14 16 180

20

40

60

80

100

120

140

160

180

200

N=50 N=800

Introduction to Biosignal Processing

MATLAB Code

Ts=0.0025; %Sampling timefs=1/Ts; %sampling frequencyM=5/Ts; %M = Data length over 5 sec

% Generate Datat1=0:Ts:(M-1)*Ts; y=[cos(2*pi*10*t1) cos(2*pi*25*t1) cos(2*pi*50*t1) cos(2*pi*100*t1)]; t=[0:length(y)-1]*Ts; %Time vectornfft=[50 800]; %Window widths

%Plot the spectrogram for window widths of 50 and 800for n=1:2

N=nfft(n); %Tested window width (N)figure; %Call a new figurespecgram(y,N,fs,N,[]); %Plot the spectrogram using current Ntitle(['N = ' num2str(N)]) %Add title

end

Page 26: Outline - KMUTTwebstaff.kmutt.ac.th/~sarawan.won/Biosignal/Biosignal2008.pdf · Some MATLAB Tools for filter ... Filter Design & Analysis GUI: fdatool Introduction to Biosignal

Introduction to Biosignal Processing

More methodsNoise reduction- Optimal filters- Adaptive noise cancellation

Time-Frequency- Wigner-Ville- Wavelets

Signals and Systems- Correlation and coherence- Modelling (black box vs. physiological)

Pattern recognition and classification- Rule-based- Statistical methods- Learning

Introduction to Biosignal Processing

Suggested Reading

Oppenheim, A.V. and Schafer, R.W. Discrete-Time signal Processing. Prentice Hall: Engle-wood Cliffs, NJ, 1989.

Semmlow, J.L. Biosignal and Biomedical Image Processing: MATLAB-Based Applications. CRC, 2004.

Rangayyan, R.M. Biomedical Signal Analysis: A Case-Study Approach. Wiley-IEEE Press, 2001.

Bruce, E.N. Biomedical Signal Processing and Signal Modeling. Wiley-Interscience, 2000.