CIFTI files contain brain imaging data in “grayordinates,” which
represent the gray matter as cortical surface vertices (left and right)
and subcortical voxels (cerebellum, basal ganglia, and other deep gray
matter). ciftiTools
provides a unified environment for
reading, writing, visualizing and manipulating CIFTI-format data. It
supports the “dscalar,” “dlabel,” and “dtseries” intents. Greyordinate
data is read in as a "xifti"
object, which is structured
for convenient access to the data and metadata, and includes support for
surface geometry files to enable spatially-dependent functionality such
as static or interactive visualizations and smoothing.
You can install ciftiTools
from CRAN with:
install.packages("ciftiTools")
Additionally, most of the ciftiTools
functions require
the Connectome Workbench, which can be installed from the HCP
website.
# Load the package and point to the Connectome Workbench --------
library(ciftiTools)
ciftiTools.setOption("wb_path", "path/to/workbench")
# Read and visualize a CIFTI file -------------------------------
<- ciftiTools::ciftiTools.files()$cifti["dtseries"]
cifti_fname <- ciftiTools.files()$surf["left"]
surfL_fname <- ciftiTools.files()$surf["right"]
surfR_fname
<- read_cifti(
xii brainstructures="all",
cifti_fname, surfL_fname=surfL_fname, surfR_fname=surfR_fname,
resamp_res=4000
)
view_xifti_surface(xii) # or plot(xii)
# view_xifti_volume(xii) if subcortex is present
# Access CIFTI data ---------------------------------------------
<- xii$data$cortex_left
cortexL <- xii$meta$medial_wall_mask$left
cortexL_mwall <- xii$data$cortex_right
cortexR <- xii$meta$medial_wall_mask$right
cortexR_mwall # subcortVol <- xii$data$subcort
# subcortLabs <- xii$meta$subcort$labels
# subcortMask <- xii$meta$subcort$mask
<- xii$surf$cortex_left
surfL <- xii$surf$cortex_right
surfR
# Create a `"xifti"` from data ----------------------------------
<- as.xifti(
xii2 cortexL=cortexL, cortexL_mwall=cortexL_mwall,
cortexR=cortexR, cortexR_mwall=cortexR_mwall,
#subcortVol=subcortVol, subcortLabs=subcortLabs,
#subcortMask=subcortMask,
surfL=surfL, surfR=surfR
)
# Write a CIFTI file --------------------------------------------
write_cifti(xii2, "my_cifti.dtseries.nii")
See this link to view the tutorial vignette.
"xifti"
?The "xifti"
object is a general interface for not only
CIFTI files, but also GIFTI and NIFTI files. For example, we can plot a
surface GIFTI:
<- as.xifti(surfL=read_surf(ciftiTools.files()$surf["left"]))
xii plot(xii)
We can also convert metric GIFTI files and/or NIFTI files to CIFTI
files (or vice versa) using the "xifti"
object as an
intermediary.
oro.nifti
,
RNifti
gifti
cifti
can read in any CIFTI file, whereas ciftiTools
provides a
user-friendly interface for CIFTI files with the dscalar, dlabel, and
dtseries intents only.fsbrain
xml2
rgl
You can cite our paper at https://doi.org/10.1016/j.neuroimage.2022.118877.
The following data are included in the package for convenience:
Example CIFTI files provided by NITRC.
Cortical surfaces provided by the HCP, according to the Data Use Terms:
Data were provided [in part] by the Human Connectome Project, WU-Minn Consortium (Principal Investigators: David Van Essen and Kamil Ugurbil; 1U54MH091657) funded by the 16 NIH Institutes and Centers that support the NIH Blueprint for Neuroscience Research; and by the McDonnell Center for Systems Neuroscience at Washington University.
Several parcellations provided by Thomas Yeo’s Computational Brain Imaging Group (CBIG):