-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_plot_multiparc_atlases.m
100 lines (65 loc) · 2.64 KB
/
main_plot_multiparc_atlases.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
clc;clear all;close all;restoredefaultpath;
addpath('src');
uscbrain_multi_atlas = '/ImagePTE1/ajoshi/code_farm/svreg/USCBrainMulti';%correct this
subbasename = '/home/ajoshi/Desktop/anat/sub-OAS30009_ses-d0148_run_02_T1w';% correct this
BrainSuitePath = '/home/ajoshi/BrainSuite21a'; % correct this
lmid = readdfs(fullfile(uscbrain_multi_atlas,'USCBrain.left.mid.cortex.dfs'));
rmid = readdfs(fullfile(uscbrain_multi_atlas,'USCBrain.right.mid.cortex.dfs'));
l = dir(uscbrain_multi_atlas);
for k = 3:length(l)
atlas_dir = fullfile(uscbrain_multi_atlas,l(k).name);
if ~isfolder(atlas_dir)
continue;
end
disp(atlas_dir);
atd = dir([atlas_dir,'/*.label.nii.gz']);
if length(atd)<1
continue;
end
atlasbasename = fullfile(atd(1).folder,atd(1).name);
a = regexp(atlasbasename, '.label.nii.gz', 'split');
atlasbasename = a{1};
[d,n]=fileparts(a{1});
[~,atlas_name] = fileparts(d);% n(5:end);
if strcmp(atlas_name,'Schaefer2018')
atlas_name = n(9:end);
end
%fprintf('Processing Atlas:%s\natlasbasename:%s\n------\n',atlas_name,atlasbasename);
atlas_left=readdfs([atlasbasename,'.left.mid.cortex.dfs']);
atlas_right=readdfs([atlasbasename,'.right.mid.cortex.dfs']);
xmlfile = fullfile(atlas_dir,'brainsuite_labeldescription.xml');
if ~exist("xmlfile",'file')
disp('XML FILE NOT FOUND');
disp(xmlfile);
else
xmlfile = fullfile(uscbrain_multi_atlas,'brainsuite_labeldescription.xml');
end
atlas_left.vertices = lmid.vertices;
atlas_right.vertices = rmid.vertices;
atlas_left_file = 'tmpleft.dfs';
writedfs(atlas_left_file,atlas_left);
atlas_right_file = 'tmpright.dfs';
writedfs(atlas_right_file,atlas_right);
recolor_by_label(atlas_left_file,[],xmlfile);
recolor_by_label(atlas_right_file,[],xmlfile);
atlas_left = readdfs(atlas_left_file);
atlas_right = readdfs(atlas_right_file);
%h=figure;
h=figure('Position', [10 10 900 1000]);
hold on;
patch('faces',atlas_left.faces,'Vertices',atlas_left.vertices,'facevertexcdata',atlas_left.vcolor,'edgecolor','none','facecolor','flat');
patch('faces',atlas_right.faces,'Vertices',atlas_right.vertices,'facevertexcdata',atlas_right.vcolor,'edgecolor','none','facecolor','flat');
%light("Position",[-100 50 300]);
%light("Position",[-100 50 450]);
%light("Position",[200 50 450]);
axis tight;axis equal;view(0,90);material dull;axis off;axis vis3d;camlight;
saveas(h,[atlas_name,'.png']);
close all;
end
%
%
%
%
% a=tic;
% svreg_multiparc(subbasename,uscbrain_multi_atlas,BrainSuitePath,'USCBrain_BT');
% toc(a)