Actor classes for many commonly-used data types: Actors. However, before you can use brainrender to visualize your data, you'll have to load and process them to put them into a format that brainrender accepts. These are the main steps you'll have to undertake to visualize your data.
You can find a lot of examples in brainrender's repository, some of these are focused on showing how to load and use your data in brainrender. Head there for more details.
In order to visualize your data in brainrender, it has to be in register with the axes system in brainrender. If you used tools like brainreg your data will already be registered and you can skip this step. If not, you will have to transform your data so that its axes match brainrender's. Brainglobe has BG-space, a software that aims at facilitating the operation of swapping axes around, which can get confusing rapidly otherwise.
Check Registering data for more details.
If you have cells coordinates (or the coordinates of any other set of points in the brain) saved in a file (e.g. as .csv), you can use many popular python packages for loading them as python arrays. These include pandas for
.h5 files, numpy for
Neuron morphologies are generally saved as
.swc files. Brainrender's
Neuron class can load morphology data directly from this file format, but head to morphapi for more details about to load and process neuron morphology data.
Given the popularity of python for scientific research, there are tools to load almost all data formats. These include numpy to load
.tiff etc. Brainglobe provides a general purpuse software tool for loading and saving image data: imio. You can use imio to load most types of data (e.g.
.nifti etc) :
from imio import loadload.load_any('mydata.tif')
from brainrender.actors import Volumeimport numpy as npvol = Volume(np.load('data.npy')) # this will workvol = Volume('data.npy') # this will work too :)
If your data is as volumetric (3D voxels) image, you might want to extract mesh information from your data. If that's the case,
vedo provides code to go from volumes to meshes:
from vedo import Volumefrom brainrender import Scenevol = Volume(mydata)mesh = vol.isosurface()scene = Scene()scene.add(mesh)
Vedo provides many more methods to go from volume to mesh and vice versa: check its awesome documentation for more details.
from brainrender.actors import Volumemesh = Volume('data.npy').isosurface()
You can also render your data directly as a brainrender
from brainrender import Scene, actorsscene = Scene()scene.add(actors.Volume(mydata))
Brainrender can create streamlines visualizations for connectomics data. Data for streamlines can be saved as
.json and loaded with pandas's
read_json function. Data should be organized in a hierarchical structure with two main entries (
lines) denoting the injection points and the coordinates of points along each "line" of the streamlines. Each line should be a list of dictionaries with "x", "y" and "z" coordinates.