Skip to content

Commit

Permalink
adjustment in placing after yz swapped (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilobenozzo committed Nov 25, 2023
1 parent ff6ecbf commit 802f360
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions bsb/placement/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def place(self, chunk, indicators):
cell_type = indicator.cell_type
radius = indicator.get_radius()
for prt in self.partitions:
width, height, depth = prt.data.mdc - prt.data.ldc
width, depth, height = prt.data.mdc - prt.data.ldc
ldc = prt.data.ldc
# Extension of a single array in the X dimension
spacing_x = self.spacing_x
Expand All @@ -48,34 +48,34 @@ def place(self, chunk, indicators):
# The rounded amount of cells that will be placed
cells_placed = cells_per_row * n_arrays
# Calculate the position of the cells along the z-axis.
z_pos, z_axis_distance = np.linspace(
y_pos, y_axis_distance = np.linspace(
start=0.0,
stop=depth - radius,
num=cells_per_row,
retstep=True,
endpoint=False,
)
# Center the cell soma center to the middle of the unit cell
z_pos += radius + z_axis_distance / 2
y_pos += radius + y_axis_distance / 2
# The length of the X axis rounded up to a multiple of the unit cell size.
lattice_x = n_arrays * spacing_x
# The length of the X axis where cells can be placed in.
bounded_x = lattice_x - radius * 2
# Epsilon: open space in the unit cell along the z-axis
ϵ = z_axis_distance - radius * 2
epsilon = y_axis_distance - radius * 2
# Storage array for the cells
cells = np.empty((cells_placed, 3))
for i in range(z_pos.shape[0]):
for i in range(y_pos.shape[0]):
# Shift the arrays at an angle
angleShift = z_pos[i] * math.tan(self.angle)
angleShift = y_pos[i] * math.tan(self.angle)
# Apply shift and offset
x = x_pos + angleShift
# Place the cells in a bounded lattice with a little modulus magic
x = ldc[0] + x % bounded_x + radius
# Place the cells in their y-position with jitter
y = ldc[1] + y_pos[i] + epsilon * (np.random.rand(x.shape[0]) - 0.5)
# Place them at a uniformly random height throughout the partition.
y = ldc[1] + np.random.uniform(radius, height - radius, x.shape[0])
# Place the cells in their z-position with jitter
z = ldc[2] + z_pos[i] + ϵ * (np.random.rand(x.shape[0]) - 0.5)
z = ldc[2] + np.random.uniform(radius, height - radius, x.shape[0])
# Store this stack's cells
cells[(i * len(x)) : ((i + 1) * len(x)), 0] = x
cells[(i * len(x)) : ((i + 1) * len(x)), 1] = y
Expand Down
2 changes: 1 addition & 1 deletion bsb/topology/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def ldc(self):
def surface(self, chunk=None):
if chunk is not None:
# Gets the xz "square" from a volume
sq = lambda v: np.array(v)[[0, 2]]
sq = lambda v: np.array(v)[[0, 1]]
ldc = sq(self.ldc)
mdc = sq(self.mdc)
cl = sq(chunk.ldc)
Expand Down

0 comments on commit 802f360

Please sign in to comment.