Skip to content

Commit

Permalink
Fix slicer pre-transforming the planes' center
Browse files Browse the repository at this point in the history
* this created problems when adding a plane mesh into a scene
* additionally it adds the parameter 'both' to plan.show()
  • Loading branch information
Carlo Castoldi committed Jan 19, 2025
1 parent e15d820 commit e5a2a22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 9 additions & 5 deletions brainglobe_heatmap/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
print_plane("Plane 0", self.slicer.plane0, blue_dark)
print_plane("Plane 1", self.slicer.plane1, pink_dark)

def show(self):
def show(self, both=True):

Check warning on line 78 in brainglobe_heatmap/planner.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_heatmap/planner.py#L78

Added line #L78 was not covered by tests
"""
Renders the hetamap visualization as a 3D scene in brainrender.
"""
Expand All @@ -88,15 +88,19 @@ def show(self):

# add slicing planes and their norms
for plane, color, alpha in zip(
(self.slicer.plane0, self.slicer.plane1),
(
(self.slicer.plane0, self.slicer.plane1)
if both
else (self.slicer.plane0,)
),
(blue_dark, pink_dark),
(0.8, 0.3),
strict=False,
):
plane_mesh = plane.to_mesh(self.scene.root)
plane_mesh.alpha(alpha).color(color)

self.scene.add(plane_mesh, transform=False)
self.scene.add(plane_mesh)

Check warning on line 103 in brainglobe_heatmap/planner.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_heatmap/planner.py#L103

Added line #L103 was not covered by tests
for vector, v_color in zip(
(plane.normal, plane.u, plane.v),
(color, red_dark, green_dark),
Expand All @@ -109,12 +113,12 @@ def show(self):
+ np.array(vector) * self.arrow_scale,
c=v_color,
),
transform=False,
classes="plane_mesh",
)

self.scene.add(
Sphere(plane_mesh.center, r=plane_mesh.width / 125, c="k"),
transform=False,
classes="plane_mesh",
)

self.scene.render(interactive=self.interactive, zoom=self.zoom)
Expand Down
1 change: 0 additions & 1 deletion brainglobe_heatmap/slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def __init__(
)

position = np.array(position)
position[2] = -position[2]

if isinstance(orientation, str):
axidx = get_ax_idx(orientation)
Expand Down

0 comments on commit e5a2a22

Please sign in to comment.