-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhbmc_permute.m
46 lines (32 loc) · 1002 Bytes
/
hbmc_permute.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
function hbmc_permute(data,models,flaps,fdir,pconfig,group,ii)
N = length(data);
ng = max(group);
K = length(models);
Ng = nan(1,ng);
for g=1:ng
Ng(g) = sum(group==g);
end
for i=ii
nn = randperm(N);
npre = 0;
permgroup = nan(1,N);
for g=1:ng
nng = nn( npre + (1:Ng(g)) ); npre = npre + Ng(g);
permgroup(nng) = g;
end
gflap = cell(K,1);
for g=1:ng
permutations = find(permgroup==g); %#ok<NASGU>
gdata = data(permgroup==g);
for k=1:K
cbm = cbm_lap_aggregate(flaps(permgroup==g,k)); %#ok<NASGU>
gflap{k} = fullfile(fdir,sprintf('lap_model%d_perm%04d.mat',k,i));
save(gflap{k},'cbm');
end
fname = fullfile(fdir,sprintf('hbmc_perm%04d_g%d.mat',i,g));
math = hbmc(gdata,models,gflap,[],pconfig,[],[]);
cbm = math(end); %#ok<NASGU>
save(fname,'cbm','permutations');
end
end
end