Skip to content

Commit e0650f6

Browse files
Update arterial tree generation
1 parent 08e295e commit e0650f6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

data/generate_arterial_tree.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy as np
33
import random
44
import copy
5+
from graphnics import *
56

67
"""
78
Creation of a tree-like network
@@ -116,28 +117,28 @@ def normal(x, y, z):
116117

117118
# direction-vector choose which vessel go to the right/left
118119

119-
if not direction:
120+
if not directions:
120121
sign1 = random.choice((-1, 1))
121122
else:
122-
sign1 = signs[0]
123-
del signs[0]
123+
sign1 = directions[0]
124+
del directions[0]
124125
sign2 = -1 * sign1
125126

126-
branch1 = [sign1, angle1, L1]
127-
branch2 = [sign2, angle2, L2]
127+
branch1 = [sign1, angle1, L1, D1]
128+
branch2 = [sign2, angle2, L2, D2]
128129

129130
parent_edge_v2 = e[1] # vertex we want to connect to
130131

131132
# Check that the new edge does not overlap other edges
132-
for sign, angle, L in [branch1, branch2]:
133+
for sign, angle, L, D in [branch1, branch2]:
133134
new_node_pos = compute_vessel_endpoint(
134135
previousvessel, normal(*previousvessel[1]), sign * angle, L
135136
)
136137

137138
all_pos = np.asarray(list(nx.get_node_attributes(G, "pos").values()))
138139
intersecting_lines = 0
139140
C = Point(all_pos[parent_edge_v2])
140-
D = Point(new_node_pos)
141+
DD = Point(new_node_pos)
141142

142143
non_neighbor_edges = copy.deepcopy(list(G.edges()))
143144

@@ -151,13 +152,13 @@ def normal(x, y, z):
151152
for v1, v2 in non_neighbor_edges:
152153
A = Point(all_pos[v1])
153154
B = Point(all_pos[v2])
154-
if doIntersect(A, B, C, D):
155+
if doIntersect(A, B, C, DD):
155156
intersecting_lines += 1
156157

157158

158159
#if no edges overlap with this new one
159160
# we go ahead and add it
160-
if intersecting_lines < 1:
161+
if True: #intersecting_lines < 1:
161162
new_node_ix += 1
162163

163164
new_edge = (e[1], new_node_ix)
@@ -167,7 +168,7 @@ def normal(x, y, z):
167168
G.nodes[new_node_ix]["pos"] = new_node_pos
168169

169170
# Set radius
170-
G.edges[new_edge]["radius"] = D1 / 2
171+
G.edges[new_edge]["radius"] = D / 2
171172

172173
# Add to the pool of vessels for this generation
173174
current_edges.append(new_edge)

0 commit comments

Comments
 (0)