Skip to contents

[Experimental]

Turn SUIT cerebellar parcellation files into a brain atlas you can plot with ggseg and ggseg3d. Reads GIFTI label files containing vertex-to-region assignments and projects them onto the SUIT flatmap surface to generate 2D polygon geometry. Optionally tessellates per-region 3D meshes from a cerebellar segmentation volume.

The SUIT (Spatially Unbiased Infratentorial Template) flatmap is a standard 2D representation of the cerebellar cortex. Unlike cortical atlases that require orthographic projection of an inflated mesh, the flatmap surface already contains 2D coordinates.

Usage

create_cerebellar_from_gifti(
  gifti_files,
  decimate = 0.5,
  verbose = get_verbose(),
  ...,
  volume = NULL,
  atlas_name = NULL,
  output_dir = NULL,
  min_coverage = NULL,
  cleanup = NULL,
  skip_existing = NULL
)

Arguments

gifti_files

Character vector of paths to GIFTI label files (.label.gii or .func.gii) containing the cerebellar parcellation.

decimate

Mesh decimation factor between 0 and 1. Reduces the number of faces in 3D meshes using quadric edge decimation (via Rvcg::vcgQEdecim()). A value of 0.5 reduces faces by 50%. Set to NULL to skip decimation. Requires the Rvcg package. Default is 0.5.

verbose

How much to print: 0 silent, 1 progress (the default), 2 adds FreeSurfer's own output. TRUE and FALSE mean 1 and 0. Falls back to options("ggseg.extra.verbose"), then GGSEG_EXTRA_VERBOSE.

...

Not used. Present so that a mistyped or misplaced argument is reported against this function rather than silently ignored; anything passed here is an error. Geometry is shaped after the build: see atlas_polish(), or atlas_simplify(), atlas_smooth() and atlas_dilate() individually.

volume

Optional path to a cerebellar segmentation volume (NIfTI) for 3D mesh generation. When provided, per-region meshes are tessellated using FreeSurfer tools and included in the atlas for 3D rendering.

atlas_name

Name for the atlas. If NULL, derived from the input filename. It also names the folder of intermediate files inside output_dir, so it must be a single name without path separators.

output_dir

Where to put the intermediate files. Defaults to tempdir(), from options("ggseg.extra.output_dir") or GGSEG_EXTRA_OUTPUT_DIR.

min_coverage

Smallest share of core labels that must end up with 2D geometry, between 0 and 1. A build that falls below it warns and names the labels that have no shape; the warning fires whatever verbose is set to, because a region that cannot be drawn is data loss rather than progress chatter. The build itself still returns, so a long pipeline is never thrown away over a threshold. Use 0 to turn the check off. Defaults to 0.8, or to options("ggseg.extra.min_coverage"), then GGSEG_EXTRA_MIN_COVERAGE.

cleanup

Remove the intermediate files afterwards. Default TRUE, from options("ggseg.extra.cleanup") or GGSEG_EXTRA_CLEANUP.

The intermediate files live in a folder named after the atlas inside output_dir, and the whole folder is removed. A build therefore refuses to start if that folder already holds files it did not write, since removing it would take them too. Choose another output_dir or atlas_name, or pass FALSE to build there and keep everything.

skip_existing

Reuse a step's intermediate files when they already exist, instead of running the step. Default FALSE, from options("ggseg.extra.skip_existing") or GGSEG_EXTRA_SKIP_EXISTING.

A cache records which ggseg.extra wrote it, not what it was built from, so reuse cannot tell that the volume or lookup table has changed. Reuse is therefore asked for rather than assumed, and is reported when it happens. To continue an interrupted build, either pass TRUE or leave the finished steps out of steps.

Value

A ggseg_atlas object of type "cerebellar" containing region metadata (core), a colour palette, sf geometry for 2D plots, and optionally 3D meshes.

Examples

if (FALSE) { # \dontrun{
atlas <- create_cerebellar_from_gifti(
  gifti_files = "Lobules-SUIT.label.gii"
)
plot(atlas)
} # }