-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtPole_experiments.m
133 lines (118 loc) · 2.92 KB
/
tPole_experiments.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
124
125
126
127
128
129
130
131
132
133
clear all; close all;
addpath(genpath('.'));
makeGif = true;
gifname = 'TPconformalMap.gif';
maxdist = 50;
load('FastDiskConformalMap/human_brain.mat');
% flip (easier to work with)
v = v(:,[2 1 3]);
% find temporal apex (heauristically - most anterior point below y=-15)
TL = find(v(:,3)<-15);
[m,i] = max(v(TL,1));
antPole = TL(i);
dist = perform_fast_marching_mesh(v,f,antPole);
if makeGif
fig = figure;
p1 = patch('faces',f,'vertices',v);
axis equal tight;
p1.FaceVertexCData = dist;
p1.FaceColor = 'flat';
p1.LineStyle = 'none';
title('Geodesic distance from temporal apex');
view(180,0);
material dull;
light;
drawnow;
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind,cm,gifname,'gif','DelayTime',2, 'Loopcount',inf);
xl = xlim;
yl = ylim;
zl = zlim;
end
% get only area around apex
rm = sort(find(dist>maxdist),'descend');
v2 = v; f2 = f;
for s = 1:length(rm)
r = rm(s);
v2(r,:) = [];
f2(any(f2==r,2),:) = [];
f2(f2>r) = f2(f2>r)-1;
end
dist(rm) = [];
mean_curv(rm) = [];
if makeGif
fig2 = figure;
p = patch('faces',f2,'vertices',v2);
axis equal tight;
drawnow;
xl2 = xlim;
yl2 = ylim;
zl2 = zlim;
close;
fig;
for n = 1:90
fraction = n/90;
p1.FaceAlpha = 1-fraction;
xlim(xl2*fraction + xl*(1-fraction));
ylim(yl2*fraction + yl*(1-fraction));
zlim(zl2*fraction + zl*(1-fraction));
view(90*fraction + 180*(1-fraction),0);
p2 = patch('faces',f2,'vertices',v2);
p2.FaceVertexCData = dist;
p2.FaceColor = 'flat';
p2.LineStyle = 'none';
material dull;
title('50mm distance from temporal apex');
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind,cm,gifname,'gif','DelayTime',1/30,'WriteMode','append');
end
imwrite(imind,cm,gifname,'gif','DelayTime',1,'WriteMode','append');
end
%% conformal map
% map to unfolded
map = disk_conformal_map(v2,f2);
map(:,3) = 0;
map = map(:,[3 2 1]);
map = map.*maxdist;
if makeGif
close all;
fig = figure;
p = patch('faces',f2,'vertices',v2);
p.FaceVertexCData = mean_curv;
p.FaceColor = 'flat';
p.LineStyle = 'none';
axis equal tight;
view(90,0);
light;
material dull;
drawnow;
title('Temporal pole mean curvature (for visualization)');
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind,cm,gifname,'gif','DelayTime',2,'WriteMode','append');
for n = 1:90
cla;
fraction = n/90;
vmid = map.*fraction + v2.*(1-fraction);
p = patch('faces',f2,'vertices',vmid);
p.FaceVertexCData = mean_curv;
p.FaceColor = 'flat';
p.LineStyle = 'none';
axis equal tight;
view(90,0);
light;
material dull;
title('Conformal mapping to disk (Choi et al., 2015)');
drawnow;
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind,cm,gifname,'gif','DelayTime',1/30,'WriteMode','append');
end
imwrite(imind,cm,gifname,'gif','DelayTime',2,'WriteMode','append');
end