Howto import and export data

libeegtools with EEGLab/Matlab

Suppose you imported your data from your recording software into EEGlab. You want to use libEEGTools functionality that is not well implemented in Matlab/EEGlab wrappers.

Unfortunately, there is no reader for Matlab .mat files yet (the format is fairly complicated). It is therefore necessary to import/export data between libeegtools and matlab.

You have 2 options:

  1. you implement a custom .mex-file (basically a c-file using the Matlab-API) that connects EEGlab to libeegtools (see MEX-Files). Have a look at the ml_*.c files in /libeegtools/matlab. These are examples for such wrappers.
  2. you export the data you need to libeegtools and import it back to eeglab again (discussed here)

EEGlab -> libeegtools

libeegtools implements a reader/writer for a simple RAW-format that contains ERP-data for a number of trials and electrodes along with time-marker information. To convert an EEG-struct to RAW, do the following:

  1. First you need an epoched EEG-struct that contains the epochs for all experimental conditions (run "Extract Epochs" with all stimulus-onset markers).
  2. From this struct, extract the indices you want with get_epoch_indices.
  3. run eegset_to_raw to write it to a RAW-file.
Example

To write trials from condition 1 and 2 with 2 time-markers (e.g. stimulus and response) to a file.

matlab> idx = get_epoch_indices( EEG, ['stimulus_onset_condition1' 'stimulus_onset_cond2'] );
matlab> eegset_to_raw( EEG, 2, idx, 'condition1and2.raw');

libeegtools -> EEGLab

Todo:
write documentation for libeegtools -> EEGLab