forked from JoramSoch/MACS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch_MA_cvLME_auto.m
82 lines (69 loc) · 2.76 KB
/
batch_MA_cvLME_auto.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 module = batch_MA_cvLME_auto
% _
% Configure MATLAB Batch for "MA: calculate cvLME (automatic)"
%
% Author: Joram Soch, BCCN Berlin
% E-Mail: joram.soch@bccn-berlin.de
%
% First edit: 17/03/2017, 04:05 (V0.99/V15)
% Last edit: 09/03/2018, 10:25 (V1.2/V18)
%=========================================================================%
% F I E L D S %
%=========================================================================%
% Select MS.mat
%-------------------------------------------------------------------------%
MS_mat = cfg_files;
MS_mat.tag = 'MS_mat';
MS_mat.name = 'Select MS.mat';
MS_mat.help = {'Select the MS.mat file describing a model space of GLMs.'};
MS_mat.filter = 'mat';
MS_mat.ufilter = '^MS\.mat$';
MS_mat.num = [1 1];
% Accuracy & Complexity
%-------------------------------------------------------------------------%
AnC = cfg_menu;
AnC.tag = 'AnC';
AnC.name = 'Accuracy & Complexity';
AnC.val = {0};
AnC.help = {'Choose whether model accuracy and model complexity are calculated in addition to the log model evidence.'};
AnC.labels = {'No', 'Yes'};
AnC.values = {0, 1};
%=========================================================================%
% M O D U L E %
%=========================================================================%
% MA: cvLME (auto)
%-------------------------------------------------------------------------%
module = cfg_exbranch;
module.tag = 'MA_cvLME_auto';
module.name = 'MA: calculate cvLME (automatic)';
module.val = {MS_mat AnC};
module.help = {'Cross-Validated Log Model Evidence for General Linear Models'
'Type "help MA_cvLME_multi" or "help MA_cvLME_single" for help.'};
module.prog = @run_module;
%=========================================================================%
% F U N C T I O N S %
%=========================================================================%
% Run batch
%-------------------------------------------------------------------------%
function out = run_module(job)
% get input variables
load(job.MS_mat{1});
AnC = logical(job.AnC);
% execute operation
[N,M] = size(MS.SPMs);
for i = 1:N
fprintf('\n-> Subject %d (%d out of %d):\n',i,i,N);
for j = 1:M
fprintf(' - Model %s (%d out of %d) ... ',MS.GLMs{j},j,M);
load(MS.SPMs{i,j}); % load SPM.mat
% update working directory, if non-existent
if ~isfield(SPM,'swd')
SPM.swd = fileparts(MS.SPMs{i,j});
end;
MA_cvLME_multi(SPM,[],[],AnC); % calculate cvLME
fprintf('successful!\n');
end;
end;
fprintf('\n');
% set output files
out = [];