template <- system.file("extdata", "cifti", "tiny.dlabel.nii", package = "freesurferformats")
keys <- read.fs.parcellation.cifti(template, "lh")
label_table <- read.fs.parcellation.cifti(template, "lh", with_label_table = TRUE)$label_table
out_file <- file.path(tempdir(), "written.dlabel.nii")
write.fs.parcellation.cifti(out_file, keys, template = template, structure = "lh",
label_table = label_table)
table(read.fs.parcellation.cifti(out_file, "lh"))
unlink(out_file)
Run the code above in your browser using DataLab