| read.cifti | R Documentation |
Read a CIFTI-2 file, i.e. its XML metadata (see
read.cifti.header) and its data values. The data are returned
as an array in the order in which they are stored in the file: the first
array dimension is CIFTI matrix dimension 0 (which Connectome Workbench
calls the ROW dimension), the second one is matrix dimension 1 (the COLUMN
dimension). This is the same order that other CIFTI implementations use for
their data arrays.
For a dense file like a .dscalar, dimension 0 holds the scalars (maps) and
dimension 1 the brainordinates (surface vertices and volume voxels), so the
data matrix has one row per map and one column per grayordinate. For a
.dtseries, dimension 0 holds the series, so the matrix has one row per
series point. The functions cifti.series.info and
cifti.map.for.dim tell you what a dimension is; never conclude
it from the file name. Use cifti.structure.data to extract the
data of a brain structure, which is the more convenient interface for most
purposes and the one that the read.fs.*.cifti functions are built on.
Reading a file twice (once for the header, once for the data) is not necessary to extract a single structure, but it is what this function does; use it if you need more than one structure or the raw matrix.
read.cifti(filepath, rows = NULL, columns = NULL)
filepath |
character string, the path to a CIFTI-2 file. Note that a CIFTI-2 file is a NIFTI-2 file, but its data are not a 3D volume; gzipped CIFTI files do not exist (the format forbids compression so that random access remains possible). |
rows |
integer vector or |
columns |
integer vector or |
a named list with the entries 'header' (an fs.cifti object, see
read.cifti.header) and 'data' (the numeric or integer array).
The array dimensions are named with the axis labels of the corresponding
matrix dimensions, see cifti.dim.labels. The object has class
'fs.cifti.data'.
The generic readers read.fs.morph and
read.fs.volume dispatch on the file name and would therefore
match a CIFTI-2 file (which is a NIFTI-2 file), so they detect this case and
stop with a pointer to this function and the other CIFTI readers instead of
returning the values of the matrix in an order that means nothing.
Other cifti functions:
cifti.axis.brain.models(),
cifti.axis.from.template(),
cifti.axis.labels(),
cifti.axis.parcels(),
cifti.axis.parcels.from.annot(),
cifti.axis.scalars(),
cifti.axis.series(),
cifti.brain.model.surface(),
cifti.brain.model.volume(),
cifti.dim.labels(),
cifti.file.type.for.axes(),
cifti.grayordinates(),
cifti.header.from.axes(),
cifti.label.table(),
cifti.parcel(),
cifti.parcels(),
cifti.series.info(),
cifti.structure.data(),
cifti.structures(),
cifti.volume(),
print.fs.cifti(),
print.fs.cifti.data(),
print.fs.connectome(),
read.cifti.header(),
read.cifti.rows(),
read.fs.connectome.cifti(),
write.cifti(),
write.fs.connectome.cifti(),
write.fs.morph.cifti(),
write.fs.parcellated.cifti(),
write.fs.parcellation.cifti(),
write.fs.series.cifti()
cifti_file <- system.file("extdata", "cifti", "tiny.dscalar.nii", package = "freesurferformats")
cii <- read.cifti(cifti_file)
dim(cii$data)
# The first 3 grayordinates of the first map:
cii$data[1, 1:3]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.