Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hemisphere slicing #375

Merged
merged 2 commits into from
Aug 16, 2024
Merged
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
19 changes: 10 additions & 9 deletions brainrender/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,17 @@
actors = self.add(*regions)

# slice to keep only one hemisphere
if hemisphere == "right":
plane = self.atlas.get_plane(
pos=self.root._mesh.center_of_mass(), norm=(0, 0, 1)
)
elif hemisphere == "left":
plane = self.atlas.get_plane(
pos=self.root._mesh.center_of_mass(), 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
Loading