Using Script to Import EEGLAB files - How to import with Condition folders

Dear Brainstorm community,

So far, I've been manually using the GUI to import individual EEGLAB files which are already preprocessed and epoched. The data is an ERP study, with 4 conditions of interest, with the event values of interest under EEG.event.type being 'Go_Happy', 'Go_Angry', 'NoGo_Happy', and 'NoGo_Angry'.

When using the GUI to import, I can select these 4 conditions, and Brainstorm imports the epochs into their own unique event-named folders like this:

Screen Shot 2020-03-27 at 5.30.40 PM

I would like to however script this process using 'process_import_data_epoch'. I have tried many combinations of filling in the 'eventtypes' field, but I keep ending up with a generic folder with all the epochs under it like this:

This is my Conditions selection screen when using the GUI:

and the Import EEG-EEGLAB file screen:

Any help as to what I can do to get the epochs into their individual condition folders while using the script would be greatly appreciated.

Thank you,
Paul

You need to enter only "type" as the option "Event types", together with the option "Create one condition for each event type".

Example for a file where I want to use the parameter "cell" to classify my epochs:

image

From the pipeline editor, it looks like this:

The output structure in the database explorer:
image

1 Like

(watch out for the additional input parameters: the DC offset correction must be added as a separate process - in my example, the GUI version is corrected but not the script version)

Hi there,
I am trying to do the same, import with condition folders in scripting mode not through the gui. I have no problems with the gui, imports them perfectly but writing the code, I can't find the right combination in "process_import_data_epoch" to do that. Probably I am missing something very obvious...
My attempt is as follows:

sFiles = bst_process('CallProcess', 'process_import_data_epoch', sFiles, [], ...
    'ImportMode','Event',...
    'UseEvents', 1,...
    'TimeRange',[-3000,2990],... 
    'GetAllEpochs',1,...
    'eventstypes','type',...
    'subjectname',  SNames{sb}, ....
    'datafile',     {pFile, 'EEG-EEGLAB'}, ...
    'split',        0, ...
    'ignoreshort',  1, ...
    'channelalign', 0, ...
    'usectfcomp',   0, ...
    'usessp',       0, ...
    'freq',         [], ...
    'baseline',     []);

Any suggestions of what I am doing wrong will be appreciated, thanks!!

Probably I am missing something very obvious...

  • Update Brainstorm
  • Configure the process Import MEG/EEG: Existing epochs in order to obtain what you want (and make sure you really have existing epochs in the file, otherwise you need to select the "Events" process)
  • Generate the script for calling the process Import MEG/EEG: Existing epochs
  • Do not try to modify the list of parameters (this "GetAllEpochs" you added is not linked to anything). The process executed from the GUI or from a script do exactly the same thing. If there are issues that are not available in the process options, then they won't be available from a script.

Starting by reading the Scripting tutorial would probably help you:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Starting_a_new_script

1 Like