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 -------------------------------
cifti_fname <- ciftiTools::ciftiTools.files()$cifti["dtseries"]
surfL_fname <- ciftiTools.files()$surf["left"]
surfR_fname <- ciftiTools.files()$surf["right"]
xii <- read_cifti(
cifti_fname, brainstructures="all",
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 ---------------------------------------------
cortexL <- xii$data$cortex_left
cortexL_mwall <- xii$meta$medial_wall_mask$left
cortexR <- xii$data$cortex_right
cortexR_mwall <- xii$meta$medial_wall_mask$right
# subcortVol <- xii$data$subcort
# subcortLabs <- xii$meta$subcort$labels
# subcortMask <- xii$meta$subcort$mask
surfL <- xii$surf$cortex_left
surfR <- xii$surf$cortex_right
# Create a `"xifti"` from data ----------------------------------
xii2 <- as.xifti(
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.
load_surf
. See the data acknowledgement section at the bottom of this README.
"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:
xii <- as.xifti(surfL=read_surf(ciftiTools.files()$surf["left"]))
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 pre-print at https://arxiv.org/abs/2106.11338.
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):
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.