# Wavelet analysis of EEG

I want to do a time-frequency analysis of an EEG signal. I found the GSL wavelet function for computing wavelet coefficients. How can I extract actual frequency bands (e.g. 8 - 12 Hz) from that coefficients? The GSL manual says:

For the forward transform, the elements of the original array are replaced by the discrete wavelet transform $f_i \rightarrow w_{j,k}$ in a packed triangular storage layout, where $j$ is the index of the level $j = 0, \ldots, J-1$ and $K$ is the index of the coefficient within each level, $k = 0 ... (2^j)-1$. The total number of levels is $J = \log_2(n)$. The output data has the following form, $(s_{-1,0}, d_{0,0}, d_{1,0}, d_{1,1}, d_{2,0}, \ldots, d_{j,k}, \ldots, d_{J-1,2^{J-1}-1})$

If I understand that right an output array data[] contains at position 1 (e.g. data[1]) the amplitude of the frequency band 2^0 = 1 Hz, and

data[2] = 2^1 Hz
data[3] = 2^1 Hz
data[4] = 2^2 Hz


until

data[7] = 2^2 Hz
data[8] = 2^3 Hz


and so on ...

That means I have only the amplitudes for the frequencies 1 Hz, 2 Hz, 4 Hz, 8 Hz, 16 Hz,...
How can I get for example the amplitude of a frequency component oscillating at 5.3 Hz?
How can I get the amplitude of a whole frequency range, e.g. the amplitude of 8 - 13 Hz?

Two options:

• One way to get the amplitude at an arbitrary frequency (say 5.3 Hz) would be to resample the signal at a sampling rate such that the base frequency calculated by the wavelet transform would be 5.3 Hz (instead of 1.0 Hz).

• A more appropriate way for a frequency range (say the 8-13 Hz alpha rhythm) is to discard the wavelet transform, filter the signal in this range with a band-pass filter (say a Butterworth filter), apply the Hilbert Transform, and calculate the analytic signal amplitude.

In MATLAB, the latter option would correspond to:

[b a] = butter(2,[8 13]/(sampling_freq/2));
eeg_filtered = filter(b,a,eeg);
eeg_amp = abs(hilbert(eeg_filtered));

• Especially since you are interested in time-frequency analysis, be careful about the filter you use. You might consider a symmetric FIR filter as an alternative to the Butterworth, which has a terribly nonlinear phase response. Another option is to run the data through the BW filter and take the output, reverse it and run it through the filter again. This will remove the phase nonlinearity. It will also sharpen the cutoff frequencies since you've filtered twice. So you may need to adjust for that, too. In either case, you'll need enough data for any transient response to get worked out... Jun 29 '11 at 12:10
• ...before (and after) the actual data of interest is filtered. Jun 29 '11 at 12:11