Skip to main content

subcortex_visualization: A toolbox for custom data visualization in the subcortex and cerebellum

DOI:10.64898/2026.01.23.699785

This package (implemented in Python and R) currently includes the following sixteen subcortical and cerebellar atlases for data visualization in two-dimensional vector graphics:

More information about these atlases, including the process of rendering the surfaces and tracing the outlines for each, can be found in the atlas_info/ directory and at the project website.

🔗 Citing this package

If you use this package in a scientific publication, blog post, etc., we ask that you please read and cite the associated publication:

  • 📕 Bryant, Annie G. (2026). Subcortex visualization: A toolbox for custom data visualization in the subcortex and cerebellum. Aperture Neuro, 2026;6. doi:10.52294/001c.165884.
Click here for a BibTex reference:
@article{bryant2026subcortex,
	title = {Subcortex visualization: A toolbox for custom data visualization in the subcortex and cerebellum},
	url = {https://doi.org/10.52294/001c.165884},
	doi = {10.52294/001c.165884},
	journal = {Aperture Neuro},
	author = {Bryant, Annie G.},
  volume = {6},
	year = {2026}
}

🙋‍♀️ Motivation

Among the many beautiful tools for visualizing region-level cortical results (as elegantly laid out by Chopra et al. Aperture Neuro 2023), there are far fewer options by comparison once you venture below the cortical mantle. Most research groups end up developing visualization pipelines in an ad hoc way for individual atlases, which can amount to redundant efforts and figures that are difficult to compare across studies.

This package is inspired by the fantastic ggseg R package (and its Python extension), which unifies more than fifteen cortical parcellation atlases into a clean, standardized two-dimensional (2D) vector graphic format for data mapping. We followed in this approach because vector graphics aren't subject to the lighting artifacts that make three-dimensional (3D) renderings difficult to interpret (especially with color-mapped values), and they produce crisp, resolution-independent figures that are publication-ready straight out of the box (and easy to touch up in Inkscape or Illustrator afterwards).

While ggseg does support subcortical plotting via the FreeSurfer aseg atlas, it's not currently possible to show all seven subcortical regions (accumbens, amygdala, caudate, hippocampus, pallidum, putamen, thalamus) together in one figure, and the atlas coverage for the broader subcortex, thalamic nuclei, brainstem, and cerebellum is quite limited across the field.

With subcortex_visualization, we hope to fill this gap by offering sixteen commonly used subcortical and cerebellar atlases that all render in the same consistent 2D vector format, for mapping empirical region-level data from a variety of sources, using a single function call in Python or R. To our knowledge, it's the largest collection of non-cortical atlases in one unified vector-based visualization toolbox.

The below graphic shows the path from 3D volumetric segmentation to 2D vector scaffold, using the Melbourne Subcortex Atlas (S1 resolution) as an example:

Vector outlines are derived from 3D subcortical meshes (like the one for the aseg subcortical atlas offered by the ENIGMA toolbox), either through a semi-automated or manual tracing pipeline. Check out adding_new_atlases/ as well as the package documentation website for more information. Those same pipelines are there for you if you want to add your own custom atlas to the mix.

🖥️ Installation

Python

The Python version of this package can be installed in two ways. First, you can install directly with pip from the PyPI repository:

pip install subcortex-visualization

If you would like to make your own modifications before installing, you can also clone this repository first and then install from your local version:

git clone https://github.com/anniegbryant/subcortex_visualization.git
cd subcortex_visualization
pip install .

This will install the subcortex_visualization package so you have access to the plot_subcortical_data function and associated data.

R

The R version of this package can be installed from GitHub within R using the remotes package as follows:

# if not already installed
install.packages("remotes")

# then install subcortexVisualizationR
remotes::install_github("anniegbryant/subcortex_visualization", subdir = "subcortexVisualizationR")

👨‍💻 Usage

❗️ Quick start

Running the code below (in either Python or R) will produce an image of the left subcortex in the aseg_subcortex atlas (the default), each region colored by its index, with the viridis color scheme:

plot_subcortical_data(hemisphere='L', fill_title="Subcortical region index", atlas='Melbourne_S1')

Note that we specified atlas='Melbourne_S1' to demonstrate default functionality with the S1 resolution of the Melbourne Subcortex Atlas.

📚 Tutorial

For a guide that goes through all the functionality and atlases available in this package, we compiled walkthrough tutorials for Python and R on the project website. To plot real data in the subcortex, your subcortex_data should be a Python pandas.DataFrame or an R data.frame structured as follows (here we've just assigned an integer index to each region):

region value Hemisphere
accumbens 0 L
amygdala 1 L
caudate 2 L
hippocampus 3 L
pallidum 4 L
putamen 5 L
thalamus 6 L

The core plotting function in both Python and R is plot_subcortical_data, which takes the following arguments:

Parameter Default Description
subcortex_data None / NULL Optional dataframe with columns region, Hemisphere, and value_column. If omitted, regions are colored by index.
atlas 'aseg_subcortex' Atlas name (see full list below).
value_column 'value' Column in subcortex_data to visualize.
hemisphere 'L' 'L', 'R', 'V', or 'B'.
views ['medial', 'lateral'] Which faces to show. Options: 'medial', 'lateral', 'superior', 'inferior'. Not applicable to SUIT.
line_color 'black' Outline color for each region.
line_thickness 0.5 Outline thickness, or a column name in subcortex_data for per-region thickness.
cmap 'viridis' Colormap name, a matplotlib.colors.Colormap, or (in R) a vector of hex colors or palette function.
NA_fill '#cccccc' Fill color for regions with missing data.
fill_alpha 1.0 Region opacity (0–1).
fill_by_significance False / FALSE If True, dims non-significant regions (requires a p_value column in subcortex_data).
nonsig_fill_alpha 0.5 Opacity for non-significant regions when fill_by_significance=True.
vmin / vmax None / NULL Manually constrain the colormap range.
midpoint None / NULL Center a diverging colormap at this value.
show_legend True / TRUE Whether to display the colorbar/legend.
fill_title 'values' Colorbar label.
fontsize 12 Font size for figure text.

Two additional utility functions are also available. Check out the full Python API or R API reference:

  • parcel_segstats: Extract and summarize voxel values from a NIfTI volume across atlas parcels (supports multiple atlases and summary statistics, with optional resampling).
  • get_atlas_regions: Return the region names for a given atlas.

Here's an example in Python for plotting both hemispheres with data randomly sampled from a normal distribution, using a blue–white–red diverging colormap centered at zero:

import matplotlib.colors as mcolors
import numpy as np

np.random.seed(127)

# Get region names for the aseg subcortex atlas
aseg_subcortex_regions = get_atlas_regions("aseg_subcortex")

# Sample random values from a normal distribution for each hemisphere
example_continuous_data_L = (pd.DataFrame({
    "region": aseg_subcortex_regions,
    "value": np.random.normal(0, 1, len(aseg_subcortex_regions))
}).assign(Hemisphere="L"))

example_continuous_data_R = (pd.DataFrame({
    "region": aseg_subcortex_regions,
    "value": np.random.normal(0, 1, len(aseg_subcortex_regions))
}).assign(Hemisphere="R"))

# Combine left and right hemisphere data for bilateral plotting
example_continuous_data = pd.concat([example_continuous_data_L, example_continuous_data_R], axis=0)

white_blue_red_cmap = mcolors.LinearSegmentedColormap.from_list("BlueWhiteRed", ["blue", "white", "red"])

plot_subcortical_data(subcortex_data=example_continuous_data, atlas='aseg_subcortex',
                      hemisphere='both', fill_title="Normal distribution sample",
                      cmap=white_blue_red_cmap, midpoint=0)

🗺️ Available atlases

The following subcortical and cerebellar atlases are currently supported with more information at the project website:

💡 Want to generate your own mesh and/or parcellation?

This package provides sixteen subcortical, thalamic, and cerebellar atlases as a starting point. The workflow can readily be extended to your favorite segmentation atlas, though! We provide two pipelines in the adding_new_atlases/ folder:

  1. Semi-automated pipeline: Uses Python scripts to automatically trace per-region surface meshes via YABplot and Potrace; faster and fully scriptable (with the exception of one manual region order definition step at the end), ideal for atlases with clearly separable regions.
  2. Manual pipeline: Interactively renders a composite mesh in Surf Ice and traces each region by hand in Inkscape; more time-consuming, but more interactive and offers finer control for atlases with many small or closely-packed nuclei.

Check out the project website page for a full walkthrough of both approaches.

🙏 Acknowledgments

Thank you very much to Sidhant Chopra, Chris Rorden, Justine Hansen, Ye Tian, and Toomas Erik Anijärv for their suggestions and continued development of open tools for neuroimaging visualization that enabled the development of this project!

We're also very grateful for ongoing contributions from members of the GitHub community:

Contributors

Publications that have used this package 👯‍♀️

📜 Diano et al. (2025) PNAS: https://www.pnas.org/doi/10.1073/pnas.2518549122

📜 San-Martín et al. (2025) Scientific Reports: https://www.nature.com/articles/s41598-025-25065-6

📜 Wu et al. (2026) NeuroImage: https://www.sciencedirect.com/science/article/pii/S1053811926000315

📜 Lawn et al. (2026) bioRxiv: https://doi.org/10.64898/2026.06.10.731385

📜 Guo et al. (2026) Progress in Neuro-Psychopharmacology and Biological Psychiatry: https://doi.org/10.1016/j.pnpbp.2026.111883

📜 Orsenigo et al. (2026) bioRxiv https://doi.org/10.64898/2026.08.26.747212

📜 Levitis et al. (2026) medRxiv https://doi.org/10.64898/2026.08.28.26361643

❓📧 Questions, comments, or suggestions always welcome!

Please feel free to ask questions, report bugs, or share suggestions by creating an issue or by emailing me (Annie) at (anniegbryant@gmail.com) 😊

As an open-source tool, pull requests are always welcome from the community, too. If you create your own custom vector graphic scaffold for your segmentation atlas of choice, feel free to create a pull request to incorporate and be acknowledged.

Metadata

Release files for subcortex-visualization 1.3.2

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

Source distribution (sdist)

Source distribution for subcortex-visualization 1.3.2
File Size Uploaded
subcortex_visualization-1.3.2.tar.gz 23.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for subcortex-visualization 1.3.2
File Interpreter ABI Platform
subcortex_visualization-1.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 47.8 MB

Release files / subcortex_visualization-1.3.2.tar.gz

Download URL subcortex_visualization-1.3.2.tar.gz
Size 23.4 MB
Tags Source
SHA-256 checksum
How to use checksums
15458d60b924afb2c50b0c6b0363143071cf7377b42d4aa5c3317055e1710f07
BLAKE2b-256 checksum
How to use checksums
b91728861d891b772c4780ebc14ea405b32fd8e2d4b6f33f592e2e97ae10c0e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / subcortex_visualization-1.3.2-py3-none-any.whl

Download URL subcortex_visualization-1.3.2-py3-none-any.whl
Size 24.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
52550eddd47950fbdfa4607c2a974dee16fac53391b34ff3635234125ef731f5
BLAKE2b-256 checksum
How to use checksums
1e963ca917854e8a10c3a37d4edbb1ea75258e0d7372b509cbe29f8ced28be1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

1.3.3

2 release files

This release

1.3.2 This release

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.2

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