-
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 an example to dynamically alter the scene in each frame (#376)
- Loading branch information
1 parent
242dad8
commit 11d0d76
Showing
2 changed files
with
63 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_um = scene.atlas.shape_um | ||
# Multiply by fact to move the plane, add buffer to go past the brain | ||
point = [(shape_um[0] + 500) * fact, shape_um[1] // 2, shape_um[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) |