-
Notifications
You must be signed in to change notification settings - Fork 7
/
bf_regularise_manual.m
49 lines (41 loc) · 1.21 KB
/
bf_regularise_manual.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
function res = bf_regularise_manual(BF, S)
% Manual specification of the regularisation parameter
% Copyright (C) 2013 Wellcome Trust Centre for Neuroimaging
% Vladimir Litvak
% $Id$
%--------------------------------------------------------------------------
if nargin == 0
lambda = cfg_entry;
lambda.tag = 'lambda';
lambda.name = 'Regularisation';
lambda.strtype = 'r';
lambda.num = [1 1];
lambda.val = {0};
lambda.help = {'Select the regularisation (in %)'};
res = cfg_branch;
res.tag = 'manual';
res.name = 'User-specified regularisation';
res.val = {lambda};
return
elseif nargin < 2
error('Two input arguments are required');
end
%%%%%%%%%
%MWW 19/11/2014
% added to be compatible with multi-class festures (see bf_features)
if isfield(S,'class'),
features_mod = BF.features.(S.modality).class{S.class};
else
features_mod = BF.features.(S.modality);
end;
C = features_mod.C;
%%%%%%%%%
lambda = (S.lambda/100) * trace(C)/size(C,1);
C = C + lambda * eye(size(C));
Cinv = pinv_plus(C);
U = eye(size(C));
features = BF.features.(S.modality);
features.C = C;
features.Cinv = Cinv;
features.U = U;
res = features;