EEGLAB Documentation

repository·develop·Indexed 21 days ago

https://github.com/sccn/eeglab

An open-source signal processing environment for electrophysiological signals, such as EEG, running on Matlab and Octave. It provides a comprehensive toolbox for analyzing single-trial EEG dynamics and independent component analysis (ICA). The environment includes a graphic interface toolkit using the inputgui function and a Resampling Statistical Toolkit for inferential statistics using bootstrap and permutation methods.

Tokens
2K
Snippets
7
Records
11
Agent score
74%

What's inside EEGLAB

  1. Use the Resampling Statistical Toolkit for inferential statistics

    develop

    The Resampling Statistical Toolkit is a package within EEGLAB designed for inferential statistics using resampling methods (bootstrap and permutation). Data are organized into arrays, allowing multiple tests to be executed simultaneously across dimensions such as time, electrodes, and subjects.

    Requirements

    • Matlab: Required for all functions.
    • Statistics Matlab Toolbox: Required only if performing parametric statistics. It is NOT required for resampling methods (bootstrap/permutation).

    Data Organization

    To run multiple tests at once, organize your data into arrays where the last dimension represents the subjects. For example, a design with 100 time points, 64 electrodes, and 10 subjects should be shaped as (100, 64, 10).

  2. EEGLAB Directory Structure Overview

    develop

    The EEGLAB repository is organized into several key directories:

    • /functions: Contains all distributed EEGLAB functions, categorized into admin, sigproc, pop, and misc.
    • /plugins: The location where downloaded EEGLAB plug-ins should be placed. dipfit (1.0) is included by default.
    • /sample_data: Contains miscellaneous EEGLAB data used for tutorials and references.
    • /sample_locs: Contains standard channel location files (e.g., 10-10, 10-20).
  3. Run EEGLAB in Matlab

    develop

    To start the EEGLAB environment, follow these steps:

    1. Launch Matlab.
    2. Use the Matlab file browser or cd command to navigate to the directory containing the EEGLAB installation.
    3. At the Matlab command prompt (>>), type eeglab and press Enter.

    Note: If you encounter permission or execution issues, try running Matlab as an administrator.

    >> eeglab
  4. Install EEGLAB via Git

    develop

    To install EEGLAB using Git, you must use the --recurse-submodules flag. Downloading a ZIP file directly from GitHub is not recommended because it will not include the necessary EEGLAB submodules required for full functionality.

    If you have already cloned the repository without submodules, you can initialize them by navigating to the eeglab folder and running the submodule update commands.

    # Recommended way to clone
    git clone --recurse-submodules https://github.com/sccn/eeglab.git
    
    # If you forgot to include submodules during the initial clone
    git submodule update --init --recursive --remote
    git pull --recurse-submodules
  5. Create a graphic interface with inputgui

    develop

    The inputgui function is the primary tool for creating complex graphic interfaces in EEGLAB. It allows you to define a layout of uicontrols (like text labels and edit boxes) and returns the user's input.

    Basic Usage

    You can define a list of controls using the 'uilist' argument. Each control is defined as a cell array specifying its style, string, and optional tags.

    Output Format

    • res: A cell array containing the output values.
    • userdat: User data structure.
    • strhalt: Indicates if the user halted the process.
    • restag: A structure where each field corresponds to a tag defined in the uilist. For example, if a control has the tag 'editstr', the value will be accessible via restag.editstr.
    [res userdat strhalt restag] = inputgui('geometry', { 1 1 }, 'uilist', ...
                              { { 'style' 'text' 'string' 'Enter a value' } ...
                                { 'style' 'edit' 'string' '' 'tag' 'editstr' } });
    
    % Access the edited string via the tag
    value = restag.editstr;
  6. Compute paired or unpaired tests with statcond

    develop

    The statcond function is the main entry point for computing paired or unpaired t-tests, 1-way ANOVA, and 2-way ANOVA. It supports both parametric methods (via the Matlab statistics toolbox) and resampling methods.

    Usage Patterns

    1. Parametric Test Uses the standard Matlab statistics toolbox.

    [t df p] = statcond({ cond1 cond2 });

    2. Bootstrap Resampling Uses bootstrap methods. Use the 'mode' option set to 'bootstrap' and specify the number of accumulations with 'naccu'.

    [t df p] = statcond({ cond1 cond2 }, 'mode', 'bootstrap', 'naccu', 1000);

    3. Permutation Test Uses permutation methods. Use the 'mode' option set to 'perm' and specify the number of accumulations with 'naccu'.

    [t df p] = statcond({ cond1 cond2 }, 'mode', 'perm', 'naccu', 1000);

    Outputs

    • t: The test statistic.
    • df: Degrees of freedom.
    • p: The p-value(s).
    cond1 = rand(100,64,10); % 100 time points, 64 electrodes, 10 subjects
    cond2 = rand(100,64,10)+0.2;
    
    % Parametric
    [t df p] = statcond({ cond1 cond2 });
    
    % Bootstrap
    [t df p] = statcond({ cond1 cond2 }, 'mode', 'bootstrap', 'naccu', 1000);
    
    % Permutation
    [t df p] = statcond({ cond1 cond2 }, 'mode', 'perm', 'naccu', 1000);
  7. Define complex GUI geometry with inputgui

    develop

    For non-trivial layouts, use the 'geom' input in inputgui. This works similarly to the Matlab subplot function, allowing you to define specific bounding boxes for each control.

    Each geometry entry is a cell array: {rows, cols, [x_start, y_start], [x_end, y_end]}.

    res = inputgui('geom', { {2 1 [0 0] [1 1]} {2 1 [1 0] [1 1]} }, 'uilist', ...
                              { { 'style' 'text' 'string' 'Enter a value' } ...
                                { 'style' 'edit' 'string' '' } });
  8. Use EEGLAB dialog replacements for standard Matlab functions

    develop

    EEGLAB provides enhanced versions of standard Matlab dialog functions that use the inputgui toolkit for a consistent look and feel. Use these instead of the built-in Matlab functions:

    • questdlg2: Replaces questdlg (Question dialog)
    • errordlg2: Replaces errordlg (Error dialog)
    • warndlg2: Replaces warndlg (Warning dialog)
    • listdlg2: Replaces listdlg (List selection dialog)
    • inputdlg2: Replaces inputdlg (Input dialog)
    % Example using questdlg2
    ButtonName = questdlg2('What is your favorite color?', 'Color Question', ...
                             'Red', 'Green', 'Blue', 'Green');
  9. Reference of statistical functions in the toolkit

    develop

    The following functions are available in the Resampling Statistical Toolkit:

    FunctionDescription
    statcondMain function for paired/unpaired t-tests, 1-way ANOVA, and 2-way ANOVA
    fdrImplements False Detection Rate method for multiple comparisons correction
    teststatFunction testing the statcond function output
    ttest_cellComputes paired t-test
    ttest2_cellComputes unpaired t-test
    anova1_cell1-way unpaired ANOVA (equivalent to Matlab anova1)
    anova1rm_cell1-way repeated measures (paired) ANOVA
    anova2_cell2-way unpaired ANOVA (equivalent to Matlab anova2)
    anova2rm_cell2-way repeated measures (paired) ANOVA
    combinedataSupport function to combine different conditions for statcond