-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_flow_paths.m
132 lines (101 loc) · 2.95 KB
/
plot_flow_paths.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
close all
clc
%close(vidObj)
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 = 0.5;
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), hold on
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
load('ideal_cap_bed_3x3_flow_paths.mat')
[num_paths length_paths] = size(flow_paths_by_seg);
%flow_paths_by_seg = zeros(num_paths, length_paths-1);
% for p = 1:num_paths
% path = flow_paths_by_nodes(p,:);
% path = path + 1;
%
% for v = 1:length(path)-1
% n0 = path(v);
% n1 = path(v+1);
%
% node0 = nodes(n0,:);
% node1 = nodes(n1,:);
%
% %plot([node0(1) node1(1)], [node0(2) node1(2)])
%
% for v2 = 1:num_vess
% if (vess_conn(v2,1) == n0) && (vess_conn(v2,2) == n1)
% flow_paths_by_seg(p,v) = v2;
% end
% end
% end
% end
%
% for p = 1:num_paths
% path = flow_paths_by_seg(p,:);
%
% for v = 1:length(path)
% seg = path(v);
% n0 = vess_conn(seg,1);
% n1 = vess_conn(seg,2);
%
% node0 = nodes(n0,:);
% node1 = nodes(n1,:);
%
% plot([node0(1) node1(1)], [node0(2) node1(2)], 'b')
% end
% end
perfused_paths_over_time = [];
path_flow_over_time = [];
for t = 1:num_timesteps
perfused_paths = ones(num_paths,1);
path_flow = zeros(num_paths,1);
for p = 1:num_paths
path = flow_paths_by_seg(p,:);
for s = 1:length(path)
seg = path(s);
path_flow(p,1) = path_flow(p,1) + abs(vess_flow(seg,t));
if (abs(vess_flow(seg,t)) < 1e-6) && (perfused_paths(p,1) == 1)
perfused_paths(p,1) = 0;
end
end
end
perfused_paths_over_time = [perfused_paths_over_time perfused_paths];
path_flow_over_time = [path_flow_over_time path_flow/sum(path_flow)];
perfusion_loss_over_time(t) = 1 - sum(perfused_paths)/num_paths;
end
perfusion_loss_over_time
%perfusion_loss_over_runs = [perfusion_loss_over_runs; perfusion_loss_over_time];