I did my main analysis on 3 groups (HLG_MLD, HLG_MOD, CG). I wanted to do some analysis on subgroups so I split these three groups according to median accuracy of overall sample (high vs low) creating 6 groups by adding tags HGH and LOW. To get the group averages of the three primary groups (ignoring the HGH and LOW tags) I tried the below script with loops. This led to the error. I had to use the script without loops (filling in the group names and outcomes manually) to get the averages.
Group = {'CG', 'HLG_MLD', 'HLG_MOD'}
Outcome = {'11_right', '12_right', '21_right', '22_right'}
sFiles = []
% Process: Select files using search query
sFiles = bst_process('CallProcess', 'process_select_search', [], [], ...
'search', '(([name CONTAINS "bl"] AND [name CONTAINS "Avg"] AND [path CONTAINS "Subject"]))');
for k = 1:length(Group)
for j = 1:length(Outcome)
Tag = Group{k}+"_"+Outcome{j}
% Process: Select file names with tag: resample
sFiles1 = bst_process('CallProcess', 'process_select_tag', sFiles, [], ...
'tag', Group{k});
sFiles1 = bst_process('CallProcess', 'process_select_tag', sFiles1, [], ...
'tag', Outcome{j});
% Process: Average: Everything
sFiles1 = bst_process('CallProcess', 'process_average', sFiles1, [], ...
'avgtype', 1, ... % Everything
'avg_func', 1, ... % Arithmetic average: mean(x)
'weighted', 0);
% Process: Add tag:
sFiles1 = bst_process('CallProcess', 'process_add_tag', sFiles1, [], ...
'tag', Tag, ...
'output', 1); % Add to file name
end
end