Skip to content

Commit

Permalink
Added check for symmetrical atlas
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorTatarnikov committed Aug 15, 2024
1 parent 1537b8e commit 89ffcaf
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions brainrender/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,17 @@ def add_brain_region(
actors = self.add(*regions)

# slice to keep only one hemisphere
if hemisphere == "right":
mesh_center = self.root._mesh.bounds().reshape((3, 2)).mean(axis=1)
plane = self.atlas.get_plane(pos=mesh_center, norm=(0, 0, 1))
elif hemisphere == "left":
mesh_center = self.root._mesh.bounds().reshape((3, 2)).mean(axis=1)
plane = self.atlas.get_plane(pos=mesh_center, norm=(0, 0, -1))

if hemisphere in ("left", "right"):
if self.atlas.metadata["symmetric"]:
mesh_center = (
self.root._mesh.bounds().reshape((3, 2)).mean(axis=1)
)
else:
mesh_center = self.root._mesh.center_of_mass()

Check warning on line 296 in brainrender/scene.py

View check run for this annotation

Codecov / codecov/patch

brainrender/scene.py#L296

Added line #L296 was not covered by tests

normal = (0, 0, 1) if hemisphere == "right" else (0, 0, -1)
plane = self.atlas.get_plane(pos=mesh_center, norm=normal)

if not isinstance(actors, list):
actors._mesh.cut_with_plane(
origin=plane.center,
Expand Down

0 comments on commit 89ffcaf

Please sign in to comment.