-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_ideal_sprout_front.m
177 lines (128 loc) · 8.54 KB
/
generate_ideal_sprout_front.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
function [] = generate_ideal_sprout_front(num_hc_long, num_hc_high, Ncell_art, Ncell_vein, Ncell_cap)
close all
% num_hc_long = 5;
% num_hc_high = 10;
%
% d_cap = 8;
% d_art = 16;
% d_vein = 32;
%
% Ncell_cap = round(pi*d_cap/5)
% Ncell_art = round(pi*d_art/5)
% Ncell_vein = round(pi*d_vein/5)
num_hc_long = double(num_hc_long)
num_hc_high = double(num_hc_high)
a = 20;
b = a/sqrt(2);
Lhc = (1 + sqrt(2))*a;
hc_v1 = [sind(45) cosd(45)];
hc_v2 = [sind(45) -cosd(45)];
hc_v3 = [1 0];
hc_v4 = [1 0];
hc_v5 = [cosd(45) -sind(45)];
hc_v6 = [cosd(45) sind(45)];
Lseg = 10;
Nseg_a_hc = a/Lseg;
vess_seg = [];
for j = 1:num_hc_long
origin = [];
if (mod(j,2) ~= 0)
for i = 1:2:2*num_hc_high
if (j == 1)
next_origin = [a/2 i*b];
else
next_origin = [floor(j/2)*(Lhc+a)+(a/2) i*b];
end
origin = [origin; next_origin];
end
[len wid] = size(origin);
for i = 1:len
if (j == 1)
vess_seg = [vess_seg; 0 a/2 origin(i,2) origin(i,2) Ncell_cap];
%plot([0 a/2], [origin(i,2) origin(i,2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
end
vess_seg = [vess_seg; origin(i,1) origin(i,1)+a*hc_v1(1) origin(i,2) origin(i,2)+a*hc_v1(2) Ncell_cap];
%plot([origin(i,1) origin(i,1)+a*hc_v1(1)], [origin(i,2) origin(i,2)+a*hc_v1(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1) origin(i,1)+a*hc_v2(1) origin(i,2) origin(i,2)+a*hc_v2(2) Ncell_cap];
%plot([origin(i,1) origin(i,1)+a*hc_v2(1)], [origin(i,2) origin(i,2)+a*hc_v2(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1)+a*hc_v1(1) origin(i,1)+a*hc_v1(1)+a*hc_v3(1) origin(i,2)+a*hc_v1(2) origin(i,2)+a*hc_v1(2)+a*hc_v3(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v1(1) origin(i,1)+a*hc_v1(1)+a*hc_v3(1)], [origin(i,2)+a*hc_v1(2) origin(i,2)+a*hc_v1(2)+a*hc_v3(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1)+a*hc_v2(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1) origin(i,2)+a*hc_v2(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v2(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)], [origin(i,2)+a*hc_v2(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1)+a*hc_v1(1)+a*hc_v3(1) origin(i,1)+a*hc_v1(1)+a*hc_v3(1)+a*hc_v5(1) origin(i,2)+a*hc_v1(2)+a*hc_v3(2) origin(i,2)+a*hc_v1(2)+a*hc_v3(2)+a*hc_v5(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v1(1)+a*hc_v3(1) origin(i,1)+a*hc_v1(1)+a*hc_v3(1)+a*hc_v5(1)], [origin(i,2)+a*hc_v1(2)+a*hc_v3(2) origin(i,2)+a*hc_v1(2)+a*hc_v3(2)+a*hc_v5(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1)+a*hc_v2(1)+a*hc_v4(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1) origin(i,2)+a*hc_v2(2)+a*hc_v4(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v2(1)+a*hc_v4(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1)], [origin(i,2)+a*hc_v2(2)+a*hc_v4(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
if (j == num_hc_long)
vess_seg = [vess_seg; origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1)+(a/2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1)+(a/2)], [origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
end
end
else
for i = 1:num_hc_high-1
next_origin = [(Lhc-b)+((j/2)-1)*(a+Lhc)+(a/2) 2*i*b];
origin = [origin; next_origin];
end
[len wid] = size(origin);
for i = 1:len
vess_seg = [vess_seg; origin(i,1) origin(i,1)+a*hc_v1(1) origin(i,2) origin(i,2)+a*hc_v1(2) Ncell_cap];
%plot([origin(i,1) origin(i,1)+a*hc_v1(1)], [origin(i,2) origin(i,2)+a*hc_v1(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1) origin(i,1)+a*hc_v2(1) origin(i,2) origin(i,2)+a*hc_v2(2) Ncell_cap];
%plot([origin(i,1) origin(i,1)+a*hc_v2(1)], [origin(i,2) origin(i,2)+a*hc_v2(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1)+a*hc_v1(1) origin(i,1)+a*hc_v1(1)+a*hc_v3(1) origin(i,2)+a*hc_v1(2) origin(i,2)+a*hc_v1(2)+a*hc_v3(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v1(1) origin(i,1)+a*hc_v1(1)+a*hc_v3(1)], [origin(i,2)+a*hc_v1(2) origin(i,2)+a*hc_v1(2)+a*hc_v3(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1)+a*hc_v2(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1) origin(i,2)+a*hc_v2(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v2(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)], [origin(i,2)+a*hc_v2(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1)+a*hc_v1(1)+a*hc_v3(1) origin(i,1)+a*hc_v1(1)+a*hc_v3(1)+a*hc_v5(1) origin(i,2)+a*hc_v1(2)+a*hc_v3(2) origin(i,2)+a*hc_v1(2)+a*hc_v3(2)+a*hc_v5(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v1(1)+a*hc_v3(1) origin(i,1)+a*hc_v1(1)+a*hc_v3(1)+a*hc_v5(1)], [origin(i,2)+a*hc_v1(2)+a*hc_v3(2) origin(i,2)+a*hc_v1(2)+a*hc_v3(2)+a*hc_v5(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
vess_seg = [vess_seg; origin(i,1)+a*hc_v2(1)+a*hc_v4(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1) origin(i,2)+a*hc_v2(2)+a*hc_v4(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v2(1)+a*hc_v4(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1)], [origin(i,2)+a*hc_v2(2)+a*hc_v4(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
if (j == num_hc_long)
vess_seg = [vess_seg; origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1)+(a/2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2) Ncell_cap];
%plot([origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1) origin(i,1)+a*hc_v2(1)+a*hc_v4(1)+a*hc_v6(1)+(a/2)], [origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2) origin(i,2)+a*hc_v2(2)+a*hc_v4(2)+a*hc_v6(2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_cap/2)
end
end
end
if (j == 1)
y_max = 2*num_hc_high*b;
origin(:,1) = zeros(len,1);
artery = [0 0; origin];
artery_seg = [];
for i = 1:length(artery)-1
artery_seg = [artery_seg; artery(i,1) artery(i+1,1) artery(i,2) artery(i+1,2) Ncell_art];
%plot([artery(i,1) artery(i+1,1)], [artery(i,2) artery(i+1,2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_art/2)
end
end
vess_seg = [artery_seg; vess_seg];
if (j == num_hc_long)
x_max = floor(num_hc_long/2)*(Lhc+a)+(a/2);
if (mod(num_hc_long,2) ~= 0)
x_max = x_max + Lhc + (a/2);
else
x_max = x_max + b + (a/2);
end
origin(:,1) = x_max*ones(len,1);
%vein = [x_max y_max; flipud(origin); x_max 0];
vein = [x_max 0; origin];
for i = 1:length(vein)-1
vess_seg = [vess_seg; vein(i,1) vein(i+1,1) vein(i,2) vein(i+1,2) Ncell_vein];
%plot([vein(i,1) vein(i+1,1)], [vein(i,2) vein(i+1,2)], 'r.-', 'MarkerSize', 8, 'LineWidth', d_vein/2)
end
end
end
vess_diam = zeros(length(vess_seg), 1);
for i = 1:length(vess_seg)
vess_diam(i,1) = vess_seg(i,5)*5/pi;
end
%
% % Plotting
% figure(1), hold on
%
% for i = 1:length(vess_seg)
% plot([vess_seg(i,1) vess_seg(i,2)], [vess_seg(i,3) vess_seg(i,4)], 'r.-', 'LineWidth', vess_diam(i,1)/2)
% end
%
% axis([-0.1*x_max 1.1*x_max -0.1*y_max 1.1*y_max])
% grid on
vess_seg = [vess_seg(:,1) vess_seg(:,3) vess_seg(:,2) vess_seg(:,4) vess_seg(:,5)];
save('ideal_sprout_front.mat', 'vess_seg')