Read a CIFTI-2 file whose two matrix dimensions both describe
brainordinates or parcels, i.e. a dense connectome (.dconn), a parcellated
connectome (.pconn) or one of the mixed types (.pdconn, .dpconn). The result
contains the matrix and the parcels or brainordinates its rows and columns belong to;
this is what makes a connectome file usable, since the numbers alone do not say which
pair of regions a value describes.
Both values of a connectome are stored in the file (the matrix is not symmetric on
disk, and the diagonal is stored as well), so reading a .pconn gives a square matrix
with the number of parcels as its number of rows and columns. A real .dconn (an HCP
subject has 91,282 grayordinates, i.e. 8.3 billion values, 33 GB) can not be read into
memory at all: use the rows and columns parameters to read only the part you need,
which is a contiguous block of the file for each requested column.
read.fs.connectome.cifti(filepath, rows = NULL, columns = NULL)a named list with class 'fs.connectome':
'data': numeric matrix, the connectome, with the parcels or brainordinates as
the dimnames of its rows and columns (see cifti.dim.labels),
'parcel_names': character vector, the names of the parcels, or NULL if the
file has no parcellated dimension,
'parcels': data.frame with one row per parcel (the columns 'index', 'name',
'num_vertices' and 'num_voxels', see cifti.parcels), or NULL,
'parcels_dim': integer, the matrix dimension that holds the parcels (0 or 1),
or NA if the file has none,
'grayordinates': data.frame with one row per brainordinate of the dense
dimension (see cifti.grayordinates), or NULL,
'grayordinates_dim': integer, the matrix dimension that holds the dense
brainordinates (0 or 1), or NA if the file has none,
'header': the fs.cifti metadata object, see read.cifti.header.
Note that the parcels and brainordinates describe all indices of the dimension they
belong to, not only the ones selected with rows or columns.
character string, the path of a CIFTI-2 file, see read.cifti.
An fs.cifti object (see read.cifti.header) or an fs.cifti.data object
(see read.cifti) are accepted as well.
integer vector or NULL, the indices of matrix dimension 0 to read, see
read.cifti.
integer vector or NULL, the indices of matrix dimension 1 to read. This
is the way to read part of a file that is too large to read completely, see
read.cifti.
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(),
read.cifti.header(),
read.cifti.rows(),
write.cifti(),
write.fs.connectome.cifti(),
write.fs.morph.cifti(),
write.fs.parcellated.cifti(),
write.fs.parcellation.cifti(),
write.fs.series.cifti()
pconn_file <- system.file("extdata", "cifti", "tiny.pconn.nii", package = "freesurferformats")
conn <- read.fs.connectome.cifti(pconn_file)
dim(conn$data)
conn$parcel_names
conn$data[1:2, 1:2]
Run the code above in your browser using DataLab