template <- system.file("extdata", "cifti", "tiny.dscalar.nii", package = "freesurferformats")
out_file <- file.path(tempdir(), "written.dscalar.nii")
data <- read.fs.morph.cifti(template, "lh")
data[2] <- 555 # change one value
write.fs.morph.cifti(out_file, data, template = template, structure = "lh")
read.fs.morph.cifti(out_file, "lh")[1:3]
unlink(out_file)
Run the code above in your browser using DataLab