V1 -> V2
Brainrender version 2.0 was recently released. This includes a major overhaul of most of
brainrender's code and the introduction of a few new features. If you have been using version 1 of
brainrender, we strongly recommend upgrading to the new one with:
pip install brainrender -U
However going from v1 to v2 means that some changes will be needed to make your
Actorclass is introduced, everything rendered in
brainrenderis first converted into an instance of
Actor. Different types of
Actorclass have been created to render different types of data:
brainrender.actors.Neuronis used to render neurons morphology (e.g. downloaded with
brainrender.actors.Pointsis used to render anything that can be represented as a set of points (e.g. labelled cells from
brainrender.actors.Streamlinesis used to render streamlines tractography data
brainrender.actors.Volumerenders volumetric data (e.g. gene expression)
- Other actor classes like
Rulercan be used to render other types of data.
The introduction of these new classes implies that the workflow for rendering data in
brainrenderhas changed a little bit. While before you would use methods like
Scene.add_cellsto render labelled cells, now you have to create a
Pointsactor and add that to the scene with
Scene.add. The same goes for all other types of visualizations supported by dedicated
Actorclasses. More details can be found in the examples at the Github repository.
If the data you want to render does not have a dedicated
Actorclass, you can create a
Meshobject from your data, as you would've done in v1, and use that to create a generic
As state above, most of
Scene's method for adding actors to your rendering have been removed. A generic
Scene.addcan be used to add any
Meshobject to the scene, while
Scene.add_brain_regionscan be used specifically to add brain region meshes. Also methods to add a silhouette or a label to individual actors are supported.
Scenegot a few new methods as well:
removecan be used to remove an
Actorfrom the rendering,
get_actorscan be used to get a handle on the actors in the scene. The
slicemethod also replaced
VideoMakerclass changed slightly. Your interaction with it will be largely unchanged, however its inner workings are now different: it uses
opencvto create and compress videos. This means that you don't need
) however you do need to make sure that
ffmpegis installed and working correctly.
A brand new
Animationclass has been introduced which facilitates the creation of videos with more advanced animations, more about it in the docs and examples.
The GUI, previously developed as part of a separate python package has not been fully integrated in brainrender.
Much of the remainder of
brainrender's functionality persists unchanged. Some method names might have changed however, but you should find all the info you need in the examples at the Github repository. Two more things worth noticing are:
- The name of the camera parameters used to specify the position of custom cameras have changed
- Some of the parameters in
brainrender.settingshave changed or have been removed.