-
Notifications
You must be signed in to change notification settings - Fork 7
/
bf_group.m
82 lines (65 loc) · 2.21 KB
/
bf_group.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function out = bf_group
% A module for applying a processing step to a group of subjects
% Copyright (C) 2015 Wellcome Trust Centre for Neuroimaging
% Vladimir Litvak
% $Id$
%--------------------------------------------------------------------------
% BF
%--------------------------------------------------------------------------
BF = cfg_files;
BF.tag = 'BF';
BF.name = 'BF.mat or M/EEG files';
BF.filter = '.*.mat$';
BF.num = [1 Inf];
BF.help = {'Select BF.mat file.'};
%--------------------------------------------------------------------------
% prefix
%--------------------------------------------------------------------------
prefix = cfg_entry;
prefix.tag = 'prefix';
prefix.name = 'Directory prefix';
prefix.help = {'Specify the string to be prepended to the output directory name',...
'This is only used for batches starting with the Data module.'};
prefix.strtype = 's';
prefix.num = [0 Inf];
prefix.val = {''};
%--------------------------------------------------------------------------
% plugin
%--------------------------------------------------------------------------
plugin = cfg_choice;
plugin.tag = 'plugin';
plugin.name = 'Group analysis ';
group_funs = spm_select('List', fileparts(mfilename('fullpath')), '^bf_group_.*\.m$');
group_funs = cellstr(group_funs );
for i = 1:numel(group_funs)
plugin.values{i} = feval(spm_file(group_funs{i},'basename'));
end
out = cfg_exbranch;
out.tag = 'group';
out.name = 'Group analysis';
out.val = {BF, prefix, plugin};
out.help = {'Set up group analyses'};
out.prog = @bf_group_run;
out.vout = @bf_group_vout;
out.modality = {'EEG'};
end
function out = bf_group_run(job)
plugin_name = cell2mat(fieldnames(job.plugin));
BF = job.BF;
S = job.plugin.(plugin_name);
S.prefix = job.prefix;
BF = feval(['bf_group_' plugin_name], BF, S);
if ~isa(BF, 'cell')
BF = {BF};
end
out.BF = BF(:);
end
function dep = bf_group_vout(job)
% Output is always in field "BF", no matter how job is structured
dep = cfg_dep;
dep.sname = 'BF.mat files';
% reference field "B" from output
dep.src_output = substruct('.','BF');
% this can be entered into any evaluated input
dep.tgt_spec = cfg_findspec({{'filter','mat','strtype','e'}});
end