Skip to contents

Get the mapping from the matrix indices of one dimension to the individual surface vertices and volume voxels a CIFTI-2 file contains. This is the per-index version of the table returned by cifti.structures, which reports index ranges instead of single indices. It is useful to find out which vertex or voxel a data row belongs to, or to find the data index of a vertex or voxel.

Note that the same vertex or voxel can only appear once per dimension (the matrix has one entry per brainordinate), but a structure can be split over several brain model entries, and the vertices of a grayordinates file are a subset of the vertices of the surface it refers to.

Usage

cifti.grayordinates(cii, dim = 0L)

Arguments

cii

an fs.cifti instance, see read.cifti.header.

dim

integer, the matrix dimension to get the brain models for. CIFTI-2 files have two dimensions, so this is usually 0 (Workbench calls it the ROW dimension) or 1 (the COLUMN dimension). See read.cifti.header for details on the dimensions.

Value

a data.frame with one row per index of the matrix dimension and the columns 'index' (integer, 0-based matrix index), 'structure' (character string, the brain structure as spelled in the file), 'structure_short' (without the CIFTI_STRUCTURE_ prefix), 'model_type' ('SURFACE' or 'VOXELS'), 'vertex_index' (integer, 0-based index of the vertex in the surface for surface models, NA for volume models) and 'i', 'j', 'k' (integer, 0-based voxel indices for volume models, NA for surface models).

Examples

cifti_file <- system.file("extdata", "cifti", "tiny.dscalar.nii", package = "freesurferformats")
cii <- read.cifti.header(cifti_file)
grayordinates <- cifti.grayordinates(cii, dim = 1L)
head(grayordinates)
#>   index                   structure structure_short model_type vertex_index  i
#> 1     0 CIFTI_STRUCTURE_CORTEX_LEFT     CORTEX_LEFT    SURFACE            0 NA
#> 2     1 CIFTI_STRUCTURE_CORTEX_LEFT     CORTEX_LEFT    SURFACE            1 NA
#> 3     2 CIFTI_STRUCTURE_CORTEX_LEFT     CORTEX_LEFT    SURFACE            2 NA
#> 4     3 CIFTI_STRUCTURE_CORTEX_LEFT     CORTEX_LEFT    SURFACE            3 NA
#> 5     4 CIFTI_STRUCTURE_CORTEX_LEFT     CORTEX_LEFT    SURFACE            4 NA
#> 6     5 CIFTI_STRUCTURE_CORTEX_LEFT     CORTEX_LEFT    SURFACE            5 NA
#>    j  k
#> 1 NA NA
#> 2 NA NA
#> 3 NA NA
#> 4 NA NA
#> 5 NA NA
#> 6 NA NA