Abstract
Here we present brainrender, an open source python package for rendering three-dimensional neuroanatomical data aligned to the Allen Mouse Atlas. Brainrender can be used to explore, visualise and compare data from publicly available datasets (e.g. from the Mouse Light project from Janelia) as well as data generated within individual laboratories. Brainrender facilitates the exploration of neuroanatomical data with three-dimensional renderings, aiding the design and interpretation of experiments and the dissemination of anatomical findings. Additionally, brainrender can also be used to generate high-quality, publication-ready, figures for scientific publications.
Introduction
In recent years, the study of mouse neuroanatomy greatly benefited from the development of a high resolution three dimensional reference atlas from the Allen Institute (here-after referred to as the Allen atlas [1; 2]). This has enabled large scale projects aimed at mapping mesoscale connections across the entire murine brain (e.g. Allen’s Mouse Connectome project [3]) and reconstructing the three-dimensional morphology of over 1000 neurons (e.g. Janelia’s Mouse Light [4]). The Allen atlas is also used as a reference for registering anatomical data produced with high throughput techniques such as serial two-photon tomography [5; 6], which is a crucial step in the analysis of data generated with these techniques [7]. Visualisation of anatomical data registered to the Allen atlas often requires custom-made code, a time consuming effort that is technically not trivial. Here we present brainrender, an easy to use and open source python package for the visualisation of anatomical data registered to the Allen atlas.
As the use of the Allen atlas has become more widespread in the research community, software has been developed to visualise anatomical data. These include Brain Explorer [8] and Neuron Browser [9] which can be used to explore data from the Allen Institute projects and the Mouse Light project respectively. Using these software packages does not require any programming experience making them widely accessible. However, they cannot be used to visualise user-generated data alongside that from publicly available datasets. Furthermore, they offer little room for users to personalise the look of the rendered data, a key feature for any software that is to be used to generate figures for scientific articles.
In addition to the software discussed above, open source packages with similar functionalities have been developed in popular programming languages such as R and Matlab [10; 11; 12]. These can be used to either explore a publicly available dataset or visualise user-generated data, but not both at the same time. Furthermore, there are currently no such packages written in Python, a programming language that is being increasingly adopted by the neuroscience community [13].
For these reasons we developed brainrender. Development of brainrender was instructed by two design goals: first, to provide a single software package for the visualisation of both publicly available and user-generated neuroanatomical data. Second, to facilitate the creation of high quality renderings of neuroanatomical data to be used for figures in scientific publications. In addition, we made the software user-friendly by handling the API interactions (necessary to download data from public databases) and data rendering behind the scenes, needing minimal user input. This means that using brainrender requires little coding experience, facilitating its adoption by the research community. We believe that brainrender will be useful in guiding the design and interpretation of neuroanatomical studies as well as the dissemination of anatomical findings.
In this preprint, we begin by showing how brainrender can be used to visualise data from the Allen atlas, Mouse Connectome and Mouse Light projects and conclude with a demonstration of how it can be used to visualise the results of retrograde tracing experiments. Brainrender’s code is made available at its github repository (https://github.com/BrancoLab/BrainRender) alongside numerous examples and tutorials.
Public datasets
Brainrender supports interaction with the Allen atlas and two large publicly available datasets: the Mouse Connectome project from Allen [3] and the Mouse Light project from the Janelia Research Campus [4]. In this section we will show examples of how brainrender can be used to visualise the three dimensional organisation of brain structures, mesoscale connectomics (afferent and efferent projections from a target area) and neuronal morphological reconstructions.
Brain structures
To contextualise anatomical and morphological data, it is helpful to be able to visualise a subset of brain regions relevant to the data at hand. This can be done in brainrender by specifying which of the brain regions in the Allen atlas to visualise (see Fig 1a, b). Behind the scenes, brainrender uses the Allen’s API services to download and render the three dimensional anatomy of selected brain regions.
a) Subregions of the thalamus. Solid red: ventral posterior complex of the thalamus, wireframe red: thalamus. b) Cortical layers in the barrel field of the primary somatosensory cortex. c) Efferent anatomical projections from the periaqueductal gray visualised as streamlines. d) Afferent projections to the zona incerta visualised as tractography. Injection sites and tractography tracts are coloured according to the target region of the virus injection. e) Visualisation of a pyramidal neuron in the primary motor cortex. Data from MouseLight project (doi:10.25378/janelia.5527438). f) Rendering of morphological reconstructions of pyramidal neurons. Data from http://neuromorpho.org/ [14].
Mesoscale connectomics
Mesoscale connectivity data from the Mouse Connectome project can be visualised in two ways: 1) efferent projections can be rendered as streamlines (Fig 1c) and 2) afferent projections can be visualised as tractography data (Fig 1d).
As part of the Mouse Connectome project mice were injected with viruses expressing fluorescent markers. Fluorescence was then measured across the entire brain and the data were registered to the common coordinate framework of the Allen atlas before being made publicly available. The streamlines visualisation relies on the use of a fast marching algorithm on the fluorescence data to reconstruct efferent projections from the site of virus injection. The results of this analysis were shared by Neuroinformatics NL (https://neuroinformatics.nl/drupal). Brainrender can be used to automatically download and visualise efferent projections from a target brain region, as illustrated in Fig 1c for the periaqueductal gray.
To visualise afferent projections to a region of interests, brainrender selects the set of tracing experiments in the Mouse Connectome project that resulted in fluorescence signal in the selected region by using the Allen institute’s SDK and API services. Then, the location of virus injection of each selected experiment and the projections to the region of interest are rendered as displayed in Fig. 1d.
Neuronal morphology
The visualisation of afferent and efferent projections from a brain region can be combined to build a qualitative understanding of the input and output connectivity of the circuit being studied. A more precise understanding of the projections of individual neurons can be obtained by rendering morphological data for neurons located in (or projecting to) the region of interest. Brainrender can be used to easily download and visualise morphological reconstructions registered to the Allen atlas from the Mouse Light project, as illustrated in Fig. 1e.
Brainrender can also render morphological reconstructions from other sources (e.g. see Fig. 1f). Thus brainrender can be used to visualise the large body of open access neuron morphologies currently available (e.g. from the Allen Cell Types project or from the https://neuromorpho.org free database, [14]).
User generated data
Tracing experiments
To demonstrate how brainrender can be used to visualise the results of tracing experiments, we used unpublished data that are part of an ongoing project investigating the location of neurons projecting to the motor (deep) part of the superior colliculus (SCm). SCm projecting neurons were labelled with the tdTomato fluorescent marker by injecting a retrogradely transported viral particle expressing CRE and enhanced GFP (AAV2r-CRE-eGFP) in a Flex-tdTomato mouse line. Injection of the virus in the right SCm resulted in labelled neurons across several cortical and subcortical areas. In agreement with previous tracing studies, numerous labelled neurons were identified unilaterally in the secondary motor cortex (MOs) and zona incerta (ZI), ipsilaterally to the injection site. In the ventrolateral hypothalamus (VMH) labelled neurons were equally distributed across both hemispheres (see Fig 2d).
a), b), c) Visualisation of virus injection site (red) in the motor superior colliculus (fuchsia). a) Coronal view of the injection site. b) Top view of the injection site. c) Angled view of the injection site. d) Labelled cells in the secondary motor cortex, zona incerta and ventrolateral hypothalamus. e) Labelled cells in the isocortex. An animated visualisation of panel d can be found at: https://raw.githubusercontent.com/BrancoLab/BrainRender/master/Docs/Media/cells.gif
To extract the precise location of labelled neurons registered to the Allen atlas, the entire brain was imaged with a two-photon tomography setup [15]. We then used cellfinder, a novel tool for cell detection in whole-brain images, to extract the location of labelled cells [16]. Cellfinder relies on amap [7] for registering image data to the Allen atlas, yielding the coordinates of labelled cells in the common coordinate space which can easily be visualised in brainrender. The boundaries of the injection site were extracted from the imaging data using custom python code, which will be made available as part of the neuro python package (www.github.com/SainsburyWellcomeCentre/neuro). In brief, the whole brain imaging data was thresholded and binarised to identify the location of the injection site. Then, a marching cubes algorithm was utilised to extract the surface of the injection site, which was then converted to a mesh structure and rendered.
After extracting the coordinates of the injection site and labelled cells, data were rendered in brainrender alongside the relevant brain regions (Fig 2) Visualisation of the injection site (Fig 2a, b and c) demonstrated that the injection was not entirely confined to the SCm but also included part of the superficial superior colliculus. The location of all labelled neurons in MOs, ZI and VMH is shown in Fig 2d while Fig 2e while shows the position of neurons in across the entire isocortex.
Implanted devices
Brainrender can also be used to visualise the position of devices implanted in the brain, such as optic fibres and electrodes arrays implanted in the brain (e.g. see Fig 3). This can be used to confirm and visualise the correct placement of implanted devices as well as to create schematics of proposed experiments.
a) Example of how the position of an implanted electrodes array can be visualised. Electrodes (grey) are shown in position in the CA1 field of the hippocampus. b) Schematic illustration of two optic fibres (light blue) implanted over the central amygdala (salmon). The basolateral amygdala is shown in grey.
Thanks to the flexibility afforded by the rendering engine that brainrender relies upon (vtkplotter, [17]), custom devices can also be rendered. In fact, brainrender can be used to visualise any three dimensional object by loading mesh data from ‘.obj’ and ‘.stl’ files. This allows for the possibility of visualising custom designed devices alongside neuroanatomical data.
Discussion
In this preprint we presented brainrender, an open source python package for rendering three dimensional anatomical data aligned to the Allen atlas. Brainrender can be used to explore anatomical and connectomics data from projects carried out by the Allen Institute as well as neuronal morphological reconstructions from the Mouse Light project. Thus, brainrender can be used to rapidly obtain a qualitative understanding of the input/output connectivity of a brain region, guiding the design of further experiments.
Brainrender can also be used to visualise neuroanatomical data generated within individual laboratories, facilitating the interpretation and dissemination of anatomical findings. To further aid the dissemination of anatomical data, brainrender also provides a simple way to generate high quality renderings of anatomical data for scientific figures and illustrations.
Code availability
Brainrender is available as a stand alone python package on PyPI. Brainrender’s code is public and available on Github: https://github.com/BrancoLab/BrainRender. Contributions to brainrender are welcomed and encouraged. For bug reports, feature requests and code contributions, please open an issue at the Github repository or contact the authors directly.