Documentation: Some Practical Examples of how to use the BBCI Toolbox


IN CONSTRUCTION


Table of Contents

ERP Analysis

% Define some settings
disp_ival= [-200 1000];
ref_ival= [-200 0];
crit_maxmin= 70;
crit_ival= [100 800];
crit_clab= {'F9,z,10','AF3,4'};
clab= {'Cz','PO7'};
colOrder= [1 0 1; 0.4 0.4 0.4];

file= 'VPibv_10_11_02/CenterSpellerMVEP_VPibv';
[cnt, mrk, mnt]= eegfile_loadMatlab(file);

% Apply highpass filter to reduce drifts
b= procutil_firlsFilter(0.5, cnt.fs);
cnt= proc_filtfilt(cnt, b);
  
% Artifact rejection based on variance criterion
mrk= reject_varEventsAndChannels(cnt, mrk, disp_ival, 'verbose', 1);

% Segmentation
epo= cntToEpo(cnt, mrk, disp_ival);
  
% Artifact rejection based on maxmin difference criterion on frontal chans
epo= proc_rejectArtifactsMaxMin(epo, crit_maxmin, ...
            'clab',crit_clab, 'ival',crit_ival, 'verbose',1);
epo= proc_baseline(epo, ref_ival);
epo_r= proc_r_square_signed(epo);
  
fig_set(1);
constraint= ...
      {{-1, [100 300], {'I#','O#','PO7,8','P9,10'}, [50 300]}, ...
       {1, [200 350], {'P3-4','CP3-4','C3-4'}, [200 400]}, ...
       {1, [400 500], {'P3-4','CP3-4','C3-4'}, [350 600]}};
[ival_scalps, nfo]= ...
    select_time_intervals(epo_r, 'visualize', 1, 'visu_scalps', 1, ...
                          'title', untex(file), ...
                          'clab',{'not','E*'}, ...
                          'constraint', constraint);
printFigure('r_matrix', [18 13], opt_fig);
ival_scalps= visutil_correctIvalsForDisplay(ival_scalps, 'fs',epo.fs);

fig_set(3)
H= grid_plot(epo, mnt, defopt_erps, 'colorOrder',colOrder);
grid_addBars(epo_r, 'h_scale',H.scale);
printFigure(['erp'], [19 12], opt_fig);

fig_set(2);
H= scalpEvolutionPlusChannel(epo, mnt, clab, ival_scalps, defopt_scalp_erp2, ...
                             'colorOrder',colOrder);
grid_addBars(epo_r);
printFigure(['erp_topo'], [20  4+5*size(epo.y,1)], opt_fig);

fig_set(4, 'shrink',[1 2/3]);
scalpEvolutionPlusChannel(epo_r, mnt, clab, ival_scalps, defopt_scalp_r2);
printFigure(['erp_topo_r'], [20 9], opt_fig);

Even in this very basic ERP analysis, there are several steps, in which the choice of processing can have quite a big impact on the results, but nevertheless, the correct choice is not clear to us (maybe we will find out a recommendable choice at some point).

  1. Highpass filter (lines ).
    • Alternatives are proc_subtractMovingAverage(cnt, 1500, 'centered', 'sinus'), other highpass filters, or no highpass filtering at all. Also bandpass filtering is an alternative (e.g. [0.5 30]), but typically the lowpass filtering is not required since high frequency are dampened also by the normal ERP averaging across trials.

  2. Baseline correction. For the ERP themselves the choice of baseline correction does not matter.
    • They stay the same. But for the measure for discriminability (e.g. r^2-values) it may have a big impact. In this example, baseline correction is performed on a trialwise basis. This way it is done for online experiments. For the ERP analysis this may be have the disturbing consequency, that the r^2-values in/near the baseline interval can become spuriously high, since the trial-to-trial variance is artificially reduced. Alternatives are to subtract the across-trials

      average of the baseline (option 'trialwise',0 in proc_baseline) or to subtract the classwise average of the baseline (option 'classwise',1 in proc_baseline).

  3. Measure for discriminability (line ). Choices are, e.g., signed r^2, t-values, p-values, AUC-score.