User Tools

Site Tools



EEGLAB Hackathon
Main Website


Session Two: Post-Processing & Analysis (GUI)

GUI Steps

1. Loading existing dataset

Once the Night Crew batch has ran, human supervision is needed again. Usually, it will be because we have chosen to correct artefacts using the ICA decomposition we ran at the end of that script.

To load an existed EEGLAB formated dataset fire eeglab if you haven't done so yet, then go to: File>Load existing dataset browse for your dataset.

NOTE: Several sets can be loaded at once by holding the ⌘[cmd] (mac)/ Ctrl (PC) key.

As previously seen, loaded datasets appear in the EEGLAB main window, which also displays information about the dataset that is currently active (nb channels, epochs, ICA weights, etc.)

Loading sets clogs the RAM, depending on how much space you have you'll have to figure out how many sets is too many.

Let's load participant 504, 517 & 522 for the moment.

2. Dealing with artefacts II

Our next task is to correct the artefacts out of our data. We ran a time-consuming ICA decomposition and we might as well use it. ICA is by far one of the best methods to correct for artefacts and it is particularly good at correcting those stereotypical ones like eye-blinks, but also vertical and horizontal eye-movements as well as big muscle artefacts.

This step unfortunately does require human supervision throughout. A bit like the Gratton & Coles routine in NeuroScan requires the user to “model” eye-blinks here we will need to review the ICA decomposition and identify components that look like the artefacts we want to correct.

Once we have identified and labelled those components the correction consists in mathematically removing those components out of the data. The exat maths behind ICA is pretty much beyond me, but Arnaud Delorme claims he can explain ICA to dummies:head to his page for more info. The EEGLAB official documentation also has quite a lot about ICA.

As you may have noticed, when you load a post-ICA set, the eeglab main window tells you that this set contains ICA weights:

a. Exploring ICs & Preparing for removal

The first step consists in exploring and plotting ICs to identify which ones may be responsible for artefacts such as eye movements. To do this we need to plot the components. Go to Tools>Reject data using ICA>Reject components by map. Enter the range of components you want to plot (for now we'll only plot the first 34) and hit OK.

After an ICA decomposition there are as many ICs as you have channels in your dataset. The runic() function ranks the component by the amount of variance explained. This means that the bigger the contribution to the data the higher on the list the component is.

Eye-blinks or movements are quite big and systematic, they therefore usually make it to the top. If one is screening for these types of artefacts only plotting between 20 and 30 ICs is more than enough usually.

EEGLAB will plot the number of components specified and produced the following window:

Details about each component can be accessed by clicking the button on top of each topo plot.

Let's open component 1:

This component is actually a good candidate for an eye-blink as it exhibits the three main characteristics of such an artefact:

  1. Scalp topography: Concentrated on the extremely frontal channels and decreasing towards the back.
  2. Amplitude: Strong positive wave generally shifting the ERP upwards.
  3. Frequency: Smoothly decreasing in frequency with no clear peak beyond the 10–20Hz boundaries.

A rule of thumb contends that removing the 5 first ICs should usually cover most of the problematic artefacts without tempering with actual cognitive data. More on this later however!

Blinks vary from participant to participant and often blinks won't exhibit the “BIG 3” characteristics!

Since IC 1 is clearly accounting for a lot of the eye activity we may want to remove it. We will therefore label it for rejections by toggling the ACCEPT button to REJECT. We can move on to inspecting other ICs now. IC2 also seems to be an eye-artefact so we might want to do the same.

5 First ICs rule of thumbs
While often it will be the case that the first 5 ICs are big artefacts like eye blinks, it is not always the case. Look at IC 4 in participant 504 (fig below). Would you feel comfortable deleting that IC? How about IC 4 in participant 522?

It turns out ICA isn't used just for artefact correction but can be pretty good at isolating component sources in space. Indeed, it is used by the DIPFIT dipole fitting function of EEGLAB for that purpose).

504 IC 4:

522 IC 4:

ELECTRODE JUMPS, NOISE PICK-UPS Other types of artefacts that ICA is good at picking up are single-channel jumps or pops (i.e. electrode going “off” and picking up line-noise. We might want to spot those too and remove them if they start impacting a large number of trials.

The section “studying and removing ICA components” of the EEGLAB official page is pretty useful and details a lot more about ICA, a visit won't hurt!

b. Removing/Subtracting ICA components

Once we are happy with the selection, we can head over to Tools>Remove Components. The window that pops up should have the list of ICs we have labeled for rejection. This is the last chance to change our mind. Make sure to delete the numbers in the second field (by default EEGLAB puts the components back into the data by feeling the same list in the field “components to keep”.

When the next window pops up we can choose to Plot single trials to check that our selection was correct.

If we're happy with the job, we can hit Accept, save the set and move on to a new participant.

c. Using the ADJUST toolbox: semi-automatic solution

  • While there is nothing better than human supervision to decide whether an IC is brain-related or pure artefact, we may often be too conservative. Fortunately, there are several toolboxes designed to assist us with the selection of problematic ICs –especially those electrode jumps that affect only a few trials and that may may not even bother plotting because they rank pretty low).
  • To use ADJUST, once our ICAed dataset is loaded head to: Tools>ADJUST, then hit Run ADJUST. ADJUST will apply an algorithm geared towards detecting Horizontal and Vertical eye-movements as well as generic discontinuities in the data (e.g., channel pops). More on the back-end of ADJUST here.
  • While this toolbox can run entirely automatically, we will use it as a help rather than let it be applied blindly to the data as it is often either over or under estimating.
  • Once ADJUST has ran it pops up the same Explore components window but it has pre-labeled some components it thinks are problematic. And usually it is pretty correct:

  • We just need to open the pre-labeled ICs and confirm that we really want to reject them. If we leave an IC untouched it will by default stay out of the rejection.
  • The rest is identical to the fully manual solution: Remove Components, plot single trials, check, Accept.

3. Analysis direction choice

At this point we have taken care of all of the necessary pre-processing steps. Indeed, we have reduced file size, filtered the data and corrected artefacts. Whatever comes next will be dictated by what the type of analysis that we want to carry out.

In the present situation would like to run traditional averaging analyses. This type of analysis is best carried out in the EEGLAB toolbox ERPLAB.

The way we will be preparing the data in the following steps, however, will render our data incompatible with EEGLAB. This is only a “problem” if we want to run less traditional analyses but we will see a workaround in the last session dedicated for advanced analyses.

One of the main reasons we want to use ERPLAB is probably because it requires very little programming from then on thanks to the way it handles epoching and averaging via 'bin descriptor files'.

4. The ERPLab Route

Subsequent steps should be ran from an installation of ERPLAB within EEGLAB v. 12 as version 13 currently creates a bug when specifying overlapping bins.

I have reported this bug a few days ago and the developers of ERPLAB are working on a fix.

a. Trial selection (BDF Files)

i. Bin Descriptor File

The first thing we need to do consists in selecting the trials or epochs or interest.

The dataset we have contains a lot of different trigger types. Remember typicality in this design varied over 5 different levels. While these levels should be used as continuous regressor in a linear modelling approach, for now our traditional ERP approach will only focus on main effects which may then be broken down into separate conditions.

Conditions & Triggers Recap

%Individual Conditions
%%Main Effects
%%Main Effects Match conditions only

ERPLAB implements trial selection via what it calls “Bin Descriptor Files” (BDF). BDFs are simple text files which contain, in the simplest syntax (3 lines per bin), instructions about how files are to be epoched. “Bins” are basically groups of (or single) triggers which the experimenter will want to analyse. In our case, we would have bins called “Label”, “Sound”, “Match”, “Mismatch and so on…

Here are a few tips about how to build them:

  • Declaring Bins

Line 1 declares a bin from 1 to however many bins you need as long as numbering is kept constant.

bin 1
bin 2
bin 3
  • Labeling the bin

Line 2 assigns a label (string) to the bin. It can be anything as long as it is intelligible to the experimenter.

bin 1
bin 2
  • Triggers & epoching instructions

Line 3 is a bit less intuitive but still easy:

  1. Group trigger codes between {} and separated by ;
  2. Specify time-locking events using . before trigger for which you want an epoch.
  3. Another set of {} can be used to specify a condition such as is immediately followed by if the {} follow the time-locking events or immediately preceded by if the {} come before the time-locking events.
bin 1
bin 2

In this example event(s) in the first set of brackets will created a time-locked epoched to 111 or 211 only when they are immediately followed by trigger code 10 or 11.


With the tips we've just seen, prepare a BDF which will create bins for the conditions in the text file above. In addition, we want to analyse only ERPs which are associated to a correct response from the participant.

When a participant made a correct response, the acquisition computer received trigger code 1. When a participant made an incorrect response, the trigger code was 2.

If you're stuck with the implementation of the correct response sorting think about using another set of brackets.

Here is the final file (click on the thumbnail to download it):

bin 1
bin 2
bin 3
bin 4
bin 5
bin 6
bin 7
bin 8
bin 9
bin 10
bin 11
bin 12
bin 13
bin 14

BDFs are therefore very handy when it comes to epoching because within minutes we can create any group of triggers based on their environment in the EEG data such as correct vs. incorrect answer –tasks which otherwise require a fair bit of tweaking in other software packages (event files modifications).

ii. Creating an EventList

Because of the way ERPLab works on epochs it requires you to create a separate “EventList” on which it can work. It does so by pulling the information contained in the EEGLAB dataset structure and creates a simpler structure which it appends to the EEG structure as EEG.EVENTLIST.

One of the advantages is that this EventList can be saved as a text file for potential editing without touching the actual even info on the dataset. The disadvantage is that EEGLAB is completely blind to it and from that point the data that ERPLab creates will not be compatible with EEGLAB (however, we have a work around for that –which we saw in the first session).

If we do not intend to do any modifications it won't bother us anyway! BUT it is a necessary step before we can epoch according to the conditions we wrote in the BDF.

ERPLab only likes to work from a continuous dataset! If you remember we already epoched our sets in the first session. Does that mean we have to redo it all again?
No, that would be silly and our trick to save ICA time would not have been much of a trick.
All we need to do is use a function provided by ERPLab that re-creates a continuous set from epoched data.

  • First, let's concatenate our epoched data so that ERPLab feels at home: Go to ERPLAB>Utilities>Convert an epoched set into a continuous one. Hit OK in the warning box
    • Voilà! Easy right?
  • Second, we can now create the EVENTLIST. Go to ERPLAB>Event List>Create EventList. Warning message pops up telling you that some of your trigger codes are strings (the concatenation added the code boundary to our sets, hence the presence of text). Hit Continue. The following window appears:

  • The default options are fine. Indeed we need to convert the string boundary into a numerical value and -99 is just as good. Hit Create.
iii. Assigning Bins & Extracting Bin-based epochs

Now that we have met all the pre-requisites of ERPLab, and now that we have created an Event structure that it likes working on, we can go further.

  • First, let's ask ERPLab to create Bins according to our descriptor file
    • Go to, ERPLAB>Assign Bins (BINLISTER)

  • As shown in the figure above:
    • Browse for the BDF.txt file where you have stored it on your computer. You can have a look at it and perform some last minute changes if you wish by using the Take a look button.
    • Check “read event list from current dataset”
    • Check to “write the resulting EVENTLIST to the current dataset, “transfer EVENTLIST info to EEG.event” and save it to the “MATLAB workspace” just in case something goes wrong. Hit RUN
  • Second, let's now ask ERPLab to extract epochs based on the combinations we described in the BDF (which have now been assigned to the EVENFILE.
    • Go to, ERPLAB>Extract Bin-based epochs. Specify the limits of the epochs. This time we will put the real limits in ms [-100 1000], and ask for a baseline correction to be done on the Pre-Stimulus interval.

  • Voilà! Our set is now epoched again (check the info in the main window) and if we plot the data (Plot>Channel Data (Scroll)) we can see each epochs has now been assigned to a (or several) bins:

b. Artefact detection

Although we've taken care to correct most artefacts out of the data with ICA, there might still be epochs containing artefacts that have not been picked up by the ICA. At this point our datasets should be pretty clean anyway but we probably want to make sure to reject anything big enough to be a problem and that we might not have managed to correct.

We will use a simple artefact rejection function that rejects activity above or below a certain threshold. There is another very popular method known as the moving peak-to-peak window which is a bit more elaborate and offers more flexibility. In this example we want to reproduce the analyses as we usually carry them out in the BULET lab so we will use the equivalent “simple threshold” method. (For more information on the different methods go to the ERPLAB page)

  • Go to, ERPLAB>Artefact detection in epoched data>Simple voltage threshold. Choose the entire window length and set the upper and lower µV limits to the commonly used -75 75 threshold. Hit OK
    • Epochs with activity exceeding the specified threshold will now be marked (and not rejected) with a flag. ERPLAB provides a summary of the artefact detection (which we can actually save –more on this later when we go on batching).

c. Averaging

The advantage of ERPLab, is that it does not create separate files for each conditions (unlike NeuroScan). This is very handy since the output from the averaging step will be a single file per participant containing all the bins we have specified in the BDF.

  • Let's average our epoched set! Go to, ERPLAB>Compute Averaged ERPs

  • Specify the datasets for which you would like to obtain ERPs (a range, or a list can be chosen if several sets for several participants are loaded in memory), in my example I'm performing the averaging on dataset 2.
  • Check Exclude epochs marked during artefact detection (If you do not want to reject any epochs –and therefore ignore the results from the previous step– check Include ALL epochs.
  • Check include standard error of the mean as this might be useful later (but it's optional). Hit RUN.


Following those instructions prepare all individual sets into averaged ERP sets, which we will use to compute grand averages across participants.

e. Plotting

Once we have computed an average we can use the plotting tools to visualise the ERP.

  • Go to, ERPLAB>Plot ERP>Plot ERP waveforms

This window has loads of options but we will concentrate on the following:

  • Bins to plot: It is unlikely that we want to plot all the 14 bins we have created.
    • Let's uncheck All Bins and hit browse. How about bins 9 & 10? (⌘-cmd/ctrl+click will allow you to select several bins at once).
  • Scales:
    • Time. Let's keep the full window length.
    • Y range. Let's go for -10 15 (for individual data. We would lower it for Grand Averaged data)
    • Polarity. If the button says “negative is up” click it to toggle “positive is up” (although that is entirely up to you.
  • Channels:
    • let's go with all channels
  • Baseline Correction: Pre
  • Style:
    • Because we have loaded electrode locations we can chose “topographic” this will mimic the arrangement of electrodes in 2D space.

d. Grand Averages

The final step is not to average over individual ERPsets, since we generally look at ERP effects at the group level.

This step requires that we have created an ERPset (i.e. averaged the data) for each participant.

Each participant's ERPsets may be already loaded in memory (loading and ERP set is done via ERPLAB>Load existing ERPset) or saved on disk.

  • Go to, ERPLAB>Average across ERPsets
  • Click From ERPset files, then Add ERPset.
  • Locate your sets on the hard rive (⌘-cmd/ctrl+click will allow you to select several sets at once)
  • Check include standard error of the mean
  • Hit RUN

See plotting instructions above if you want to plot the Grand Averages you have just created.

f. Measurements & Stats

This step is also pretty handy in ERPLab compared to the output usually given by NeuroScan for example, which often require painful steps to render a file fit to go into R or any statistical package of your choice.

  • Lauch the measurement window: ERPLAB>ERP Measurements

  • Just like in the grand average step you can either perform the measurements from a number of sets already loaded, or load them in the interface.
  • Once your sets are loaded or listed, choose what measure you want to extract. In this instance we will choose Mean Amplitude between two fixed latencies
  • Let's select bins 9 & 10 (either through the browser or by typing 11 12.
  • Choose channels from which you want to extract the measure (using Browse displays the labels).
  • Specify the min and max latencies between which the mean amplitude should be collected.
  • Don't forget to set your baseline as pre (that means pre-stimulus onset).
  • Check include bin label as well as bin number
  • Give a name (and/or path) to your file. Hit RUN.

Depending on the format we have chosen ERPLab will create a text file that will look like this:

       value	     chindex	     chlabel	        bini	      binlabel	 ERPset
      -0.096	           4	         FCZ	           9	  RelatedSound	508ERPs
      10.153	          11	         CPZ	           9	  RelatedSound	508ERPs
       6.445	          15	         CP3	           9	  RelatedSound	508ERPs
      -5.037	          17	         FC3	           9	  RelatedSound	508ERPs
      -2.253	          19	         FC4	           9	  RelatedSound	508ERPs
       6.724	          21	         CP4	           9	  RelatedSound	508ERPs
       4.993	          67	          Cz	           9	  RelatedSound	508ERPs
      -2.918	           4	         FCZ	          10	UnrelatedSound	508ERPs
       5.030	          11	         CPZ	          10	UnrelatedSound	508ERPs
       3.612	          15	         CP3	          10	UnrelatedSound	508ERPs
      -5.859	          17	         FC3	          10	UnrelatedSound	508ERPs
      -3.076	          19	         FC4	          10	UnrelatedSound	508ERPs
       3.981	          21	         CP4	          10	UnrelatedSound	508ERPs
       0.338	          67	          Cz	          10	UnrelatedSound	508ERPs
      -5.366	           4	         FCZ	           9	  RelatedSound	510ERPs
       6.077	          11	         CPZ	           9	  RelatedSound	510ERPs
       6.212	          15	         CP3	           9	  RelatedSound	510ERPs
      -2.737	          17	         FC3	           9	  RelatedSound	510ERPs
      -2.601	          19	         FC4	           9	  RelatedSound	510ERPs
       6.074	          21	         CP4	           9	  RelatedSound	510ERPs
      -0.092	          67	          Cz	           9	  RelatedSound	510ERPs
      -7.110	           4	         FCZ	          10	UnrelatedSound	510ERPs
       3.940	          11	         CPZ	          10	UnrelatedSound	510ERPs
       4.258	          15	         CP3	          10	UnrelatedSound	510ERPs
      -3.586	          17	         FC3	          10	UnrelatedSound	510ERPs
      -3.835	          19	         FC4	          10	UnrelatedSound	510ERPs
       4.489	          21	         CP4	          10	UnrelatedSound	510ERPs
      -2.092	          67	          Cz	          10	UnrelatedSound	510ERPs
       2.096	           4	         FCZ	           9	  RelatedSound	512ERPs
       6.408	          11	         CPZ	           9	  RelatedSound	512ERPs
       5.063	          15	         CP3	           9	  RelatedSound	512ERPs
      -2.507	          17	         FC3	           9	  RelatedSound	512ERPs
      -0.456	          19	         FC4	           9	  RelatedSound	512ERPs
       7.250	          21	         CP4	           9	  RelatedSound	512ERPs
       2.298	          67	          Cz	           9	  RelatedSound	512ERPs
       1.672	           4	         FCZ	          10	UnrelatedSound	512ERPs
       5.101	          11	         CPZ	          10	UnrelatedSound	512ERPs
       4.351	          15	         CP3	          10	UnrelatedSound	512ERPs
      -3.082	          17	         FC3	          10	UnrelatedSound	512ERPs
       0.549	          19	         FC4	          10	UnrelatedSound	512ERPs
       5.850	          21	         CP4	          10	UnrelatedSound	512ERPs
       1.775	          67	          Cz	          10	UnrelatedSound	512ERPs

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.

eeglabsesh2.txt · Last modified: 2014/10/08 03:14 (external edit)