The ggseg package comes with a function of the same name which can be used to plot brain segmentations. The function displays the Desikan-Killiany cortical atlas by default, as in the following example.
# install.packages("remotes")
# remotes::install_github("LCBC-UiO/ggseg")
library(ggseg)
ggseg()

The function has several arguments that allow selecting the hemisphere, the view or even the color and size of the segmentation lines.
# install.packages("remotes")
# remotes::install_github("LCBC-UiO/ggseg")
library(ggseg)
ggseg(mapping = aes(fill = region),
colour = "gray3", # Color of the segmentation
size = 1, # Size of the segmentation
hemisphere = "left", # or "right"
view = "lateral") + # or "medial"
theme(legend.position = "none")

The package also provides a geom named geom_brain. In the following example each region is colorized and a legend with four columns is displayed.
# install.packages("remotes")
# remotes::install_github("LCBC-UiO/ggseg")
library(ggseg)
# install.packages("ggplot2")
library(ggplot2)
ggplot() +
geom_brain(atlas = dk) +
guides(fill = guide_legend(ncol = 4)) +
theme_void() +
theme(legend.position = "bottom",
legend.text = element_text(size = 8))


The other atlas that comes with the package is aseg, which provides the Freesurfer automatic subcortical segmentation of a brain volume.
# install.packages("remotes")
# remotes::install_github("LCBC-UiO/ggseg")
library(ggseg)
ggseg(atlas = aseg)

You can also display only one hemisphere of the brains making use of the hemisphere argument.
# install.packages("remotes")
# remotes::install_github("LCBC-UiO/ggseg")
library(ggseg)
ggseg(atlas = aseg,
hemisphere = "left") # or "right"
The geom_brain function also supports the aseg atlas.

# install.packages("remotes")
# remotes::install_github("LCBC-UiO/ggseg")
library(ggseg)
# install.packages("ggplot2")
library(ggplot2)
ggplot() +
geom_brain(atlas = aseg) +
theme_void() +
theme(legend.position = "bottom",
legend.text = element_text(size = 8)) +
guides(fill = guide_legend(ncol = 4))
If you like this package consider taking a look to ggseg3d for 3D brain atlas plotting and ggsegExtra for additiona atlases as well as functions and pipelines to create custom atlases.
Learn statistics from the basics to advanced techniques, clearly explained
Go to site
See also