-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added working callback example for slicing through the brain
- Loading branch information
1 parent
9cd07c8
commit 41f76ba
Showing
2 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from brainrender import Animation, Scene, settings | ||
from pathlib import Path | ||
|
||
settings.SHOW_AXES = False | ||
|
||
scene = Scene(atlas_name="allen_mouse_25um") | ||
|
||
regions = ( | ||
"CTX", | ||
"HPF", | ||
"STR", | ||
"CB", | ||
"MB", | ||
"TH", | ||
"HY", | ||
) | ||
scene.add_brain_region(*regions, silhouette=True) | ||
|
||
|
||
def slc(scene, framen, totframes): | ||
# Get new slicing plane | ||
fact = framen / totframes | ||
shape = list(scene.atlas.shape_um) | ||
# Multiply by fact to move the plane, add buffer to go past the brain | ||
point = [(shape[0] + 500) * fact, shape[1] // 2, shape[2] // 2] | ||
plane = scene.atlas.get_plane(pos=point, norm=(1, 0, 0)) | ||
|
||
scene.slice(plane) | ||
|
||
|
||
anim = Animation( | ||
scene, Path.cwd(), "brainrender_animation_callback", size=None | ||
) | ||
|
||
# Specify camera pos and zoom at some key frames` | ||
anim.add_keyframe(0, camera="frontal", zoom=1, callback=slc) | ||
|
||
# Make videos | ||
anim.make_video(duration=5, fps=10, fix_camera=True) |