Skip to main content

yabplot: yet another brain plot

logo

PyPI version Docs Tests DOI

yabplot is a Python library for creating publication-quality 3D brain visualizations. it provides a unified interface for cortical regions, subcortical structures, white matter bundles, connectomes, voxel-wise maps, and vertex-wise maps.

the idea is simple. while there are already amazing visualization tools available, they often focus on specific domains—using one tool for white matter tracts and another for cortical surfaces inevitably leads to inconsistent styles. i wanted a unified, simple-to-use tool that enables me (and hopefully others) to perform most brain visualizations in a single place. recognizing that neuroscience evolves daily, i designed yabplot to be modular: it supports standard pre-packaged atlases out of the box, but easily accepts any custom parcellation or tractography dataset you might need. moreover, it enables to plot volumetric data either voxel-wise or by projecting the data to cortical surface or white matter tracts.

features

  • unified plotting API: plot cortical regions, vertex-wise maps, subcortical structures, voxel-wise maps, white-matter tracts, and connectomes with a consistent interface.
  • pre-packaged resources: access commonly used atlases and meshes on demand, including schaefer, brainnetome, aparc, aseg, musus100, and xtract atlases.
  • flexible data mapping: pass data as arrays for strict ordering or dictionaries for partial/name-based mapping.
  • custom atlases: build and use custom cortical parcellations, subcortical segmentations, and tractography datasets.
  • volume projection: project nifti images to cortical surfaces or tractograms for vertex-wise and tractometry visualizations, or plot the volumes voxel-wise.
  • publication-oriented output: generate static figures, saved images, and interactive 3D views.

installation

uv add yabplot # to install
uv sync --upgrade-package yabplot # to update

or

pip install yabplot # to install
pip install yabplot --upgrade # to update

dependencies: python 3.11 with ipywidgets, nibabel, matplotlib, pandas, pooch, pyvista, scikit-image, trame, trame-vtk, trame-vuetify

(Connectome Workbench (wb_command) is a requirement to create custom cortical atlases unless you plan to only use pre-loaded atlases; see more in docs)

quick start

please refer to the documentation for more comprehensive guides.

import yabplot as yab
import numpy as np

# check that you have the latest version
print(yab.__version__)

# see available atlases and brain meshes
print(yab.get_available_resources())

# see the region names for a specific atlas
print(yab.get_atlas_regions(atlas='aseg', category='subcortical'))

# plotting cortical surface regions
atlas = 'aparc'
dmap1 = {'L_lateraloccipital': 0.265, 'L_postcentral': 0.086}
ax = yab.plot_cortical(data=dmap1, atlas=atlas, vminmax=[0.0, 0.3], cmap='viridis',
    bmesh='midthickness', views=['left_lateral', 'left_medial'])

# plotting subcortical regions
atlas = 'aseg'
regs = yab.get_atlas_regions(atlas=atlas, category='subcortical')
data = np.arange(1, len(regs)+1)
ax = yab.plot_subcortical(data=data, atlas=atlas, vminmax=[2, 14], 
    views=['left_lateral', 'superior', 'right_lateral'], 
    bmesh_alpha=0.1, cmap='plasma')

# plotting white matter tracts
atlas = 'xtract_medium'
regs = yab.get_atlas_regions(atlas=atlas, category='tracts')
data = {reg: np.sin(i) for i, reg in enumerate(regs)}
ax = yab.plot_tracts(data=data, atlas=atlas, style='matte', cmap='coolwarm',
    views=['left_lateral', 'anterior', 'superior'], bmesh='pial')

# plotting connectome
data = np.random.rand(400, 400)
ax = yab.plot_connectome(matrix=data, atlas='schaefer400',
    edge_cmap='dense', node_cmap='binary', edge_threshold='95%', 
    views=['left_lateral', 'superior', 'posterior']
)

# volume projection to cortical surface and vertexwise plotting
threshold = 4
b_lh_path, b_rh_path = yab.data.get_surface_paths('midthickness', 'bmesh')
lh_data, rh_data = yab.project_vol2surf('path/to/yourdata.nii.gz', bmesh='midthickness')
lh_data = np.where(lh_data > threshold, lh_data, np.nan)
rh_data = np.where(rh_data > threshold, rh_data, np.nan)
lh_mesh, rh_mesh = yab.load_vertexwise_mesh(b_lh_path, b_rh_path, lh_data, rh_data)
ax = yab.plot_vertexwise(lh_mesh, rh_mesh, cmap='viridis', vminmax=[-10, 10], 
                    views=['left_lateral', 'left_medial'])

# plotting volume voxel-wise 
threshold = '99.5%'
nii_path = 'path/to/yourdata.nii.gz'
ax = yab.plot_voxelwise(nii_path, threshold='99%', cmap='Reds',
    views=['left_lateral', 'superior', 'anterior'])

examples

acknowledgements

yabplot relies on the extensive work of the neuroimaging community. if you use these atlases in your work, please cite the original authors. if you use this package for any scientific work, please cite the DOI (see more info on Zenodo).

Metadata

Release files for yabplot 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yabplot 0.5.1
File Size Uploaded
yabplot-0.5.1.tar.gz 49.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yabplot 0.5.1
File Interpreter ABI Platform
yabplot-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 94.4 kB

Release files / yabplot-0.5.1.tar.gz

Download URL yabplot-0.5.1.tar.gz
Size 49.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3a0d1579448c51bd7772755a4c1fe88e99c3b14c8a7a6531d2137219b2f9db6a
BLAKE2b-256 checksum
How to use checksums
527f1336a576d8cd01c26a7f614737b396545154e79413724bde25d765a1c0af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 14, 2026.

Transparency log

Release files / yabplot-0.5.1-py3-none-any.whl

Download URL yabplot-0.5.1-py3-none-any.whl
Size 45.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b572f91547de91684e6f86cb6cb780bafe43c938a4796b38181e2540620d4639
BLAKE2b-256 checksum
How to use checksums
e9c35e4db76f771162b031563d39cf6688b40bebeebda3c110ff5f5726f53261
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page