Hello my name Arnaud Delorme.
And this is part one of a series of videos on time frequency analysis of EEG time series.
This part is about Fourier analysis of EEG signal.
So let's first talk about the biophysics of the EEG signal.
EEG was first discovered by Hans Berger.
In 1924 he defined the EEG alpha rhythm.
Here is a neuron.
On the top are the dendrites and on the bottom is the cell body.
The dendrites integrate electrical signal and transfer it to the cell body.
And this movement of electrical charges along dendrites, generates an electric field.
When we have many of these neurons oriented in the same way and active at the same time,
these electric fields sum up to generate what we call the local field potential, which is
the EEG at the surface of the cortex.
Through volume conduction, this potential may then be recorded at the EEG scalp sensors.
So this is where the EEG comes from.
It comes from synchronized cell excitation of large groups of neurons.
And the synchrony of cell excitation determines the amplitude and rhythm of the EEG signal.
You may have heard of common oscillatory modes of the EEG signal.
This is simulated ideal data, and these are sinusoids at different frequencies.
We typically define the alpha EEG rhythms as a rhythm from 9 to 11 Hertz and then Beta
from 18 to 21 Hertz, gamma from 30 to 60 Hertz.
Then we have lower frequencies with theta from 4 to 7 hertz and delta from 0.5 to 2
Hertz.
These are of course idealized signal and when you look at actual EEG signal, it would look
more like this.
And as you can see, for each frequency of interest there is actually a mixture of different
signals at different frequencies.
So in real EEG, a given frequency is rarely seen in its pure form.
So now we're going to see how we can extract the frequency content of the EEG signal.
And for this, we need to make the assumption that the EEG signal is stationary.
This is not entirely true for EEG signal but is approximately true over short time window.
And by stationary we mean that the first and second moments ? so the mean and the variance
-- of the data distribution does not depend on time.
So, let's look at an example.
Here, we have different stationary sinusoids, one at 2 Hertz, one at 10 Hertz, and one at
20 hertz.
If we simply add these signals, as it is represented on the bottom right corner, you can see that
this signal has complex features.
Yet it is stationary because it is sum of stationary signals.
Now if we want to analyze this signal ? to see what the signal is made out of -- we can
perform a power spectrum.
By looking at the Power spectrum of the signal we can recognize three frequency
components the signal is made of (at 2, 10, and 20Hz).
So in the next slides, we're going to see how to build such a power spectrum.
Fourier stated that any stationary, continuous process can be exactly described by an infinite
sum of sinusoids of different amplitudes and phases.
So let?s first define what we mean by amplitude and phase of sinusoids.
Here is a sinusoid and the amplitude is the height on the y axis and the phase is the
shift of the sinusoid on the X axis.
So here we have a signal in the time domain on your left and a frequency decomposition
of this signal on your right.
We only have one frequency here, but we are going to add some more.
Now, we have 3 frequencies with different phases and amplitudes, and you can see that
as we sum over these frequencies, the original time-domain signal starts to appear.
When we use more frequencies of different phases and amplitudes, we can recover at the
bottom right the original signal.
We can then construct the power spectrum by just looking at the amplitude at different
frequencies.
At this frequency, the amplitude is relatively high, so we have a peak in the power spectrum.
At this other frequency, the amplitude is very low, so we have a through in the power
spectrum.
At this third frequency, the amplitude is high again, so we have another peak in the
power spectrum.
As a side note, the power spectrum is actually not the raw amplitude but the square of the
amplitude at all these frequencies.
So this is how the power spectrum is built and the goal of Fourier analysis is learn
the correct amplitude and phase for each sinusoid such that their sum reconstructs the original
time series.
So a little bit more formally.
We already saw the amplitude and phase shift of a sinusoid.
This is the equation describing this sinusoid.
When dealing with sinusoids, we usually use the angular frequencies which is equal to
2π times the frequency in Hertz.
And this cosine formula is equal to the real part of this complex exponential ? this is
Euler?s formula.
This complex number is called a phasor sometimes represented by S(omega,time).
A phasor may be represented with a vector.
The length of the vector represents the amplitude and the angle of the vector represents the
phase.
You might have seen this other notation from Euler?s formula in which a complex exponential
can be decomposed into a real cosine part and an imaginary sine part.
So let's see an example here.
This is the phasor we just talked about.
As time increases, we can see the phasor rotates and this is the representation of real part
of the phasor ? which means the cosine.
Here is another representation with 3 phasors with the purple being the sum of the red and
blue phasors.
We can see the different phases and amplitudes of these phasors as time increases.
So let?s go back to Fourier?s definition, which states that a signal in time domain
can be described by a sum of sinusoids with different amplitudes and phases.
This is what this equation represents here for a single frequency.
When we apply this formula for a given frequency, we obtain a phasor at that frequency, which
has a specific amplitude and phase (here in red).
The power reflects the covariance between the original signal and a complex sinusoid
at that frequency.
And of course, we also have the inverse Fourier transform, in which we can take we can combine
these phasors across frequency and get back the original time domain signal as I showed
you in one of the first slides.
This slide is to show you how this is calculated in Matlab.
This is a discrete Fourier transform function that takes a column time signal vector as
input.
We loop over frequencies and in the inner loop we apply the formula from the previous
page, by summing over time samples.
You can check, it is the exact same formula.
Note that, for reference, we actually do not need this inner loop.
Using Matlab vector notation we can simply multiply a row vector by a column vector and
obtain the same result.
So this is a discrete Fourier transform.
If you copy and paste this code to create a Matlab function, give it an input array
and compare the output with the Matlab fast Fourier transform FFT function, you will obtain
exactly the same results.
By the way, the difference between the discrete Fourier transform and the fast Fourier transform
is basically that the fast Fourier transform is faster.
The fast Fourier transform uses some mathematical trick so it can reuse some of the values calculated
for some frequencies for other frequencies.
So this is the end of his first part and I'll see you in the next video.