User Tools

Site Tools



EEGLAB Hackathon
Main Website


This is an old revision of the document!

Session Two: Post-Processing & Analysis (GUI)

Preparation of Day Crew Script for analysis in ERPLAB

As we have seen once we ran the Night Crew we get a set which contains ICA weights. At this point human supervision is unavoidable as we need to explore ICs and subtract the ones that are responsible for artefacts.

At the end of each set we will have saved a set which will not only contain ICA weights but which will have been corrected by subtracting ICs responsible for artefacts.

1. Loading ICAed set

We will not use pop_loadcnt() this time because the final set that the Night Crew created is in the EEGLAB format. To load a *.set file we use pop_loadset()

EEG = pop_loadset('filename', 503_ICAC.set);


2. Make ERPLab happy: epoched to continuous dataset

As we saw earlier ERPLab wants a continuous set. Luckily its developers provide a function for that:

EEG = pop_epoch2continuous(EEG);

Yes! Just as easy as this!

3. Create Eventlist

The following line will create a simple event list and will convert the “mess” created by the previous function by converting the strings boundary to a numerical value -99.

EEG  = pop_creabasiceventlist( EEG , 'AlphanumericCleaning', 'on', 'BoundaryNumeric', { -99 }, 'BoundaryString', { 'boundary' } );

4. Assign bins

Don't forget to update the path of the BDF file.

EEG  = pop_binlister( EEG , 'BDF', '/Path/Of/BDFFile', 'ExportEL', 503_bin.txt', 'IndexEL',  1, 'SendEL2', 'All', 'UpdateEEG', 'on', 'Voutput', 'EEG' );

5. Extract bin-based epochs (& baseline correct)

Does what it says on the tin. Specify limits of epoch window. Third argument sets the baseline correction (here pre for pre-stimulus interval)

EEG = pop_epochbin(EEG , [-100  1000], 'pre');

6. Detect & Mark Artefacts for rejection

  • Specify channel array, in that example we excluded VEOG & HEOG
  • Flag 1, dictates how the artefacted epoch is labeled. Here it will have a flag value of 1 but could be set tp another number (say because we want to perform other types of artefacts detections)
  • Threshold, min max array.
  • Time window, min max array
EEG  = pop_artextval( EEG , 'Channel', [1:65 67], 'Flag',  1, 'Threshold', [-75 75], 'Twindow',...
 [-100 1000] );

7. Averaging

  • Criterion:
    • 1=Exclude trials labelled as artefacts
    • 0=Include all trials
    • 2=Only trials with artefacts
    • SEM here will be calculated.
ERP = pop_averager(EEG , 'Criterion', 1, 'SEM', 'on');

NOTE: The result from the averaging is now assigned to a new object called ERP!

7. Saving ERP set

At this point we will want to save the result of our batch. While for all other previous steps we use the pop_saveset() command, because we are now dealing with and ERP set, we need another command to save this ERPset:

ERP = pop_savemyerp(ERP, 'erpname', 503_ERP , 'filename', 503_ERPs.erp');

8. Save a summary of artefact detection

It may come in handy to save a summary of the Artefact Detection for each subject so you can review it once you come back to your computer. Here's how to do that:

pop_summary_AR_eeg_detection(EEG, 503_AR_Summary.txt');


Just as we did for the Night Crew, your task now is to prepare a DayCrew that will take the ICA corrected set and bring it to an ERP set analysable by ERPLab.

For extra luxury we may want to have our script perform the following:

  • that it saves the a set after just before averaging
  • make sure your loop doesn't get stuck because of a buggy dataset.
  • save final dataset. (NOTE. when saving datasets you might want to think of a way to name the dataset with the subject information).

For REAL luxury

  • make matlab create the destination directory. Maybe you want to keep your ERPsets in a different folder from the other EEGLAB-type sets? If you feel brave think about this too.
eeglabsessh2b.1391687296.txt.gz · Last modified: 2014/10/08 03:14 (external edit)