Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@

# 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 @@
+ np.array(vector) * self.arrow_scale,
c=v_color,
),
transform=False,
classes=plane_mesh.br_class,
)

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

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]
Copy link
Member

@IgorTatarnikov IgorTatarnikov Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is required for sagittal slicing to work correctly. There are some underlying oddities in how brainrender handles the last spatial dimension (x in zyx representation). Without this line sagittal slices in 2D look like:

2d_heatmap_wrong_plane

This was generated by running the heatmap_2d.py example specifying the sagittal orientation. It should look something like:

2d_heamap_sagittal

I believe this is tied together with #72 and #55. I think getting rid of this line will require changes in brainrender.


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