ciftiTools (version 0.1.6.0)

make_subcort: Make "xifti" subcortical components

Description

Coerce subcortical data into valid entries for xifti$data$subcort and xifti$meta$subcort. The data arguments can be matrices/arrays or NIFTI file paths. If the mask is not provided, it will be inferred from the labels.

Usage

make_subcort(vol, labs, mask = NULL, validate_mask = FALSE)

Arguments

vol

represents the data values of the subcortex. It is either a NIFTI file path, 3D/4D data array (\(i x j x k x T\)), or a vectorized data matrix (\(V_S\) voxels x \(T\) measurements). If it's vectorized, the voxels should be in spatial order.

labs

represents the brainstructure labels of each voxel: see substructure_table. It is either a NIFTI file path, a 3D data array (\(i x j x k\)) of numeric brainstructure indices, or a \(V_S\) length vector in spatial order with brainstructure names as factors or integer indices. The indices should be 3-21 (2 and 3 correspond to left and right cortex, respectively) or 1-19 (cortex labels omitted), with 0 representing out-of-mask voxels.

mask

is a NIFTI file path or logical 3D data array (\(i x j x k\)) where TRUE values indicate subcortical voxels (in-mask). If it is not provided, the mask will be inferred from voxels with labels 0 or NA in subcortLabs. If subcortLabs are vectorized and subcortMask is not provided, the mask cannot be inferred so an error will occur.

validate_mask

If mask is provided, set this to TRUE to check that the mask only removes voxels with NA and 0 values in vol and labs. Default: FALSE (saves time).

Value

A list with components "data", "labels", "mask", and "trans_mat". The first two will be vectorized and ordered spatially.

The volume can be recovered using: vol <- unmask_vol(data, mask, fill=NA) labs <- unmask_vol(labels, mask, fill=0)

Label Levels

xifti$meta$subcort$labels is a factor with the following levels:

  1. Cortex-L

  2. Cortex-R

  3. Accumbens-L

  4. Accumbens-R

  5. Amygdala-L

  6. Amygdala-R

  7. Brain Stem

  8. Caudate-L

  9. Caudate-R

  10. Cerebellum-L

  11. Cerebellum-R

  12. Diencephalon-L

  13. Diencephalon-R

  14. Hippocampus-L

  15. Hippocampus-R

  16. Pallidum-L

  17. Pallidum-R

  18. Putamen-L

  19. Putamen-R

  20. Thalamus-L

  21. Thalamus-R

These correspond to the same structures as given by ft_read_cifti in the cifti-matlab MATLAB toolbox.

Details

To read in the labels as the primary data, use the labels NIFTI for both vol and labs.