Hello! My name is Arnaud Delorme, and this is Part 7 of a series on
independent component analysis applied to EEG time series.
This is a part on running ICA in EEGLAB and visualizing components.
So first let's talk a little bit about the secrets of a good ICA decomposition.
How do you pre-process your data?
Well, first, you need good data.
Good data means that you've acquired with low impedance.
The quality of the data is critical for a good ICA decomposition.
It's not magic.
If your data is bad, ICA can't rescue your data.
The second part is to remove very large artifacts like,
for instance, when the subject move their heads it generates dramatic artifacts.
You want to remove portions of the data where you can see that it's irrecoverable.
Either there is no EEG or the amplitude of the artifacts is 100 times the EEG.
So you want to remove these portions of data, because ICA will be
overwhelmed with these artifacts.
The first step is to ask yourself if you have enough data.
A rule of thumb is you should have about 20 times
the square of your number of channels data points.
For example, you have 30 channels so that's 30 times 30, that's about 900, about a thousand.
So you want about 20,000 data points (about 20 x 900), that's our rule of thumb.
And then you also want to high-pass filter your data.
ICA will tend to focus on what's in the data with the highest power.
So we often filter the data a 0.5 Hz, sometimes 1 Hz when
the data is low quality or sometimes even 2 Hz.
And even if you filter your data at this very "high frequency" you can always use the ICA decomposition
as a spatial filter and apply it back to your original data.
For example, there's a lot of the ERP which is contained in the low frequencies, so you might not want to lose that.
But you can actually use your ICA decomposition run on the filtered data,
You can apply it back to the unfiltered data.
You want to remove bad channels, because ICA will assign components to each bad channel,
and it might also decrease the quality of the decomposition.
And you will also want to use data in what we call double precision.
So that's the precision of the numbers in memory.
You don't have to worry about that, because this is taken care of [by the function which run ICA].
This is a very important point.
So your data is ready.
So you go to EEGLAB, and you click this menu "Decompose data by ICA".
The default option is to run InfoMax ICA.
So that's the one I showed the theory about.
And there is several arguments to this algorithm.
We're going to look at a couple of these.
There is the extended version, which is set by default.
So I explained that in one of the previous lecture:
this helps to detect line noise.
By default this algorithm won't be able to detect line
noise if you don't use the extended version.
So in general you always want to use
the extended version of this algorithm, even though it is slower.
The stopping step, so ICA is rotating this matrix and it's computing
the difference with the previous step and when it reaches a threshold it just stops.
So here it's 10 to the minus 7.
It actually depends on your number of channels. It adapts automatically to your number of channels.
If you have less than 32 channels, I think it's 10 to the minus 6.
The learning rates, again, a parameter that controls the learning speed.
You don't have to worry about this one, but it's good to know that it exists.
It's automatically adjusted.
The maximum number of steps.
So even though ICA doesn't reach the convergence threshold, the stopping threshold, it will
stop after 512 step by default, and you can change that.
And it's an important parameters, because sometimes you want to increase the number of steps.
In PCA, I'm going to comment on PCA in a little bit, in the next
slide, but this allows you to reduce the dimensionality of your matrix.
For example, if you have [converted your data to] average reference, you have to reduce
the dimensionality of your matrix by one, because your channels are linearly
dependent: the sum of your channel is zero [average reference assumption],
so one of the channel is equal to minus all the other ones.
And this is one of the algorithms.
There's actually other algorithms.
There is "binica".
So if you go to this menu where it is
written "runica", you can select other algorithms.
One is "binica", it's the same as "runica", it's the same InfoMax algorithm, except it's implemented in C.
It used to be much faster than the MATLAB version, but because MATLAB now
optimizes code, now, it's actually faster to run the MATLAB version.
So there is no real use for this binary algorithm, except you have the source so
if you want to use it for some specific purpose you can you can use this version, as well.
There's the "Picard" algorithm.
So that's a plugin, so you have to use the "manage extensions" [menu item] and install the plug-in.
This one is also InfoMax ICA, but it's a different optimization method, and uses the
Newton method. So, in theory, it is much faster to converge.
It also converges to much lower thresholds, so it goes by
default to ten to minus ten, instead of ten to the minus seven [for regular Infomax using "runica"].
It's also much faster than "runica".
That's the one I currently use.
There's no formal comparison between this algorithm and "runica", which one returns the best [results],
so that's why it's not the default and why we have kept the default InfoMax [version].
What other algorithm?
There's the Amica algorithm.
So I have talked about Amica in depth in some of the previous presentations about the quality of ICA.
So I'm not gonna go back.
This is in theory the best algorithm.
It's very slow, though.
There is also fastICA.
So this one you just go to the fastICA website, you download it,
add it to your MATLAB path, and then you can use it [here].
It's gonna appear automatically in this interface, it's gonna be detected.
And that's also one of the very popular ICA algorithm that's used with EEG.
Another one that's used with EEG is called SOBI, and this one is included by default.
So it's in, it should be in your menu by default.
So you can choose between these ones.
One of the previous presentation compares these different algorithms.
There's no accepted gold standard, so it's up to you to pick the one you want.
Here a comment about using PCA.
So this is a paper we published in 2018, in which
we reduced the dimensions of the space using PCA.
And you can see here is four different PCA.
There's PCA 85, in which we kept the 85% of the variance [before running ICA].
This PCA 95, in which we kept 95% of the variance [before running ICA].
PCA 99, in which we kept 99% of the variance [before running ICA].
And then ICA only [no PCA].
And you can see the difference in terms of the decomposition.
I've showed this representation before.
This is a way to visualize cluster of ICA components when you repeatedly run the same ICA algorithm.
And here we can see at first glance that it's very different to run ICA and PCA 99.
So even when you keep just 99% of the residual variance it's not the same as using ICA [without PCA].
And the paper details all the numerical analysis,
but basically the take-home message is don't use PCA to reduce the dimensionality of your data.
And of course, if you use average reference you have to decrease [dimensionality] by one [using PCA].
And also the other case where you have to [use PCA] is when you have more than 128 channels.
If you have 256 channels, usually, unless you have a vast amount of data, you won't have enough data for ICA,
so you have to reduce dimensionality [using PCA] down to 128, for example.
These are the only two cases in which we recommend using PCA.
So you've selected ICA, so now it's running.
You can see the different steps, and you can see the learning rate,
you can see the weight change between each steps, and then it ends.
And when it ends, nothing happens in the interface, it just tells you ICA is done.
So now you can visualize your components.
And first, the first thing you can do is type EEG, the EEG structure on the command line.
And then you can see these four fields which are now populated.
There is "icaact", so this is the activities of the ICA components.
There's the "icawinv" inverse weight matrix, which contains the scalp topographies.
There is the sphere and the weight matrix,
and the relationship is that the inverse weight matrix is the pseudo
inverse of the weight [matrix] times the sphere matrix.
The inverse weight matrix: these are the components
which are contained in the inverse weight matrix.
And we're going to see how to plot these [components], analyze and recognize these [components].
So to plot component maps, you go into [menu item] "component maps" [sub menu item] "plot in two dimensions."
And then it asks you which component you want to plot.
So you can put a range of components.
Here we put 1 to 12, and there are additional plotting options.
And so here it plots component 1 to 12.
In the next lecture, we'll see how to recognize in more depth
these component classes and different classes of the components.
But here we can also already look at the difference
between a good ICA decomposition and a bad ICA decomposition.
And here, for example, a bad ICA decomposition is one where
the scalp topographies [of the components] look a little bit like checkerboard.
So it [the ICA component activity] doesn't seem to be originating from a single brain area from a single equivalent dipole.
So the top one is a poor ICA decomposition.
The bottom one looks like a good ICA decomposition,
because the scalp maps are more smooth.
When we look at these scalp maps, we know we'll be able to use dipoles
to model for example 99% of the residual variance of the component scalp topographies,
which is not the case for the top decomposition.
You can also scroll the activity of the components.
And this is how it looks like, so every line here is a component.
Here, at first glance, we can see that there's an artifact which is common to a lot of components.
So it means ICA wasn't able to capture these artifacts.
So in this case, it would be best to remove this artifact and
rerun ICA without this artifact, because ICA is not able to capture it and, in the end,
it just decreases the quality of the decomposition.
You can also plot the ICA component properties.
So that's [menu item] "Plot", [submenu item] "Component properties."
Again to plot, you select your components, and you can also enter a range here.
And then you see the scalp topography of the components, you see the
spectrum of the components, and then you also see what we call an ERPimage.
So that's what's on the top right panel here and [in ERPimage] every single trial
is stacked on top of each other, that's illustrated on top here, and color coded.
So [in ERPimage] we can see at a glance all the single trials and have an idea of the activity of the component.
So that's it for this presentation and I'll see you in the next one.