Skip to content

Commit

Permalink
Mixed network and from-scatch morgphology network vis
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldeistler committed Dec 11, 2023
1 parent 0ee4b04 commit 8410d04
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions jaxley/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,25 +707,31 @@ def compute_xyz(self):
)

for b in range(self.total_nbranches):
if parents[b] > -1:
start_point = endpoints[parents[b]]
num_children_of_parent = num_children[parents[b]]
y_offset = (
((index_of_child[b] / (num_children_of_parent - 1))) - 0.5
) * y_offset_multiplier[levels[b]]
# For networks with mixed SWC and from-scatch neurons, only update those
# branches that do not have coordingates yet.
if np.any(np.isnan(self.xyzr[b])):
if parents[b] > -1:
start_point = endpoints[parents[b]]
num_children_of_parent = num_children[parents[b]]
y_offset = (
((index_of_child[b] / (num_children_of_parent - 1))) - 0.5
) * y_offset_multiplier[levels[b]]
else:
start_point = [0, 0]
y_offset = 0.0

len_of_path = np.sqrt(y_offset**2 + 1.0)

end_point = [
start_point[0] + branch_lens[b] / len_of_path * 1.0,
start_point[1] + branch_lens[b] / len_of_path * y_offset,
]
endpoints.append(end_point)

self.xyzr[b][:, :2] = np.asarray([start_point, end_point])
else:
start_point = [0, 0]
y_offset = 0.0

len_of_path = np.sqrt(y_offset**2 + 1.0)

end_point = [
start_point[0] + branch_lens[b] / len_of_path * 1.0,
start_point[1] + branch_lens[b] / len_of_path * y_offset,
]
endpoints.append(end_point)

self.xyzr[b][:, :2] = np.asarray([start_point, end_point])
# Dummy to keey the index `endpoints[parent[b]]` above working.
endpoints.append(np.zeros((2,)))

def move(self, x: float = 0.0, y: float = 0.0, z: float = 0.0):
"""Move cells or networks in the (x, y, z) plane."""
Expand Down

0 comments on commit 8410d04

Please sign in to comment.