-
Notifications
You must be signed in to change notification settings - Fork 27
scripting 1st level analysis
This is the preferred option, as this calls limo_batch and the psom pipeline engine which captures error and thus avoid crashing even if one subject fails - and output a report.
If you have a STUDY in EEGLAB, then all is needed is define the design, i.e. which variables to use, then call LIMO. This can be done in two (actually 3 if we count the save) commands: std_makedesign and pop_limo.
For instance doing:
STUDY = std_makedesign(STUDY, ALLEEG, 1, 'name','FaceRepetition','delfiles','off','defaultdesign','off','variable1','type','values1',{'famous_new','famous_second_early','famous_second_late','scrambled_new','scrambled_second_early','scrambled_second_late','unfamiliar_new','unfamiliar_second_early','unfamiliar_second_late'}, 'vartype1','categorical','subjselect',{'sub-002','sub-003','sub-004','sub-005','sub-006','sub-007','sub-008','sub-009','sub-010','sub-011','sub-012','sub-013','sub-014','sub-015','sub-016','sub-017','sub-018','sub-019'});
[STUDY, EEG] = pop_savestudy( STUDY, EEG, 'savemode','resave');
STUDY = pop_limo(STUDY, ALLEEG, 'method','OLS','measure','daterp','timelim',[-50 650],'erase','on','splitreg','off','interaction','off');
one creates a design (here with 9 conditions) and a given set of subjects using std_makedesign, saves it to make sure all fields are up to date, and call pop_limo with LIMO options.
Define the model yourself and call limo_batch
start by indicating files to load
model.set_files = {'D:\DataSets\Face_repetition\sub-02\eeg\sub-02_proc.set'}; % cell array of subjects
model.cat_files = {'D:\DataSets\Face_repetition\sub-02\eeg\cat_factorial_fake.txt'};
model.cont_files = []; % a cell array of continuous variable or variable files
then indicates the model parameters
model.defaults.type = 'Channels';
model.defaults.analysis = 'Time';
model.defaults.method = 'WLS'; % 'OLS'
model.defaults.type_of_analysis = 'univariate';
model.defaults.fullfactorial = 1;
model.defaults.zscore = 0;
model.defaults.start = -50; % starting time in ms
model.defaults.end = 600; % ending time in ms
model.defaults.bootstrap = 0;
model.defaults.tfce = 0;
neighbours = load('D:\DataSets\Face_repetition\derivatives\limo_gp_level_chanlocs.mat')
model.defaults.neighbouring_matrix = neighbours.channeighbstructmat;
finally run limo_batch.m
[LIMO_files, procstatus] = limo_batch('model specification',model,[])
Using limo_batch is the easiest option, for instance
contrast.LIMO_files = all_my_LIMO.mat_files_as_list;
contrast.mat = [1 1 1 -1 -1 -1 0 0 0 0 ; 0 0 0 1 1 1 -1 -1 -1 0];
confiles = limo_batch('contrast only',[],contrast,STUDY);
will compute 3 contrasts for all subjects listed in contrast.LIMO_files
Below is an example of code that will run the analysis for one subject, this does the same job as calling limo_batch above but gives you access to lower level functions and can thus be adapted for each subject if needed.
% load EEGLAB data
EEGLIMO = pop_loadset('D:\DataSets\Face_repetition\sub-02\eeg\sub-02_proc.set');
% set fields for data
LIMO.data.data_dir = 'D:\DataSets\Face_repetition\sub-02\eeg';
LIMO.data.data = 'sub-02_proc.set';
LIMO.data.chanlocs = EEGLIMO.chanlocs;
LIMO.data.sampling_rate = EEGLIMO.srate;
LIMO.data.Cat = load('cat_factorial_fake.txt');
LIMO.data.Cont = [];
LIMO.data.start = -50;
LIMO.data.trim1 = 476;
LIMO.data.end = 600;
LIMO.data.trim2 = 801;
LIMO.data.timevect = EEGLIMO.times(LIMO.data.trim1:LIMO.data.trim2);
% set design`
LIMO.design.fullfactorial = 1;
LIMO.design.zscore = 0;
LIMO.design.method = 'WLS';
LIMO.design.type_of_analysis = 'Mass-univariate';
LIMO.design.bootstrap = 0;
LIMO.design.tfce = 0;
% LIMO stuff `
LIMO.Type = 'Channels';
LIMO.Level = 1;
LIMO.Analysis = 'Time';
LIMO.dir = 'D:\DataSets\Face_repetition\sub-02\eeg\WLS';
mkdir('D:\DataSets\Face_repetition\sub-02\eeg\WLS')
cd('D:\DataSets\Face_repetition\sub-02\eeg\WLS')
save('D:\DataSets\Face_repetition\sub-02\eeg\WLS\LIMO.mat','LIMO')
% evaluate the design
[LIMO.design.X,LIMO.design.nb_conditions,LIMO.design.nb_interactions,LIMO.design.nb_continuous] = ...
limo_design_matrix(EEGLIMO.data(:,LIMO.data.trim1:LIMO.data.trim2,:),LIMO,1);
LIMO.design.status = 'to do';
save('D:\DataSets\Face_repetition\sub-02\eeg\WLS\LIMO.mat','LIMO')
% run the GLM
limo_eeg(4,pwd)
Downsampling or not before analyzing
Defining conditions defining
~ categorical.txt ~continuous.txt
EEGLAB-STUDY: run, session, condition and group
Basic Stats: LIMO tests and CI
Repeated measures ANOVA
Results in the workspace
Results in LIMO.cache
Checking data under the plots
Reordering plots
Compute & Plot conditions
Compute & Plot differences
Channel neighbourhood
Editing a neighbourhood matrix
Scripting 1st level
Debugging 1st level errors
Skip 1st level
Scripting 2nd level
Getting stats results with a script