37
Dr. Gari D. Clifford, University Lecturer & Director, Centre for Doctoral Training in Healthcare Innovation, Institute of Biomedical Engineering, University of Oxford Introduction to time-frequency analysis Centre for Doctoral Training in Healthcare Innovation

Introduction to time-frequency analysis

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to time-frequency analysis

Dr. Gari D. Clifford, University Lecturer & Director, Centre for Doctoral Training in Healthcare Innovation, Institute of Biomedical Engineering, University of Oxford

Introduction to time-frequency analysis

Centre for Doctoral Training in Healthcare Innovation

Page 2: Introduction to time-frequency analysis

Physiological signals are dynamic; they exhibit time-varying statistics in both the time and frequency domain. weak-sense (or wide-sense stationarity or covariance stationarity)

- mean and variance do not change significantly over a given window

Strong/strictly stationary process - joint probability distribution does not change significantly when shifted in time or space. Higher order moments don’t change.

Fourier analysis assumes weak stationarity What if the signal is not stationary?

Physiological signals also exhibit activity that spans a range of time scales: E.g. The ECG signal contain three components with different time-scales:

atrial depolarization represented by the P wave has a duration of 0.1 to 0.15 seconds;

ventricular depolarization represented by the QRS complex 0.1 s;

ventricular repolarization - T-wave 0.2 to 0.4 seconds.

Page 3: Introduction to time-frequency analysis

The inter-beat timing (average=heart rate), changes over much longer

time scales; from minutes to hours, to days. Short term variations (1-10’s of s) - changes in the sympathetic (fight-and-

flight) and parasympathetic (rest-and-digest) activity of the central nervous system acting on the heart.

Longer term variations can be partially attributed to changes in activity and intrinsic circadian controls (that lead to sleep for example).

Page 4: Introduction to time-frequency analysis

Parametric: Runs test (Bendat and Piersol 1986):

▪ Divide the series into time intervals of equal lengths.

▪ Compute a mean value (or other, see below) for each interval.

▪ Count the number of runs of mean values above and below the median value of the series.

▪ Compare the number of counts found to known probabilities of runs for random data and compare to look-up table.

Non-parametric Sample auto-correlation function will neither cut off nor die down

quickly, but rather will die down extremely slowly.

(Bowerman and O'Connell 1979)

Page 5: Introduction to time-frequency analysis

Remove the mean or slope Remove a more complex shape – parabolic fitting

Dangerous – but sometimes works! a(1)=rand(1,1); for(i=1:1000); a(i+1)=randn(1,1)+a(i); end b = detrend(a,'linear',[10:10:1000]);

Page 6: Introduction to time-frequency analysis

Sum of sinusoids Up-Chirp n=1 (linear)

Page 7: Introduction to time-frequency analysis
Page 8: Introduction to time-frequency analysis
Page 9: Introduction to time-frequency analysis
Page 10: Introduction to time-frequency analysis

Assumes stationarity!

A sum of const frequency sinusoids

So what can we do?

Make shorter windows?

Page 11: Introduction to time-frequency analysis

Short Term Fourier Transform

Page 12: Introduction to time-frequency analysis

spectrogram(chirp,window,noverlap,[0:.1:1.2]',Fs)

n=1 (linear) n=2 (quadratic)

Page 13: Introduction to time-frequency analysis

[S,F,T,P]=spectrogram(data,WINDOW,NOVERLAP,Fvect,Fs);

Page 14: Introduction to time-frequency analysis

[S,F,T,P]=spectrogram(data,WINDOW,NOVERLAP,Fvect,Fs);

Page 15: Introduction to time-frequency analysis

waterfall(P’)

Page 16: Introduction to time-frequency analysis

A short analysis window results in good temporal resolution and poor spectral resolution.

As the analysis

window length increases its frequency resolution increases and its temporal resolution decreases.

Page 17: Introduction to time-frequency analysis

The window w(t) determines the spectral and temporal resolution of the Short-Time Fourier Transform.

Temporal resolution refers to the smallest time-separation below which two temporal events cannot be distinguished on the Spectrogram.

Similarly, spectral resolution refers to the smallest frequency-separation below which two spectral events cannot be distinguished on the Spectrogram.

A long window w(t) results in poor temporal resolution and good frequency resolution.

Conversely, a short window w(t) results in good temporal resolution and poor spectral resolution.

Time and frequency resolution can only be traded for one another, they cannot both be improved simultaneously.

Page 18: Introduction to time-frequency analysis

The STFT limits our knowledge of signal activity to a two-dimensional cell in the time-frequency plane.

The dimensions of the cell can be changed to favor either spectral or temporal resolution. The same temporal and spectral resolution applies to low and high frequency activity.

Page 19: Introduction to time-frequency analysis

Compare high temporal & high frequency resolution

Page 20: Introduction to time-frequency analysis

Slow wave (1/4s) with periodic (~100 ms) spike

With STFT you can either resolve the location of the spikes or their frequency (4&10Hz)

Page 21: Introduction to time-frequency analysis

Is there a way to have good temporal and frequency resolution?

Page 22: Introduction to time-frequency analysis

A wavelet ψ (t) is shifted by a time τ and dilated or contracted by a factor a (the scale) prior to computing its correlation with the signal x(t).

The correlation between the signal and the wavelet is defined as the integral of their product.

The CWT maps x(t) into a bivariate function C(a,τ) that can be used to determine the similarity between x(t) and a wavelet scaled by a at given time.

The correlation is localized in time, it is computed over an interval beginning at t = τ and ending t = τ + L where L is the duration of the wavelet.

A time plot of the correlation C(a,τ) between the signal and the scaled wavelets is called a Scalogram.

(Compare with spectrogram – scale is the inverse of frequency)

c.f. FT:

Page 23: Introduction to time-frequency analysis

Wavelet ψ (t) is shifted by a time τ and dilated or contracted by a factor a (the scale) prior to computing its correlation with the signal x(t).

Coefficients of C(a,τ) represent the strength

of the correlation at each scale at each point in time.

Page 24: Introduction to time-frequency analysis

BUT - CWT automatically adjusts its time and frequency resolution depending on the scale of activity of interest by dilating or contracting the analysis window

Page 25: Introduction to time-frequency analysis

Sinusoid With Frequency Breakdown

STFT CWT

Page 26: Introduction to time-frequency analysis

CWT of Sinusoid With Linearly Increasing Frequency

(n=1)

Page 27: Introduction to time-frequency analysis

The continuous wavelet transform (CWT) is a generalization of the STFT

Allows for the analysis of non-stationary signals at multiple scales.

Similar to the STFT, the CWT makes use of an analysis window to extract signal segments;

Window is called a wavelet (or mother wavelet).

Unlike the STFT, the analysis window or wavelet is not only convolved (translated), but dilated and contracted depending on the scale of activity under study.

Wavelet dilation increases the CWT's sensitivity to long time-scale events

Wavelet contraction increases its sensitivity to short time-scale events.

Page 28: Introduction to time-frequency analysis

In Matlab, type waveinfo('bior') etc

Page 29: Introduction to time-frequency analysis
Page 30: Introduction to time-frequency analysis

Similar to Fourier basis functions

Dilations and translations of the Mother function or “analyzing wavelet” define our

wavelet basis

These basis functions are orthogonal – the correlation between different functions is zero

Therefore we assume independence between the components

They provide redundancy – and therefore error correction (1D →2D)

They provide compact support – function is zero wherever it is not defined, vanishing at ∞

When zero distortion (e.g. clipping) and anti-alias conditions are satisfied, perfect reconstruction is possible

Basis functions are restricted in frequency – as we will now see when we consider the discrete wavelet transform

Aside – we do not require windowing: why?

Page 31: Introduction to time-frequency analysis

The DWT can be viewed as a Filterbank

STFT is an M-channel filterbank

M parallel filters all with equal bandwidths but different center frequencies

Page 32: Introduction to time-frequency analysis

This filterbank architecture can be used to compute the coefficients of the continuous wavelet transform

The coefficients are only computed over the dyadic scale (following a geometric sequence of ratio 2)

Split into ‘details’ and ‘approximations’ at each stage

H = filter transfer function

a = approximations

(not the scale here!)

d = details

Page 33: Introduction to time-frequency analysis

[lpdecon; hpdecon; lprecon; hprecon] = wfilters(‘bior4.4’);

We can reconstruct original signal form all details and approximations

Page 34: Introduction to time-frequency analysis

Four details and one approximation. Approximation is low freq trend

Page 35: Introduction to time-frequency analysis

ECG with mains

noise

ECG without mains

noise

With FIR filtering (&

ringing)

After wavelet

filtering

Page 36: Introduction to time-frequency analysis

Wavelet ridges:

Wavelet modulus maxima:

Page 37: Introduction to time-frequency analysis

Feature detection (ECG QT interval, spikes in EEG)

Denoising

Compression

Trend extraction

Further reading: Wavelet transforms and the ECG: a review Paul S Addison 2005 Physiol. Meas. 26 R155