Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

quickbrain

Fast, good-looking brain plots for Python

Source:
quickstart
<Figure size 1200x1000 with 4 Axes>

The quickbrain Python package provides a compact Python API for creating beautiful brain images quickly and easily.

When to use quickbrain

When to not use quickbrain

PRO:

  • simple

  • fast, viable for large composite images, e.g. for quick overview of whole-brain activation patterns

  • includes the cerebellum

  • overlays a contour to aid in interpretation

  • inflated meshes for better visualization of the insula and other deep sulcal structures

  • looks good!

CONTRA:

  • simple

  • as all visualizations that are based on meshes, it is suboptimal if you want fine-grained localization

  • only lateral and medial views

  • no nearest neighbor interpolation

Install

pip install "quickbrain @ git+https://github.com/pni-lab/quickbrain.git"

Dependencies

quickbrain keeps its runtime dependencies intentionally small:

The documentation site is built with MyST Markdown in GitHub Actions; MyST is installed there with npm and is not a Python package dependency of quickbrain.

Example

import nibabel as nib
from quickbrain import plot_brain
image = nib.load("path/to/your/image.nii.gz")
plot_brain(image)
Source:
quickstart
<Figure size 434x271 with 1 Axes>

More examples

Open quickstart for a notebook walkthrough, then see quick API Documentation for the API generated from package docstrings.

Under the hood

The quickbrain package is built on top of the nilearn package, which provides a comprehensive set of tools for neuroimaging data analysis. The trick is that we don’t need a high-resolution surface if we only want an overview of the whole-brain pattern, instead of detailed localization. Thus, the quickbrain package uses a custom-built low-resolution mesh (including the cerebellum!) and the nilearn.surface.vol_to_surf and the nilearn.surface.plot_surf_stat_map functions to project the statistical map onto the brain surface and plot the brain surface. This makes it lightning fast. But, low resolution means less details. So we put back the details by adding beautiful contour overlays, to guide the eye across sulci and gyri.

Developers, contributors and contact

Tamas Spisak

vibe-coded, cleaned, maintains
  • Center for Translational Neuro- and Behavioral Sciences (C-TNBS), University Medicine Essen, Germany

  • orcid: 0000-0002-2942-0821

  • email: tamas.spisak@uk-essen.de