Learn R Programming

ggseg3d

Interactive 3D brain atlas visualization in R. Plot brain parcellations as WebGL meshes powered by Three.js, or render publication-quality static images through rgl and rayshader. A pipe-friendly API lets you map data onto brain regions, control camera angles, toggle region edges, overlay glass brains, and snapshot the result.

Installation

Install from CRAN:

install.packages("ggseg3d")

Or get the development version from the ggsegverse r-universe:

options(
  repos = c(
    ggsegverse = "https://ggsegverse.r-universe.dev",
    CRAN = "https://cloud.r-project.org"
  )
)
install.packages("ggseg3d")

Atlases

Three atlases ship with the package (via ggseg.formats):

  1. dk – Desikan-Killiany cortical atlas
  2. aseg – Automatic subcortical segmentation
  3. tracula – White-matter tract atlas

Additional atlases are available through the ggsegverse r-universe.

Usage

ggseg3d(atlas = dk(), hemisphere = "left") |>
  pan_camera("left lateral")

Subcortical structures with a translucent glass brain overlay:

ggseg3d(atlas = aseg()) |>
  add_glassbrain() |>
  pan_camera("right lateral")

See the package website for the full walkthrough, rayshader rendering, and Shiny integration.

Citation

Mowinckel & Vidal-Piñeiro (2020). Visualization of Brain Statistics With R Packages ggseg and ggseg3d. Advances in Methods and Practices in Psychological Science. doi:10.1177/2515245920928009

Funding

This tool is partly funded by:

EU Horizon 2020 Grant: Healthy minds 0-100 years: Optimising the use of European brain imaging cohorts (Lifebrain).

Grant agreement number: 732592.

Call: Societal challenges: Health, demographic change and well-being

Copy Link

Version

Install

install.packages('ggseg3d')

Monthly Downloads

734

Version

2.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Athanasia Mo Mowinckel

Last Published

February 20th, 2026

Functions in ggseg3d (2.0.0)

rotate_vector

Rotate vector around axis by angle (Rodrigues' formula)
snapshot_brain

Save ggseg3d widget as image
set_positioning

Set hemisphere positioning mode
set_background

Set background color of ggseg3d plot
set_dimensions

Set widget dimensions
set_edges

Set region boundary edges
set_flat_shading

Enable flat shading for ggseg3d plot
updateGgseg3dBackground

Update background in Shiny
vertices_to_labels

Map atlas vertex indices to region labels
mesh_entry_to_mesh3d

Convert mesh entry to rgl mesh3d object
tangents_to_colors

Convert tangent vectors to orientation RGB colours
cross_product

Cross product of two 3D vectors
set_legend

Set legend visibility
set_orthographic

Enable orthographic camera for ggseg3d plot
vertices_to_text

Map vertices to text values for hover display
updateGgseg3dCamera

Update camera in Shiny
vertices_to_colors

Map atlas vertex indices to mesh colors
apply_colours_and_legend

Apply colour palette and build legend data
generate_tube_mesh

Generate tube mesh from centerline
build_centerline_data

Build centerline data for tract atlases
build_subcortical_meshes

Build mesh list for subcortical atlases
build_tract_meshes

Build mesh list for tract atlases
create_ggseg3d_widget

Create ggseg3d htmlwidget
build_continuous_legend

Build continuous legend
data_merge_mesh

Merge user data with mesh atlas data
ggseg3d-package

ggseg3d: Plot brain segmentations in 3D
ggseg3d-shiny

Shiny bindings for ggseg3d
build_cortical_meshes

Build mesh list for cortical atlases
add_glassbrain

Add glass brain to ggseg3d plot
ggseg3d

Plot 3D brain parcellations
ggsegray

Render brain atlas with rgl
prepare_mesh_atlas_data

Prepare mesh-based atlas data
apply_colour_palette

Apply colour palette
compute_parallel_transp_fr

Compute parallel transport frames along curve
camera_preset_to_position

Map camera preset name to position vector
build_discrete_legend

Build discrete legend
resolve_brain_mesh

Resolve brain surface mesh
build_legend_data

Build legend data structure
reexports

Objects exported from other packages
look_at_origin

Compute rgl rotation matrix to look at the origin from a given position
prepare_atlas_data

Prepare atlas data
prepare_brain_meshes

Prepare brain meshes and legend data
pan_camera

Pan camera position of ggseg3d plot
position_hemisphere

Position hemisphere vertices for anatomical display