forked from francopestilli/life_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
s_fe_fit_test_bas.m
85 lines (72 loc) · 2.58 KB
/
s_fe_fit_test_bas.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
function fe = s_fe_fit_test_bas()
%
% This function:
% - Initializes a LIFE structure from a candidate connectome
% - Generates an optimized connectome from a cadidate connectome using
% LIFE method
%
% fe = s_fe_fit()
%
% INPUTS: none
% OUTPUTS: fe structure the optimized life structure
%
% Copyright Franco Pestilli (2013) Vistasoft Stanford University.
%% Get the base directory for the data
datapath ='/home/frk/Dropbox/Life/life_test_MCH';
% Build the file names for the diffusion data, the anatomical MR, the fiber
% group containing the connectome and the
dwiFile = fullfile(datapath,'dwi_aligned_trilin_sham.nii.gz');
dwiFileRepeat = fullfile(datapath,'dwi_aligned_trilin_sham.nii.gz');
t1File = fullfile(datapath,'t1_acpcnii.gz');
fgFileName = fullfile(datapath,'dwi_aligned_trilin_csd_lmax6_dwi_aligned_trilin_brainmask_dwi_aligned_trilin_wm_prob-500.pdb');
savedir = datapath;
% The final connectome and dat astructure will be saved with this name:
feFileName = 'fe_test_fit';
% Intialize a local matlab cluster if the parallel toolbox is available.
feOpenLocalCluster;
%% Initialize the Connectome
fe = feConnectomeInit(dwiFile,fgFileName,feFileName,savedir,dwiFileRepeat,t1File);
%% Fit the model and cull. This will take some time...
fe = feConnectomeCull(fe);
%% Save it
feConnectomeSave(fe);
%% Make a plot of the weights:
w = feGet(fe,'fiber weights');
figName = sprintf('Fascicle weights');
mrvNewGraphWin(figName);
[y,x] = hist(w(w>0),logspace(-4,-.3,50));
semilogx(x,y)
set(gca,'tickdir','out','fontsize',16,'box','off')
title('fascicle weights','fontsize',16)
ylabel('number of fascicles','fontsize',16)
xlabel('fascicle weight','fontsize',16)
%% Make a plot of the RMSE:
rmse = feGet(fe,'vox rmse');
rmsexv = feGetRep(fe,'vox rmse');
figName = sprintf('RMSE');
mrvNewGraphWin(figName);
% Non-cross-validated
[y,x] = hist(rmse,50);
plot(x,y,'k-')
hold on
% Cross-validated
[y,x] = hist(rmsexv,50);
plot(x,y,'r-')
set(gca,'tickdir','out','fontsize',16,'box','off')
title('Root-mean squared error distribution across voxels','fontsize',16)
ylabel('number of voxels','fontsize',16)
xlabel('rmse','fontsize',16)
legend({'RMSE fitted data set','RMSE cross-validated'},'fontsize',16)
%% Make a plot of the RMSE Ratio:
R = feGetRep(fe,'voxrmseratio');
figName = sprintf('RMSE RATIO');
mrvNewGraphWin(figName);
[y,x] = hist(R,linspace(.5,2,50));
plot(x,y,'k-')
hold on
plot([1 1],[0 450],'k--')
set(gca,'tickdir','out','fontsize',16,'box','off')
title('Root-mean squared error Ratio','fontsize',16)
ylabel('number of voxels','fontsize',16)
xlabel('R_{rmse}','fontsize',16)
return