• Ei tuloksia

4 EEG ANALYSIS METHODS

4.2 Wavelet transform

In the following, an overview of wavelets and the wavelet transform (WT) is given, with some more general background information. The discrete wavelet transform (DWT) is considered in a relation to the multiresolution analysis (MRA) as from this viewpoint DWT

provides a very prominent tool for the EEG analysis. For the more detailed information and for the rigorous mathematical details and proofs, the interested reader may refer to e.g. Haddad and Akansu (2000), S. Mallat and Peyre (2008) and S. G. Mallat (1989).

While regular Fourier transform (FT) has an excellent frequency resolution, it totally lacks the temporal resolution. Thus FT is an inappropriate tool for analysing non-stationary signals, if it is of importance to timely localize the frequencies in the signal. Short time Fourier transform (STFT) applies a windowing technique that effectively divides the sig-nal in shorter segments and thus enables time-frequency localization with the resolution depending on the window length. However, one shortcoming of STFT is that the window has fixed length, that is, the resolution is the same for all frequencies. WT provides an alternative for STFT. The basis functions of WT, called wavelets, have finite support, in contrast to the basis functions of FT, sine and cosine functions, that have infinite support.

The fundamental difference of WT in comparison to STFT is that WT uses windows, or wavelets, of variable length, i.e. short windows for high frequencies and long windows for low frequencies.

Heisenberg inequality states an universal physical dependency between the time and frequency resolution:

∆t∆f ≥ 1

4π. (4.15)

That is, it is not possible to have an arbitrarily high resolution simultaneously for both the time and frequency, but the higher the time resolution is, the lower the frequency resolution, and vice versa. Time-frequency resolution for STFT and WT is illustrated in Figure 4.5. As it can be seen, for STFT the resolution remains constant for both the frequency and time, whereas for WT the resolution is adaptive, that is, higher frequency resolution and lower time resolution for low frequencies, and lower frequency resolution and higher time resolution for high frequencies. This kind of adaptive nature of WT is best suitable for analysing signals that have short bursts of high frequencies and low frequencies of longer duration, which actually quite often is the case for practical signals, like EEG.

Figure 4.5. Time-frequency resolution for STFT (left) and WT (right). Adapted from (Graps 1995).

Wavelet family is defined as follows:

ψab(t) = 1

√aψ(t−b

a ), (4.16)

whereψ(·)is called themother wavelet from which child wavelets are generated by scal-ing (by parametera) and shifting (by parameterb).

Wavelet functions have to satisfy the admissibility condition, that is:

∫︂ 0

|Ψ(Ω)|2

Ω dΩ<∞, (4.17)

whereΨ(Ω)is the FT of the wavelet functionψ(t).

Some common wavelet functions are illustrated in Figure 4.6.

Figure 4.6. Examples of some common wavelet functions (Haar, Morlet and Mexican hat wavelet).

Continuous wavelet transform (CWT) for a continuous function, or signal, x(t) is then defined as follows:

W(a, b) =

∫︂

−∞

ψab(t)x(t)dt . (4.18)

Alternatively the more compact notation can be used:

W(a, b) =< ψab, x > . (4.19) By varying the scaling and shifting parameters throughout their respective domains, CWT yields WT coefficients to fill the whole time-frequency plane. An illustrated example of CWT is given in Figure 4.7.

However, CWT is not that practical signal analysis tool as it is highly redundant as both the scaling and shifting parameters are continuous and thus the wavelets at the same

Figure 4.7. Wavelet transform W(a, b) =< ψab, x > computed with a Mexican hat wavelet. Black, grey and white points correspond, respectively, to positive, zero and negative wavelet coefficients. Adapted from (S. Mallat and Peyre 2008).

scale and between the scales are significantly overlapping.

DWT provides a powerful tool for the MRA of signals. MRA is based on the signal ap-proximations at different resolutions. The approximation of the signal x(t) at resolution 2−m is defined as an orthogonal projection ofx(t)on the subspaceVm ⊂L2(R). These subspaces{Vm |m∈Z}have to satisfy the following properties:

V⊂...⊂V1⊂V0⊂V−1⊂...⊂V−∞ (4.20)

⋂︂

m∈Z

Vm=∅, ⋃︂

m∈Z

Vm=L2(R) (4.21)

x(t)∈Vm ⇔x(t−2mk)∈Vm, m, k∈Z (4.22)

x(t)∈Vm⇔x(2t)∈Vm−1, m∈Z (4.23) and that there also exists scaling functionφ(t)∈V0, such that

mn(t) = 2−m/2φ(2−mt−n)}, m, n∈Z (4.24)

is an orthonormal basis forVm, that is:

< φmk, φml >=δ(k−l), (4.25) whereδ(·)is Kronecker delta function.

Based on (4.20), (4.23) and (4.24) the following holds for the scaling functionφ(t):

φ(t) = 2∑︂

n

h0(n)φ(2t−n), (4.26)

where the coefficients h0(n), known as the interscale basis coefficients, define the scal-ing functionφ(t). The equation (4.26) can be called either the refinement equation, the dilation equation or the multiresolution analysis equation.

LetWmbe a complementary subspace forVm, such that:

Vm−1 =Vm⊕Wm

Vm ⊥Wm

(4.27)

From (4.27) and (4.21) it follows that:

⋃︂

m∈Z

Wm =L2(R) (4.28)

It can be assumed that there exists functionψ(t)∈W0, such that

mn(t) = 2−m/2ψ(2−mt−n)}, m, n∈Z (4.29) is an orthonormal wavelet basis forWm.

The wavelet function can be expressed as linear combination of the translates of φ(2t), in the similar manner as the equation (4.26) for the scaling function:

ψ(t) = 2∑︂

n

h1(n)φ(2t−n). (4.30)

Orthogonal wavelet transform forx(t)is now defined as:

d(m, n) =< x, ψmn> . (4.31)

and orthogonal scaling transform forx(t)is defined as:

c(m, n) =< x, φmn> . (4.32) Signalx(t)∈V0 can be presented, or reconstructed, as linear combination of its orthog-onal projections:

That is, x(t)is presented as approximation at scale Lcomplemented with the sum of L detail components at different resolutions.

Detail coefficients (4.31) and approximation coefficients (4.32) at different scales, or res-olutions, can be obtained via dyadic half-band filter bank implementation, with downsam-pling at each stage. In MRA terms, when a sampled signalx(t)is fed to the filter bank, a coarser approximation and respective details of the signal are obtained at each level, that is, effectively a signal decomposition, or MRA, is carried out. The filter bank imple-mentation for MRA is illustrated in Figure 4.8.

Figure 4.8. Dyadic analysis filter bank implementation of DWT.

The filter coefficientsh˜0 for the low-pass filter, andh˜1 for the high-pass filter are derived from those coefficients that define the scaling function and the wavelet function in (4.26) and (4.30), respectively, such that h˜i(n)=ˆ︁hi(−n). The latter holds as analysis filters in this construction are anticausal.

The signal can be reconstructed from the signal decompositions via dyadic synthesis filter bank with upsampling at each stage, as illustrated in Figure 4.9. The filter coefficientsh0

for the low-pass filter, and h1 for the high-pass filter are those that define the scaling function and the wavelet function in (4.26) and (4.30), respectively.

Figure 4.9. Dyadic synthesis filter bank implementation.

The more detailed description for the filter bank implementation can be found in Haddad and Akansu (2000).

As an example of the DWT based MRA, the signal decomposition for a segment of the EEG signal measured from the C3 channel is illustrated in Figure 4.10. The sampling rate for the EEG signal is 500 Hz.

Figure 4.10. DWT based decomposition for EEG signal (with Haar wavelet).

In the EEG signal, presented in Figure 4.10, there are clearly visible spikes, or artefacts, that are caused by ECG. MRA provides tools for cleaning these artefacts efficiently and, importantly, without removing the underlying EEG signal. This can be accomplished by thresholding the detail components and then reconstructing the signal from the thresh-olded details and the approximation, as per equation (4.33). The EEG signal before and after the ECG artefact removal is shown in Figure 4.11. Artefact removal is one of the most prominent applications of MRA in the EEG analysis.

Figure 4.11. The original EEG signal (blue) and the cleaned and reconstructed EEG signal (red).

4.3 Coherence

Coherence is a statistic that indicates whether two signals are linearly related. As dis-cussed already earlier, it basically measures the synchronization between the signals based on the phase difference.

The magnitude squared coherence (MSC) is defined as follows:

γxy2 (ω) = |Sxy(ω)|2

Sxx(ω)Syy(ω), (4.34)

whereω is the angular frequency, Sxx(ω) and Syy(ω) are the autospectra of the signals x and y, respectively, and that are calculated similarly as (4.5). Sxy(ω) is the cross-spectrum between the signalsxandy, defined in the similar manner as (4.5):

Sxy(ω) =

∑︂

k=−∞

rxy(k)e−jωk, (4.35)

whererxy is cross-correlation function, given as follows:

rxy(k) =E[x(t)y(t−k)]. (4.36) MSC gives a value between 0 and 1. The value close to 1 indicates that the signals are strongly synchronized, whereas the value close to 0 indicates that the signals are desynchronized.