-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_ABM_output_A_branch_3D_polarity.m
163 lines (115 loc) · 3.71 KB
/
plot_ABM_output_A_branch_3D_polarity.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
close all
clc
curr_dir = pwd;
save_directory = [pwd '\Simulation Data'];
cd(save_directory)
file_name = uigetfile;
load(file_name)
vidObj = VideoWriter([erase(file_name, '.mat') '_3D'],'MPEG-4');
vidObj.FrameRate = 20;
vidObj.Quality = 100;
open(vidObj);
plot_every = 1.0;
cd(curr_dir)
num_nodes = length(nodes);
[num_vess num_timesteps] = size(vess_diameter);
vess_conn = vess_conn + ones(num_vess, 2);
% convert to uL/hr
vess_flow = vess_flow/1e6;
% convert to Pa
nodal_pressures = nodal_pressures/12.96;
Ain = input.Ain;
Bin = input.Bin;
Lseg = 10;
cellspeed = 3;
t_time = Lseg/cellspeed;
time = linspace(0,num_timesteps,num_timesteps+1)*input.dt;
figure(1)
max_cell_num = 0;
for t = 1:num_timesteps
if (max(cells{t}(:,1)) > max_cell_num)
max_cell_num = max(cells{t}(:,1));
end
end
rand_cell_pos = 2*(rand([max_cell_num,1])-0.5);
xmax = max(nodes(:,1));
ymax = max(nodes(:,2));
if (xmax > ymax)
maxmax = xmax;
else
maxmax = ymax;
end
for t = 1:(plot_every/input.dt):num_timesteps
curr_cells = cells{t};
close (1)
figure(1), hold on,
%axis([-50 150 -50 150 -100 100])
axis([-0.1*maxmax 1.1*maxmax (ymax/2)-1.2*maxmax/2 (ymax/2)+1.2*maxmax/2 -1.2*maxmax/2 1.2*maxmax/2])
for v = 1:num_vess
x0 = nodes(vess_conn(v, 1), 1);
y0 = nodes(vess_conn(v, 1), 2);
x1 = nodes(vess_conn(v, 2), 1);
y1 = nodes(vess_conn(v, 2), 2);
Z = norm([x1 - x0; y1 - y0]);
R = vess_diameter(v,t)/2;
[CYY CZZ CXX] = cylinder(R);
CXX = Z*CXX;
r = [x1 - x0; y1 - y0];
x_vect = [1; 0];
alpha = find_angle2D(x_vect, r);
Q = [cos(alpha) -sin(alpha) 0; sin(alpha) cos(alpha) 0; 0 0 1];
for j = 1:length(CXX)
for i = 1:2
xpt = CXX(i,j);
ypt = CYY(i,j);
zpt = CZZ(i,j);
vect = [xpt; ypt; zpt];
vect_new = Q*vect;
CXX_new(i,j) = vect_new(1) + x0;
CYY_new(i,j) = vect_new(2) + y0;
CZZ_new(i,j) = vect_new(3);
end
end
CXX = CXX_new;
CYY = CYY_new;
CZZ = CZZ_new;
CYL = surf(CXX, CYY, CZZ); colormap(bone)
set(CYL,'EdgeColor','None')
set(CYL,'FaceAlpha', 0.25)
end
for c = 1:length(curr_cells)
id = curr_cells(c,1);
vid = curr_cells(c,2);
xi = curr_cells(c,3);
zeta = curr_cells(c,4);
pol = [curr_cells(c,6); curr_cells(c,7)];
x0 = nodes(vess_conn(vid, 1), 1);
y0 = nodes(vess_conn(vid, 1), 2);
x1 = nodes(vess_conn(vid, 2), 1);
y1 = nodes(vess_conn(vid, 2), 2);
Z = norm([x1 - x0; y1 - y0]);
R = vess_diameter(vid,t)/2;
r = [x1 - x0; y1 - y0];
x_vect = [1; 0];
alpha = find_angle2D(x_vect, r);
Q = [cos(alpha) -sin(alpha) 0; sin(alpha) cos(alpha) 0; 0 0 1];
z_pos = Z*xi;
c_pos = 2*pi*zeta*R;
alpha = find_angle2D(pol, r);
plot_ellipse_on_cylinder(Q, [x0; y0; 0], z_pos, c_pos, Z, R, Ain, Bin, alpha, 'r', true)
end
title([num2str(time(t)) ' hours '])
%view(-60, 30)
axis off
set(gca, 'FontSize', 24)
set(gca, 'LineWidth', 2)
set(figure(1), 'Color', 'w')
fig = gcf;
pos = fig.Position;
set(fig, 'Position', [10 10 1.5*500 1.5*500]);
% Write to the video file
currFrame = getframe(gcf);
writeVideo(vidObj,currFrame)
pause(0.01)
end
close(vidObj);