read_cifti_flat: Read only the data matrix in a CIFTI file

View source: R/read_cifti_flat.R

read_cifti_flatR Documentation

Read only the data matrix in a CIFTI file

Description

Reads the CIFTI data matrix by converting it to a GIFTI using the -cifti-convert -to-gifti-ext Connectome Workbench command. The result will be a T \times G matrix (T measurements, G non-empty grayordinates). All brainstructures in the CIFTI will be obtained, with no indication for which brainstructure each brainordinate corresponds to. Medial wall vertices and voxels outside the subcortical mask will not be included. No spatial information is included. This is the fastest way to read in CIFTI data.

Usage

read_cifti_flat(
  cifti_fname,
  keep = FALSE,
  gifti_fname = NULL,
  idx = NULL,
  write_dir = NULL
)

Arguments

cifti_fname

File path to a CIFTI file (ending in ".d*.nii").

keep

This function works by converting the CIFTI file to a GIFTI file and then reading it in. Should the GIFTI file be kept? If FALSE (default), write it in a temporary directory regardless of write_dir.

gifti_fname

File path of GIFTI-format data to save the CIFTI as. Should end with ".func.gii" for dscalar and dtseries CIFTI, and ".label.gii" for dlabel CIFTI. Default: the CIFTI_fname but with the CIFTI extension replaced with the appropriate GIFTI extension.

idx

Numeric vector indicating the data indices (columns) to read. If NULL (default), read in all the data. Must be a subset of the indices present in the file, or an error will occur.

For high-resolution CIFTI files, reading in only a subset of the data saves memory, but will be slower than reading in the entire file due to the required intermediate steps.

write_dir

The directory in which to save the GIFTI, if it is being kept. If NULL (default), use the current working directory.

Value

A T \times G matrix, where T is the number of measurements and G is the number of grayordinates in the CIFTI file.


ciftiTools documentation built on Oct. 4, 2024, 1:12 a.m.