eeglaband directly load the toolbox without having to specify the current folder every time.
User/Documents/MATLAB/toolboxes, on Mac OS) and hit OK. This adds the toolbox as well as the plugins we added before moving the file into the
eeglabin the command window should fire EEGLAB. If it loads, you're fine! If it doesn't, hit your head against the desk…
help gui_erpif a help file loads and no error message appears, you're fine! If it doesn't, hit your head against the desk… again!
There is nothing easier in EEGLAB than to load datasets from other applications. There are tons of plugins already pre-installed that import datasets from most formats.
(File formats recap page from EEGLAB developers.)
The tutorial dataset was recorded in NeuroScan so we will use that particular plugin. Fear not! If you use another format, the GUI has plug-ins for other systems and will guide you through.
file>import data>use EEGLAB functions>From Neuroscan CNT file
*.cntfile, hit OK. MATLAB will load the file and display info related to the process in the command window.
Any analysis of your data will involve a fair amount of repetitive steps (for every subject, every condition, etc.). We also end up repeating these steps over the same experiment with a few changes (maybe our data is too noisy and we want to use a more powerful setting, sometimes it may be that we want to have different artefact rejection criteria, or we might just decide to group certain trials/conditions together although they have different triggers).
The ultimate goal is to be able to batch those (eternally boring steps) as they do not require any human supervision. In addition, MATLAB isn't the quickest kid in the block. EEG datasets, unlike spreadsheets, are starting to be on the heavy side and all this means that processing time and efficiency is probably something we need to keep in mind. Because computers are dumb, we have to do a fair amount of thinking for them and make decisions early on (i.e. before pre-processing) that could make our lives easier by reducing time that we have to waste waiting after our dumb computers.
We can do this in two ways
Knowing that we have to do all of the following steps before we can do pretty much anything meaningful on our data, and knowing the computing time the steps take, can you think of the most efficient sequence of pre-processing?
Steps (in no particular order):
“Ideal” pipeline order
The data set that we load only contains information about the activity recorded, the channels it is recorded from and events (triggers, answer codes, etc.). In order to plot, as well as for any steps that may require information about topographies it is important to add information about the locations of the electrodes on the scalp.
You can load your own electrodes positions (i.e. manufacturer's provided) but EEGLAB also has a few handy files from BESA with prototypical electrode positions which match your electrode labels with the XYZ co-ordinates.
To load electrodes positions to a dataset go into the
Channel location menu (
Edit>Channel Locations). The following window will appear:
use BESA file for 4-shell dipfit spherical model
The channel location window will pop up and all fields should be populated with information from the BESA file:
That's it! We now have pretty locations loaded to that dataset and we can even plot the locations of each electrodes for fun if we want to. For this we can hit
plot 2D or even
plot 3D and we should get sexy stuff like that:
While we're in the channel business, now is a good time to do a few more channel operations such as re-referencing. Since we are recording from a single reference electrode we need to re-reference our entire data to more than an electrodes to avoid biases such as topographical shifts and other spurious effects. This operation is super quick to do so we could leave it to later but since we should NOT look at non-rereferenced data why not just get rid of that step from the beginning.
While the operations behind re-referencing are fairly simple to understand, EEGLAB is for some reason a bit strange when it comes to this and requires a lot of rather repetitive steps. It took me a few hours to get it to work for the first time when I was reading if from the EEGLAB re-reference help page.
Perhaps the reason why this is less intuitive than we think is because when we have recorded the data (at the time of acquisition) in reference to an electrode that is on the scalp and therefore quite precious to us and we will need put it back into the data, which involves a few strange steps in EEGLAB but let's just put our seat-belts on and get through this.
Append Chanthis add a new channel (here #67).
Channel labelfield write the name of the electrode you want to reconstruct (in our case Cz).
Look up locks(chose BESA 4-shell again). This will add the spacial info to Cz (unsurprisingly, you get a lot of 0s because Cz is right in the middle.
Set reference. Channel indices should contain the entire array (since that reference applies to ALL channels) and we will just declare that the reference channel to which these channels are referred is Cz.
So far, all we have done is tell EEGLAB that there is an electrode that is “hidden” (Cz) that it should be added to the dataset and that this channel is in fact the (original) reference. No transformations have been done at this point since it's just a matter of creating space in the dataset to add the re-constructed Cz later on.
Notice how the information in the dataset went from “unknown” to “Cz”
Tools>Re-reference). This brings up the main window shown in the next figure.
If we did not want to re-create the online channel (say we recorded in reference to the tip of the noise or a mastoid to which we are not interested, we could go straight into the re-referencing interface, choose common average and hit OK. Since we do not wish to include the online ref electrode, we don't need to actually create a place holder for it via the channel locations interface in the first place.
Compute average reference& click on the menu button next to the
Add current reference channel back to the dataand select Cz (it will be the only channel).
As we saw before, this step isn't really the classical pre-average epoching in the sense that we are probably used to think of it, but merely so that we can reduce our data (remember, 70%!). At this point, we don't need to think about which trials go together, which ones are followed by a correct or incorrect response etc. We will therefore, create epochs of [-104 1004] for each of the experimental triggers we have sent (whether we only have two or 20 different codes).
-104 ms? WHY? As we will see in the next session we will need the epochs created here to be a little longer so that when we prepare our sets for ERPLab some of the transformations it performs to the EVENTLIST do not impact our window length. More on this on the next session!
500(while there are
995events –that is because the triggers we sent for the responses are also included in that 1second window).
We will now filter our data to get rid of electrical noise and slow waves or offsets. For this step I prefer to use the filtering tool implemented in ERPLAB because it gives a nice graphical visualisation of the filter but the same type of filter is available through EEGLAB functions too.
ERPLAB>Filter & Frequency Tools>Filters for EEG data.
IIR Butterworthfilter in our case).
0.1in our case)
30in our case)
4in our case [24dB/oct]).
There are many reasons why we would want to run an ICA on our dataset. The main one would be that it is extremely good at correcting artefacts like eye-blinks, vertical and horizontal eye-movements, muscle artefacts, electrode “jumps” and even line noise.
Sadly it is very slow. Luckily, we have made some clever decisions early on and we have reduced our file size while keeping all the interesting bits of data we may want to analyse and (in theory) we should not have to run it ever again on this dataset.
Needless to say, if we were ever going to want to automate a step in our analysis it would be the one!
runicaand we will choose that one.
Good night! */
DISCLAIMER: The tutorials provided on this wiki are not intended to compete with the tutorials written by the EEGLAB's (and other toolboxes) developers (EEGLAB website). It intends to be a condensed version for educational/reference purposes for members of the lab/department to which this workshop was given.