ggseg3d

ggseg3d(
    data=None,
    atlas=None,
    hemisphere=None,
    surface='inflated',
    color=None,
    label_by='region',
    text_by=None,
    palette=None,
    na_color='darkgrey',
    na_alpha=1.0,
    show_legend=True,
    **kwargs,
)

Create an interactive 3D brain atlas visualization.

Parameters

Name Type Description Default
data pd.DataFrame | None DataFrame with values to map onto brain regions. Must contain a column that matches atlas labels (typically ‘label’ or ‘region’). None
atlas BrainAtlas | None Brain atlas to plot. Defaults to dk() if not specified. None
hemisphere str | list[str] | None Hemisphere(s) to show: ‘left’, ‘right’, or list of both. None
surface str Surface type for cortical atlases: ‘inflated’, ‘pial’, ‘white’, ‘semi_inflated’. 'inflated'
color str | None Column name in data to use for coloring regions. If None, uses atlas palette colors. None
label_by str Column for hover labels. Default is ‘region’. 'region'
text_by str | None Additional column for hover text. None
palette dict[str, str] | None Custom color palette as dict mapping labels to colors. None
na_color str Color for regions with missing data. Default is ‘darkgrey’. 'darkgrey'
na_alpha float Opacity for NA regions (0-1). Default is 1.0. 1.0
show_legend bool Whether to show the legend. True
**kwargs Any Additional arguments. {}

Returns

Name Type Description
go.Figure A plotly Figure object that can be displayed or further customized.

Examples

Basic atlas plot:

>>> from ggsegpy import ggseg3d, dk
>>> ggseg3d(atlas=dk())

Plot with custom data:

>>> import pandas as pd
>>> data = pd.DataFrame({
...     "label": ["lh_precentral", "rh_precentral"],
...     "value": [2.5, 2.1]
... })
>>> ggseg3d(data=data, atlas=dk(), color="value")

Set camera and background:

>>> from ggsegpy import pan_camera, set_background
>>> fig = ggseg3d(atlas=dk())
>>> fig = pan_camera(fig, "left lateral")
>>> fig = set_background(fig, "black")