This package mainly contains a plotting function ggseg3d and data.frames of different brain atlases for plotting. Plotting results of analyses on regions or networks often involves swapping between statistical tools, like R and Matlab, and software for brain imaging to correctly visualise analysis results.
This package aims to make it possible to plot results directly through R.
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)
library(ggplot2)
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))
Example atlas
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)
# 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))