Sceneclass is the focal point of any work using
brainrender. It's used to add actors to your visualization, to add brain regions meshes (by interacting with the
Atlasclass), to render your scene and use it to export images (using the
Renderclass). Finally, the creation of a
Sceneis the first step towards the generation of videos and animations as well!
Given its integration with BrainGlobe's atlasAPI,
brainrendercan be used with any atlas supported by the API. The moment when you're creating your
Sceneis when you have a chance to specify which atlas you intend to use by passing
atlas_name='atlas to use'to
add_brain_regionscan be used to add
actorsto your scene or generate new
actorsto represent brain regions, respectively. To fetch brain regions data,
brainrender.atlas.Atlasbehind the scenes. The atlas class has a few useful methods (e.g.
Atlas.hierarchycan be used to visualize a list of all brain regions in the atlas being used), these can be accessed using
get_actorscan be used to get a handle on actors that are already part of the
Scene. You can look for actors using either their name or br_class (e.g. streamlines, neurons...).
removecan be used to remove any actor from your scene.
- All actors that are currently in your scene can be found at
Scene.contentcan be used to print out an overview of the scene's content.
add_silhouetteboth take actors as inputs and can be used to add a label or a silhouette to your actors. The label is a piece of text that label's the actor's mesh in your scene, the silhouette is a black outline around your actor which can be used to make it stand out in your visualization.
sliceis a special method which can be used to 'cut' the scene's content with a plane (e.g. imagine a plane going along the mid line of the brain, this can be used to cut all meshes in half). Several parameters can be passed to
slicefor instance to only cut specific actors. When using
slice, you can specify which plane to use for the cutting by either passing one of the supported plane names (sagittal, frontal and horizontal) or by creating a custom plane. This can be done using
Scene.atlas.get_planeand specifying the position and normal of the plane.
All the code relative to the rendering of your scene is defined in
Renderdirectly, and as such you can access methods like
The central method is obviously
Scene.render, this creates a window and generates the 3D interactive rendering. When calling
renderyou can specify a camera position you wish to use.
Additional methods include
export(for exporting .html files with your rendered scene).