Skip to content

Commit 9d52bbe

Browse files
authored
Update automated_pipeline.md
1 parent 9ce672c commit 9d52bbe

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

tutorials/11_Scripting/automated_pipeline.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Download the data from [https://openneuro.org/datasets/ds003061/](https://openne
2828

2929
Alternatively, use one of the available [EEGLAB studies](../tutorial_data.html). Note that some of these studies already have their data preprocessed and may not be suitable for automated processing.
3030

31-
Running the pipeline
31+
Running an ERP pipeline
3232
----------------
3333

3434
The pipeline below takes the raw data from all subjects, clean the data, extracts epochs of interest, and plots the grand average ERP.
@@ -51,7 +51,73 @@ pop_editoptions( 'option_storedisk', 1); % only one dataset in memory at a time
5151
[STUDY, ALLEEG] = pop_importbids(filepath, 'studyName','Oddball', 'subjects', [1:2]); % when using all subjects, one subject is truncated and cause the pipeline to return an error
5252
5353
% remove non-ALLEEG channels (it is also possible to process ALLEEG data with non-ALLEEG data
54-
ALLEEG = pop_select( ALLEEG,'nochannel',{'EXG1','EXG2','EXG3','EXG4','EXG5','EXG6','EXG7','EXG8', 'GSR1', 'GSR2', 'Erg1', 'Erg2', 'Resp', 'Plet', 'Temp'});
54+
ALLEEG = pop_select( ALLEEG,'rmchannel',{'EXG1','EXG2','EXG3','EXG4','EXG5','EXG6','EXG7','EXG8', 'GSR1', 'GSR2', 'Erg1', 'Erg2', 'Resp', 'Plet', 'Temp'});
55+
56+
% compute average reference
57+
ALLEEG = pop_reref( ALLEEG,[]);
58+
59+
% clean data using the clean_rawdata plugin
60+
ALLEEG = pop_clean_rawdata( ALLEEG,'FlatlineCriterion',5,'ChannelCriterion',0.87, ...
61+
'LineNoiseCriterion',4,'Highpass',[0.25 0.75] ,'BurstCriterion',20, ...
62+
'WindowCriterion',0.25,'BurstRejection','on','Distance','Euclidian', ...
63+
'WindowCriterionTolerances',[-Inf 7] ,'fusechanrej',1);
64+
65+
% recompute average reference interpolating missing channels (and removing
66+
% them again after average reference - STUDY functions handle them automatically)
67+
ALLEEG = pop_reref( ALLEEG,[],'interpchan',[]);
68+
69+
% run ICA reducing the dimention by 1 to account for average reference
70+
plugin_askinstall('picard', 'picard', 1); % install Picard plugin
71+
ALLEEG = pop_runica(ALLEEG, 'icatype','picard','concatcond','on','options',{'pca',-1});
72+
73+
% run ICLabel and flag artifactual components
74+
ALLEEG = pop_iclabel(ALLEEG, 'default');
75+
ALLEEG = pop_icflag( ALLEEG,[NaN NaN;0.9 1;0.9 1;NaN NaN;NaN NaN;NaN NaN;NaN NaN]);
76+
77+
% extract data epochs
78+
% this is not necessary if you have resting state data or eyes open
79+
% eyes closed data, you need to define the design in the STUDY
80+
ALLEEG = pop_epoch( ALLEEG,{'oddball_with_reponse','standard'},[-1 2] ,'epochinfo','yes');
81+
ALLEEG = eeg_checkset( ALLEEG );
82+
83+
% create STUDY design
84+
STUDY = std_maketrialinfo(STUDY, ALLEEG);
85+
STUDY = std_makedesign(STUDY, ALLEEG, 1, 'name','STUDY.design 1','delfiles','off', ...
86+
'defaultdesign','off','variable1','type','values1',{'oddball_with_reponse','standard'},...
87+
'vartype1','categorical','subjselect', STUDY.subject);
88+
89+
% precompute ERPs at the STUDY level
90+
[STUDY, ALLEEG] = std_precomp(STUDY, ALLEEG, {},'savetrials','on','rmicacomps','on','interp','on','recompute','on','spec','on');
91+
92+
% plot ERPS
93+
STUDY = pop_erpparams(STUDY, 'topotime',350);
94+
chanlocs = eeg_mergelocs(ALLEEG.chanlocs); % get all channels from all datasets
95+
STUDY = std_specplot(STUDY,ALLEEG,'channels', {chanlocs.labels}, 'design', 1);
96+
97+
% revert default option
98+
pop_editoptions( 'option_storedisk', 0);
99+
```
100+
101+
Running an spectral pipeline
102+
----------------
103+
104+
The pipeline below takes the raw data from all subjects, clean the data, extracts epochs of interest, and plots the spectrum to compare conditions. It is very similar to the ERP pipeline above.
105+
106+
```matlab
107+
% check folder
108+
eeglab;
109+
if ~exist('task-P300_events.json', 'file')
110+
error('Download the data from https://openneuro.org/datasets/ds003061/ and go to the downloaded folder');
111+
else
112+
filepath = fileparts(which('task-P300_events.json'));
113+
end
114+
115+
% import data
116+
pop_editoptions( 'option_storedisk', 1); % only one dataset in memory at a time
117+
[STUDY, ALLEEG] = pop_importbids(filepath, 'studyName','Oddball', 'subjects', [1:2]); % when using all subjects, one subject is truncated and cause the pipeline to return an error
118+
119+
% remove non-ALLEEG channels (it is also possible to process ALLEEG data with non-ALLEEG data
120+
ALLEEG = pop_select( ALLEEG,'rmchannel',{'EXG1','EXG2','EXG3','EXG4','EXG5','EXG6','EXG7','EXG8', 'GSR1', 'GSR2', 'Erg1', 'Erg2', 'Resp', 'Plet', 'Temp'});
55121
56122
% compute average reference
57123
ALLEEG = pop_reref( ALLEEG,[]);

0 commit comments

Comments
 (0)