-
Notifications
You must be signed in to change notification settings - Fork 0
/
runPermDecoding.m
36 lines (35 loc) · 1.17 KB
/
runPermDecoding.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
function runPermDecoding(p)
permFlag = 1;
disp('***************************')
disp('Permutation test: computing')
disp('***************************')
for permInd = 1:p.perm.n
disp(['Perm ' num2str(permInd) '/' num2str(p.perm.n)])
if permInd==1
resp = [];
fov = [];
end
[respP,resp] = permuteLabels(p,resp);
[featSelP,fov] = processFeatSel(p,permFlag,respP,fov);
[resBSP,~,~,~,~] = runAllDecoding(p,permFlag,respP,featSelP);
if permInd == 1
auc = nan([size(resBSP) p.perm.n]);
end
tmp = reshape([resBSP{:}],size(resBSP));
% tmp = reshape([tmp.subj],size(tmp));
tmp = reshape(permute([tmp.auc],[2 3 1]),[size(tmp) size(tmp(1).auc,1)]);
auc(:,:,permInd) = mean(tmp,3); clear tmp
end
disp('**********************')
disp('Permutation test: done')
disp('**********************')
% Save permutations
disp('Saving permutations')
auc = permute(auc,[3 1 2]);
resBSP = cell(size(resBSP));
for i = 1:numel(auc(1,:))
resBSP{i}.subj.aucP = permute(auc(:,i),[2 3 1]);
end
outFile = fullfile(p.wd,'results',p.anaID,'decoding.mat');
save(outFile,'resBSP','-append');
disp(['Permutations appended to ' outFile ' as variable respBSP'])