BrainAtlas
BrainAtlas(atlas, type, core, data, palette=dict())
Brain atlas container for 2D and 3D visualization.
This is the core class in ggsegpy, equivalent to R’s ggseg_atlas. It holds atlas metadata, region definitions, geometry data, and color palettes.
Parameters
| atlas |
str |
Short name for the atlas (e.g., ‘dk’, ‘aseg’, ‘tracula’). |
required |
| type |
Literal['cortical', 'subcortical', 'tract'] |
Atlas type: ‘cortical’, ‘subcortical’, or ‘tract’. |
required |
| core |
pd.DataFrame |
DataFrame with required columns: hemi, region, label. One row per unique region. |
required |
| data |
AtlasData |
Type-specific data container (CorticalData, SubcorticalData, or TractData). |
required |
| palette |
dict[str, str] |
Named dict mapping labels to hex colors. |
dict() |
Examples
>>> from ggsegpy import dk
>>> atlas = dk()
>>> print(atlas)
>>> atlas.labels[:5]
>>> atlas.to_dataframe()
Methods
| filter |
Filter atlas by hemisphere or region. |
| plot |
Quick plot of the atlas. |
| to_dataframe |
Convert atlas to GeoDataFrame for plotting. |
filter
BrainAtlas.filter(hemi=None, region=None)
Filter atlas by hemisphere or region.
Parameters
| hemi |
str | list[str] | None |
Hemisphere(s) to keep: ‘left’, ‘right’, or list. |
None |
| region |
str | list[str] | None |
Region(s) to keep. |
None |
Returns
|
BrainAtlas |
Filtered atlas copy (preserves subclass type). |
plot
BrainAtlas.plot(**kwargs)
Quick plot of the atlas.
Parameters
| **kwargs |
Any |
Passed to geom_brain(). |
{} |
Returns
|
ggplot |
A plotnine ggplot object. |
to_dataframe
BrainAtlas.to_dataframe()
Convert atlas to GeoDataFrame for plotting.
Merges core metadata with geometry data, similar to R’s as.data.frame.ggseg_atlas.
Returns
|
gpd.GeoDataFrame |
Combined data with geometry, hemi, region, label, view, and atlas metadata columns. |