forked from haililihai/ATPP_CLI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathROI_calc_matrix.m
60 lines (51 loc) · 1.77 KB
/
ROI_calc_matrix.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
function ROI_calc_matrix(PWD,ROI,SUB_LIST,POOLSIZE,VAL_THRES,DOWN_SIZE,LEFT,RIGHT)
% calculate the connectivity and correlation matrix
% load_nii_hdr modified to support .gz files
SUB=textread(SUB_LIST,'%s');
threshold = VAL_THRES;
resampflag = 1;
NewVoxSize = [DOWN_SIZE DOWN_SIZE DOWN_SIZE];
method = 1;
% Parallel Computing Toolbox settings
% 2014a removed findResource, replaced by parcluster
% 2016b removed matlabpool, replaced by parpool
% modify temporary dir
temp_dir=tempname();
mkdir(temp_dir);
if exist('parcluster')
pc=parcluster('local');
pc.JobStorageLocation=temp_dir;
else
sched=findResource('scheduler','type','local');
sched.DataLocation=temp_dir;
end
% open pool
if exist('parpool')
p=parpool('local',POOLSIZE);
else
matlabpool('local',POOLSIZE);
end
parfor i = 1:length(SUB)
subCreateMatrix(PWD,SUB{i},ROI,LEFT,RIGHT,threshold,resampflag,NewVoxSize,method)
end
% close pool
if exist('parpool')
delete(p);
else
matlabpool close;
end
function subCreateMatrix(PWD,SUBi,ROI,LEFT,RIGHT,threshold,resampflag,NewVoxSize,method)
if LEFT == 1
coord_L = load(strcat(PWD,'/',SUBi,'/',SUBi,'_',ROI,'_L_coord.txt'));
imgfolder_L = strcat(PWD,'/',SUBi,'/',SUBi,'_',ROI,'_L_probtrackx');
outfolder_L = strcat(PWD,'/',SUBi,'/',SUBi,'_',ROI,'_L_matrix/');
if ~exist(outfolder_L,'dir') mkdir(outfolder_L);end
f_Create_Matrix_v3(imgfolder_L,outfolder_L,coord_L,threshold,resampflag,NewVoxSize,method);
end
if RIGHT == 1
coord_R = load(strcat(PWD,'/',SUBi,'/',SUBi,'_',ROI,'_R_coord.txt'));
imgfolder_R = strcat(PWD,'/',SUBi,'/',SUBi,'_',ROI,'_R_probtrackx');
outfolder_R = strcat(PWD,'/',SUBi,'/',SUBi,'_',ROI,'_R_matrix/');
if ~exist(outfolder_R,'dir') mkdir(outfolder_R);end
f_Create_Matrix_v3(imgfolder_R,outfolder_R,coord_R,threshold,resampflag,NewVoxSize,method);
end