Skip to main content

Visualisation and exploration of brain atlases and other anatomical data

Project description

brainrender

A user-friendly python library to create high-quality, 3D neuro-anatomical renderings combining data from publicly available brain atlases with user-generated experimental data.

Python Version PyPI tests codecov Downloads

   

Example gallery

From: Claudi et al. (2021) Visualizing anatomically registered data with brainrender. eLife

Documentation

brainrender is a project of the BrainGlobe Initiative, which is a collaborative effort to develop a suite of Python-based software tools for computational neuroanatomy. A comprehensive online documentation for brainrender can be found on the BrainGlobe website here.

Furthermore, an open-access journal article describing BrainRender has been published in eLife, available here.

Installation

From PyPI:

pip install brainrender

Quickstart

import random

import numpy as np

from brainrender import Scene
from brainrender.actors import Points

def get_n_random_points_in_region(region, N):
    """
    Gets N random points inside (or on the surface) of a mesh
    """

    region_bounds = region.mesh.bounds()
    X = np.random.randint(region_bounds[0], region_bounds[1], size=10000)
    Y = np.random.randint(region_bounds[2], region_bounds[3], size=10000)
    Z = np.random.randint(region_bounds[4], region_bounds[5], size=10000)
    pts = [[x, y, z] for x, y, z in zip(X, Y, Z)]

    ipts = region.mesh.inside_points(pts).coordinates
    return np.vstack(random.choices(ipts, k=N))


# Display the Allen Brain mouse atlas.
scene = Scene(atlas_name="allen_mouse_25um", title="Cells in primary visual cortex")

# Display a brain region
primary_visual = scene.add_brain_region("VISp", alpha=0.2)

# Get a numpy array with (fake) coordinates of some labelled cells
coordinates = get_n_random_points_in_region(primary_visual, 2000)

# Create a Points actor
cells = Points(coordinates)

# Add to scene
scene.add(cells)

# Add label to the brain region
scene.add_label(primary_visual, "Primary visual cortex")

# Display the figure.
scene.render()

Seeking help or contributing

We are always happy to help users of our tools, and welcome any contributions. If you would like to get in contact with us for any reason, please see the contact page of our website.

Citing brainrender

If you use brainrender in your scientific work, please cite:

Claudi, F., Tyson, A. L., Petrucco, L., Margrie, T.W., Portugues, R.,  Branco, T. (2021) "Visualizing anatomically registered data with Brainrender&quot; <i>eLife</i> 2021;10:e65751 [doi.org/10.7554/eLife.65751](https://doi.org/10.7554/eLife.65751)

BibTeX:

@article{Claudi2021,
author = {Claudi, Federico and Tyson, Adam L. and Petrucco, Luigi and Margrie, Troy W. and Portugues, Ruben and Branco, Tiago},
doi = {10.7554/eLife.65751},
issn = {2050084X},
journal = {eLife},
pages = {1--16},
pmid = {33739286},
title = {{Visualizing anatomically registered data with brainrender}},
volume = {10},
year = {2021}
}

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brainrender-2.1.15.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

brainrender-2.1.15-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

Details for the file brainrender-2.1.15.tar.gz.

File metadata

  • Download URL: brainrender-2.1.15.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.7

File hashes

Hashes for brainrender-2.1.15.tar.gz
Algorithm Hash digest
SHA256 d7e4e56279dd298f6cc2cc60198c452a8dc5eb3dd6601b662f2e50f12550ecef
MD5 16a6e97a2b31d772825982421be9e1e5
BLAKE2b-256 17ea3a0cfeb64f9e7aac84bd8637b0cb45a2fae3b206180f23f8656d5f45e5a8

See more details on using hashes here.

File details

Details for the file brainrender-2.1.15-py3-none-any.whl.

File metadata

  • Download URL: brainrender-2.1.15-py3-none-any.whl
  • Upload date:
  • Size: 43.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.7

File hashes

Hashes for brainrender-2.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 c73ad4513eb345c06d232daafb1595ac8dc467d705e1b64a0b3081ba515575a6
MD5 fe1157253359b53b9b2461dc3fb9a96b
BLAKE2b-256 692b0511241f73c640d6f12ec227524d6896f216b66f17de5b5f395e7bb9b0ed

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page