Skip to contents

This package provides pipelines for creating brain atlas data sets compatible with the ggseg and ggseg3d plotting packages in R.

Installing

Install the development version from r-universe:

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

Or from GitHub:

# install.packages("remotes")
remotes::install_github("ggsegverse/ggseg.extra")

freesurfer

The atlas creation functions need the freesurfer R package at 1.9.0 or newer. An older cached copy will fail the version requirement later:

install.packages("freesurfer")

Create custom atlases

The shortest path from a FreeSurfer annotation to a plottable atlas:

library(ggseg.extra)

atlas <- create_cortical_from_annotation(
  input_annot = c("lh.aparc.annot", "rh.aparc.annot")
)

# Fewer vertices, and the voxel staircase rounded off
atlas <- atlas_polish(atlas, keep = 0.2)

plot(atlas)

sitrep() reports whether your machine has what each pipeline needs — FreeSurfer, Connectome Workbench, and the optional R packages — so run it first if a pipeline will not start.

Step-by-step tutorials, one per input format, are under Tutorials on the package documentation page. There are pipelines for cortical, subcortical, cerebellar, white-matter tract and whole-brain atlases.

The cortical pipeline projects inflated mesh triangles directly to 2D polygons — atlas creation takes seconds, with no rendering step and no FreeSurfer installation: reading .annot files needs only the freesurferformats R package. Suggestions for improvement are welcome through GH issues or direct Pull requests.

Code of Conduct

Please note that the ggseg.extra project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Report bugs or requests

Don’t hesitate to ask for support using github issues, or requesting new atlases. While we would love getting help in creating new atlases, you may also request atlases through the issues, and we will try to get to it.

Funding

This work is funded by EU Horizon 2020 Grant ‘Healthy minds 0-100 years: Optimizing the use of European brain imaging cohorts (Lifebrain)’, with grant agreement 732592. The project has also received funding from the European Research Council’s Starting grant (grant agreements 283634, to Anders Martin Fjell and 313440 to Kristine Beate Walhovd) and Consolidator Grant (grant agreement 771355 to Kristine Beate Walhovd and 725025 to Anders Martin Fjell). The project has received funding through multiple grants from the Norwegian Research Council.