Videos, animations and exporting to html
A key goal for
brainrenderwas to facilitate the dissemination of neuroanatomical data. To do so, creating spectacular renderings is not enough, you need to have a way to export them into a format that you can easily share. For this reason we've put a lot of effort into allowing you to do just that by creating screenshots, animated videos and interactive online visualizations with your renderings.
Sceneclass has a
screenshotmethod that allows you to save a
.pngimage showing the current view of the rendering. By default the screenshots are saved in the current directory, but a you can use
screenshots_folderto pass a path to the folder where you want them to be saved when you're creating an instance of Scene.
You can take a screenshot while viewing and interacting with a rendered scene by pressing the
skey in your keyboard. Using
Scene.screenshothowever gives you the freedom to specify a name for the image file to be saved.
brainrenderis setup to ignore the background when saving the screenshots. That means that you will have all of your rendered objects in your image, but the background will be transparent. If you want to include the background in your image, include these two lines before creating the screenshot:
brainrender.SCREENSHOT_TRANSPARENT_BACKGROUND = False
You can also quickly take a screenshot by pressing the "s" key on your keyboard while interacting with the scene!
The beauty of creating 3d renderings is that you can look at your data from multiple points of view. A 2d picture can't convey the same information, but a video showing the brain moving across frames may.
For this reason
brainrendersupports the creating videos where at each frame it shows the current view of the scene and in-between frames it lets you move the scene around.
The easiest way to create a video is with the
VideoMakerclass. This takes a populate
sceneas argument and allows you to create a video by specifying how the camera should move at each frame in the video. The basic
VideoMakerclass only allows for rotations in the three principal directions, however you can use a custom function to specify what should happen at each frame.
If you need to make more sophisticated animation (e.g. with actors being added, removed or edited in the video), you might prefer to use the
Animationclass. This allows you to specify the video's content by defining a few keyframes. At each keyframe you can specify a few parameters (e.g. camera position) and a function to be called when that point of the video is reached: you can then have your function perform the actions that you need (e.g. add a new actor). The video is then created by interpolating the parameter across keyframes and calling the specified functions when necessary.
Videos are an improvement over screenshots in that they let the viewer see the scene from multiple points of view. Ideally though you would need a way to let the viewer explore the scene at their own will, moving the camera around, zooming etc, the same way you do when you create your renderings. Well, fear not!
brainrendernow lets you export your scene to an
.htmlfile which you can send to your colleagues (so that they can open it in their web browser) or embed in a website.
Warning: for large and complex scenes the resulting html file might be fairly large (>100MB) and loading the interactive scene in your web browser might take a few minutes.
htmlis very easy, all you need to do is create a
Scene, add elements to it and once you're happy with it use the
Sceneto create the
The web export functionality requires
k3d==2.7.4and won't work with other versions of this package
Not all of
brainrender'sfeatures can be included into your web export (because of limitations with the
k3dpackage. For instance the appearance of your exported scene might be different from the one you saw in