Hey guys, in this video I'm going to go over
how you can do artifact
removal using independent component
analysis for EEG data
and I'm going to be running ICA in
EEGLAB. Probably you're already familiar with EEGLAB
if you work with EEG data. But it's a
plug-in for MATLAB.
I already have a dataset loaded in
and let me plot
the channel data before running ICA
just to show you what we're working with.
For this subject--
let me change the scale to 75--for this subject
we have two eye electrodes.
We have one capturing vertical
EEG, which will capture blinks and we have
one capturing horizontal eye movement
that will capture saccades. As you can see here
especially for the frontal electrodes,
when there's a blink artifact you still see
the artifact in especially the frontal electrodes
and the other EEG channels.
And the same thing with saccades as well.
That's one thing that we're--or two things that
we're going to try to remove with the ICA
decomposition. Okay so to run
ICA in EEGLAB,
it's very simple. You go to tools and
they go out of their way to put it in blue. You click
"Run ICA". It will give you a couple of different
algorithm options to run ICA with.
The standard one is just the first one called
"runica". There's another one called "binica".
This is a binary file of the
first one. It has the same algorithm and actually it will--
I read that it will run faster. And then
there are other ones. I've also read
that basically these different ones all just
usually give you the same components but you can
run multiple ones and compare. I'm just going to run
the first one called "runica". I think I--
when I've tested it, this has only taken my machine
a couple of minutes but if you find that it takes a long
time, you might to consider running the faster version.
You just have to make sure that the file path is
set correctly to run this second one.
But I'm just going to run the first one
and I'll see how long that takes.
Then this little window pops up. This is just if you want to stop MATLAB
from running. But if you go to the terminal
or command window, it will show you that
it's working on the ICA.
For me, that only took
a couple of minutes to run and once that is
done, then you can go to
plot "Component activations (scroll)"
to plot the actual
EEG signal from each component.
In this sample data
that I'm using, I have recordings
from 23 electrodes.
That's going to produce 23 independent
components. Now when you plot
or scroll through the component activities
it will have the 23 independent
components listed and the order
of the components is based on how much variance
they explain per component.
The first one explains the most variance,
followed by the second one, and the third one, and so on.
As you can see, the first 3 components
seem to be picking up mostly
the vertical and horizontal eye movements
including the blinks.
This is one way of looking at
which components you want to remove from your data
and you can scroll through this.
And then there's another way of looking
at this as well. You can go to tools,
"Reject data using ICA", and then
click "Reject components by map". I'm going to plot
the 23 electrodes or 23 components that I have
and then that will open up this window. And then you can check
each individual component by clicking the green button
above their topography maps.
If you click number 1 for example, this will open up
another window that has
a power plot, the individual topography map,
and an ERP image and an ERP. If you click
on the ERP below the ERP image,
it will give you a zoomed-up graph of what
the ERP looks like. And this is the
ERP image and this is the power plot
like I just said. You can mark
any of these independent components that you look at
for rejection by clicking the "Accept"
button. If you click it,
it will change accept to reject or vice versa.
Once you click "OK", you're not actually removing
the independent component yet. You're just marking it
for rejection. I'm going to
mark the first three for rejection.
And so how you decide whether
to accept or reject is kind of subjective. If you
have two--like my experiment--
if you have two electrodes that are measuring
blink artifacts or eye movement artifacts
then you probably want to remove at least two components
and then if you want to remove any more than two
you do have to kind of look at the data
and justify to yourself using whatever criteria you want to use
whether to accept or to reject. You also want to look at
the electrodes where--
or the topography maps where it looks like all the
signal or all the variance is coming from one
electrode. Let's look at 11, for example.
And this doesn't have a nice 1/F
power plot like you would expect from a
good electrode and then if you click the ERP image
this looks like it's mostly
pick up noise. I'm going to mark this one
for rejection as well and I'm going to just leave it there
and then just test out what the
signal looks like after we take out
the artifact from these four components. So I'm going to click
"OK." Then if I go back to this window
like I said, the components haven't actually
been removed yet. To remove components, you want to go to
"Tools," and then "Remove components." And the ones
that I've marked for rejection in that previous
window are shown here.
I'm going to click "Ok" and have these
components removed. And before
EEGLAB does that, it's going to show you this little
confirmation window. So you can check what the data will look like
before and after you remove
the components. You can either plot ERPs or plot
single trials. I'm going to click
"Plot single trials." And so it says here
that the black is the channels
before rejection and the red is after rejection. You can look at
if it's going to change the data by
removing artifact like you want it to and
let me go ahead and check "Plot ERPs."
This will open up a window comparing the ERPs before
and after. This looks okay to me.
I'm going to click "Accept"
and then it's going to let you save the file before
the ICA is removed and after
the components are removed. I'm going to save it as "aim_
post_ICA" and click "OK"
and that runs really quickly.
And now when you plot it, you'll see that the
blink artifacts should be greatly reduced
or removed completely from the data. I was just running
a quick demo. The
artifact removal might not be perfect but
you can see very clearly that
we had some crazy blinks before
and now it's been greatly reduced from the data
and this is something that you can kind of test with--
if you're not sure if you want to remove
one component or not--you can test before and after
and compare the data. And yeah. That's it for this video
and thank you guys for watching!
*chiptune music*