Simply EEGLAB

Running on HPC

Station 9 · Lesson 6 · EEGLAB 2026.1

In the GUI

  1. FileManage EEGLAB extensions
  2. ToolsNSG ToolsNSG account info
  3. ToolsNSG ToolsManage NSG jobs

Script

eeglab nogui
projectRoot = pwd;
outRoot     = fullfile(projectRoot, 'derivatives', 'eeglab');
logRoot     = fullfile(projectRoot, 'logs');
subjects    = {'sub-002', 'sub-003', 'sub-004'};
taskId = str2double(getenv('SLURM_ARRAY_TASK_ID'));
if isnan(taskId), taskId = 1; end
subj = subjects{taskId};
fprintf('Job %d: %s\n', taskId, subj);
cfg.lineFreq  = 50;                     % same settings as the batch lesson
cfg.eogLabels = {'EEG061', 'EEG062'};
cfg.dropLabels = {'EEG063', 'EEG064'};
try
    outDir = fullfile(outRoot, subj, 'eeg');
    EEG = pop_loadset('filename', sprintf('%s_task-FaceRecognition_eeg.set', subj), ...
        'filepath', outDir);
    EEG = pop_select(EEG, 'rmchannel', cfg.dropLabels);
    fullLocs = EEG.chanlocs;
    EEG = pop_eegfiltnew(EEG, 'locutoff', 0.1);
    EEG = pop_eegfiltnew(EEG, 'locutoff', cfg.lineFreq - 2, 'hicutoff', cfg.lineFreq + 2, 'revfilt', 1);
    EEG_test = pop_clean_rawdata(EEG, 'FlatlineCriterion', 5, 'ChannelCriterion', 0.8, ...
        'LineNoiseCriterion', 4, 'Highpass', 'off', 'BurstCriterion', 'off', ...
        'WindowCriterion', 'off', 'BurstRejection', 'off', 'Distance', 'Euclidian', ...
        'channels_ignore', cfg.eogLabels);
    badChans = setdiff({EEG.chanlocs.labels}, {EEG_test.chanlocs.labels}, 'stable');
    if ~isempty(badChans)
        EEG = pop_select(EEG, 'rmchannel', badChans);
    end
    if ~isempty(badChans)
        EEG = pop_interp(EEG, fullLocs, 'spherical');
    end
    clear EEG_test
    eogIdx = find(ismember({EEG.chanlocs.labels}, cfg.eogLabels));
    EEG = pop_reref(EEG, [], 'exclude', eogIdx);
    EEG_ica = pop_eegfiltnew(EEG, 'locutoff', 1);
    tic;
    EEG_ica = pop_runica(EEG_ica, 'icatype', 'runica', 'extended', 1);
    fprintf('ICA finished in %.1f min\n', toc / 60);
    icaInfo = struct('icaweights', EEG_ica.icaweights, 'icasphere', EEG_ica.icasphere, ...
                     'icachansind', EEG_ica.icachansind, 'badChans', {badChans});
    save(fullfile(outDir, sprintf('%s_task-FaceRecognition_desc-ica.mat', subj)), ...
         '-struct', 'icaInfo');
catch err
    if ~exist(logRoot, 'dir'), mkdir(logRoot); end
    fid = fopen(fullfile(logRoot, sprintf('%s_error.txt', subj)), 'w');
    fprintf(fid, '%s\n', getReport(err, 'extended', 'hyperlinks', 'off'));
    fclose(fid);
    rethrow(err);
end

Which value should I choose?

SettingValue in this lesson
Participants per jobOne
How to runmatlab -batch
Memory16G in the example
Time limit4 hours in the example
What is savedICA weights only

For your Methods

Independent component analysis (extended Infomax; Lee et al., 1999) was computed with runica (EEGLAB 2026.1) for each participant on a copy of the preprocessed data high-pass filtered at 1 Hz, and the resulting weights were applied to the 0.1 Hz high-pass filtered data; jobs ran one per participant on [computing cluster] with MATLAB [version].

Full lesson: https://simplyeeglab.pages.dev/en/lesson/hpc/

Content license: CC BY-NC-SA 4.0 · MIT (code)

An independent learning site, not affiliated with EEGLAB or SCCN.