write.fs.series.cifti: Write time series data to a CIFTI-2 '.dtseries' file.

View source: R/write_cifti_fs.R

write.fs.series.ciftiR Documentation

Write time series data to a CIFTI-2 .dtseries file.

Description

Write 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.cifti or an fs.cifti.data object, or NULL. 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, and structure has to be given.

structure

character string or NULL, the brain structure the data belongs to (e.g. 'lh'), needed if data is 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, see write.cifti. The default keeps the metadata of the template file.

Value

the axes that were written, invisibly.

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"))



freesurferformats documentation built on Sept. 25, 2026, 1:07 a.m.