-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_algorithm.m
123 lines (107 loc) · 3.03 KB
/
main_algorithm.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
% Five parcellation approaches.
% 2015-6-16 08:29:24
% SLIC: a whole brain parcellation toolbox
% Copyright (C) 2016 Jing Wang
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
% clear,clc;
load sInfo.mat;
% create folders to store the results
mkdir('sub_weight');
mkdir('sub_eigen');
mkdir('mean_weight');
mkdir('mean_eigen');
mkdir('MSC_sub_parc');
mkdir('SLIC_sub_parc');
mkdir('MSC_mean_parc');
mkdir('MSC_twolevel_weight');
mkdir('MSC_twolevel_eigen');
mkdir('MSC_twolevel_parc');
mkdir('MKSC_parc');
mkdir('SLIC_mean_parc');
mkdir('SLIC_twolevel_weight');
mkdir('SLIC_twolevel_eigen');
mkdir('SLIC_twolevel_parc');
% preproocess
mkdir('prep');
parc_parpool(nWorker);
parfor iSub=1:nSub
parc_normalize(iSub);
end
% sub_weight, sub_eigen
% this step consumes a lot of memory
parc_parpool(floor(nWorker*3/4));
parfor iSub=1:nSub
opt=1; % opt=1-6, two weighting functions, three sparsifying schemes
sub_weight(iSub,opt);
sub_eigen(iSub);
end
% sub_parc
stat=[];
for iSub=1:nSub
cSub=sSub(iSub);
for iK=1:nK
cK=sK(iK);
if ~exist(sprintf('SLIC_sub_parc/sub%05d_K%d.mat',cSub,cK))
stat=[stat;iSub,iK];
end
end
end
n=size(stat,1);
fprintf('The number of tasks: %d. \n',n);
parc_parpool(nWorker);
parfor i=1:n
iSub=stat(i,1);
iK=stat(i,2);
MSC_sub_parc(iSub,iK);
SLIC_sub_parc(iSub,iK);
end
% mean_weight, mean_eigen
parc_parpool(nWorker);
parfor iRep=1:nRep
for iPart=1:nPart
mean_weight(iPart,iRep);
mean_eigen(iPart,iRep);
end
end
% mean_parc and twolevel_parc
% three loops
stat=[];
for iK=1:nK
cK=sK(iK);
for iPart=1:nPart
for iRep=1:nRep
if ~exist(sprintf('SLIC_twolevel_parc/K%d_part%d_rep%d.mat',cK,iPart,iRep));
stat=[stat;iK,iPart,iRep];
end
end
end
end
n=size(stat,1);
fprintf('The number of tasks: %d. \n',n);
parc_parpool(nWorker);
parfor i=1:n
iK=stat(i,1);
iPart=stat(i,2);
iRep=stat(i,3);
MSC_mean_parc(iK,iPart,iRep);
MSC_twolevel_weight(iK,iPart,iRep);
MSC_twolevel_eigen(iK,iPart,iRep);
MSC_twolevel_parc(iK,iPart,iRep);
MKSC_parc(iK,iPart,iRep);
SLIC_mean_parc(iK,iPart,iRep);
SLIC_twolevel_weight(iK,iPart,iRep);
SLIC_twolevel_eigen(iK,iPart,iRep);
SLIC_twolevel_parc(iK,iPart,iRep);
end