-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzf_bmr.m
104 lines (85 loc) · 2.86 KB
/
zf_bmr.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
%% Housekeeping
%==========================================================================
fs = filesep;
D = zf_housekeeping;
Fbase = D.Fbase;
Fscripts = D.Fscripts;
Fanalysis = D.Fanalysis;
Forig = D.Forig;
sub = D.subs;
% Set up Bayesian Model Reduction across models of interest
%==========================================================================
% Set up BMR structure
%--------------------------------------------------------------------------
clear P
Amod = zf_modelspace;
% Collate all models in single matrix of models
%--------------------------------------------------------------------------
for s = 1:length(sub)
clear DCM
Fdcm = [Fanalysis fs 'DCM' fs sub{s}];
load([Fdcm fs 'Full_BLN.mat']);
FCM = DCM;
DCM = rmfield(DCM, 'Ep');
DCM = rmfield(DCM, 'Cp');
for m = 1:(length(Amod)-1)
for a = 1:3
DCM.pE.A{a} = Amod{m}.A{a};
DCM.pC.A{a} = DCM.pE.A{a} .* FCM.pC.A{a};
DCM.M.pE = DCM.pE;
DCM.M.pC = DCM.pC;
end
DCM.name = Amod{m}.name;
P{s,m} = DCM;
end
% Add full model to model matrix
%--------------------------------------------------------------------------
P{s,length(Amod)} = FCM;
end
% Run Bayesian model reduction
%==========================================================================
[BLCM BLMC BLMA] = spm_dcm_bmr(P);
% Extract free energies
%--------------------------------------------------------------------------
clear F Fs
for b = 1:length(BLMC)
F(b,:) = BLMC(b).F;
end
% Extract model names
%--------------------------------------------------------------------------
for m = 1:length(Amod)
mlab{m} = Amod{m}.name;
end
%% Family wise comparison - draw figures
%==========================================================================
% Define families
%--------------------------------------------------------------------------
Flr = F(1:6) + F(7:12) + F(13:18) + F(19:24);
Fsr = F(1:6:24) + F(2:6:24) + F(3:6:24) + F(4:6:24) + F(5:6:24) + F(6:6:24);
figure(2)
set(gcf, 'color', 'w');
colormap gray
% Plot Hub connection BMC
%--------------------------------------------------------------------------
subplot(2,1,2),
% Plot
bar(Flr - min(Flr));
% Titles and legends
title('Evidence for hub connections', 'FontSize', 12, 'FontWeight', 'bold');
set(gca, 'XTick', 1:6);
set(gca, 'XTickLabel', {'None', 'Tec', 'Cbl', 'RHb', 'CHb', 'RSC'});
% Settings
% axis square
box off
% Plot Hub connection BMC
%--------------------------------------------------------------------------
subplot(2,1,1),
% Plot
bar(Fsr - min(Fsr));
% Titles and Legends
title('Evidence for short range connections', 'FontSize', 12, 'FontWeight', 'bold');
set(gca, 'XTick', 1:4);
set(gca, 'XTickLabel', {'None', 'Homol.', 'Neigh.', 'Both'})
% Settings
% axis square
box off