Write time series data to a CIFTI-2 .dtseries file.
Source: R/write_cifti_fs.R
write.fs.series.cifti.RdWrite a per-vertex time series (or several structures at once) to a CIFTI-2
dense series file. This is the inverse of read.fs.series.cifti.
Usage
write.fs.series.cifti(
filepath,
data,
template = NULL,
structure = NULL,
start = 0,
step = 1,
unit = "SECOND",
metadata = NULL
)Arguments
- filepath
character string, the path of the file to write. The name should end with
.dscalar.nii.- data
numeric matrix or named list, the data: a matrix with one row per vertex of the complete surface and one column per series point (time point), or a named list of such matrices per structure.
- template
character string (the path of a CIFTI-2 file), an
fs.ciftior anfs.cifti.dataobject, orNULL. The grayordinate mapping of this file is used, so pass the file the data comes from (e.g. an HCP file of the same subject): the mapping of such a file cannot be invented. Without a template, the file covers all vertices of the surfaces, andstructurehas to be given.- structure
character string or
NULL, the brain structure the data belongs to (e.g.'lh'), needed ifdatais not a named list and there is no template to take the structures from.- start
numeric, the value of the first series point, see
cifti.axis.series.- step
numeric, the difference between consecutive series points.
- unit
character string, the unit of the series, one of 'SECOND', 'HERTZ', 'METER' or 'RADIAN'.
- metadata
named character vector or
NULL, the matrix metadata, seewrite.cifti. The default keeps the metadata of the template file.
See also
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(),
read.fs.connectome.cifti(),
write.cifti(),
write.fs.connectome.cifti(),
write.fs.morph.cifti(),
write.fs.parcellated.cifti(),
write.fs.parcellation.cifti()
Examples
template <- system.file("extdata", "cifti", "tiny.dscalar.nii", package = "freesurferformats")
series <- matrix(seq_len(10 * 3), nrow = 10L) # 10 vertices (lh), 3 time points
out_file <- file.path(tempdir(), "written.dtseries.nii")
write.fs.series.cifti(out_file, series, template = template, structure = "lh", step = 0.72)
dim(read.fs.series.cifti(out_file, "lh"))
#> [1] 10 3