spectral_analysis_of_eeg_signal

spectrogramm_with_morlet_wavelet()[source]

Spectogramm by doing a convolution between the raw signal and complex morlet wavelet:

Method:

Create multiple complex morlet wavelet from different frequency. The frequency range of the morlet wavelets correspond to the frequency axis of the spectogramm.

Example:

EEG raw signal

_images/eeg_signal_for_spetogramm.png
  1. Create complex morlet wavelet

    • Example of one complex molet wavelet (one for the range of the frequency)

    _images/complex_wavelet_morvelet.png
    • All the morlet wavelet shape/amplitude represented on a colormap

    _images/time_frequency_morlet_wavelet.png
  2. Convolutions

    The most efficient way is to loop on the different complex morlet wavelet and multiply fft(raw_signal) with fft(complex_morlet_wavelet[i])

  3. Plot Spectogramm

_images/spectrogramm_morlet_wavelet.png
Comparison Spectrogramm with Morlet Wavelet vs FFT:
  • scipy.signal.spectrogram(data, fs) (FFT-based Spectrogram):

    Method: Utilizes the Fast Fourier Transform (FFT) to compute the frequency content of the signal.

    Features: The spectrogram generated by this method has a fixed frequency resolution and a time resolution based on the size of the temporal window used.

    Advantages: It is a fast and efficient method to obtain a time-frequency representation of the signal, suitable for relatively stationary signals.

    Disadvantages: Less suitable for non-stationary signals or short-duration events.

  • Time-Frequency Analysis with Morlet Wavelet Transform:

    Method: Uses a family of Morlet wavelets to compute the frequency contribution at different temporal moments.

    Features: Offers variable time and frequency resolution, which is particularly useful for non-stationary signals. It can better adapt to frequency variations in the signal over time.

    Advantages: Suitable for non-stationary signals, provides representation with better temporal localization for short-duration events.

    Disadvantages: May be computationally more intensive than the FFT method.

In summary, the choice between these two approaches depends on the type of signal you are analyzing and your specific goals. If your signal is relatively stationary and you need a quick analysis, the FFT method may be appropriate. On the other hand, if your signal is non-stationary with significant frequency variations, the Morlet wavelet transform may be more suitable despite potentially higher computational complexity.

welch_example()[source]

Spectral analysis of an EEG signal using welch method

Welch method:

Cut the signal in n window and compute fft on each of them.

Imagine a time-domain signal represented as a sinusoidal wave. At the core of the Welch method, you divide this signal into partially overlapping segments. For each segment, you apply a window to mitigate edge effects. T hen, instead of taking the FFT of the entire signal, you take the FFT of each modified segment and average them.

The idea is that this overlapping approach reduces the variance of the estimation, which can be particularly useful when the signal changes over time.

Advantage over fft:

More adapt if signal characteristics change over time. E.g Noise increase/ decrease/ change of shape over time.

Example:

_images/EEG_signal.png _images/welch_versus_fft.png