Skip to contents

Read vertex-wise brain surface data from a file. The file can be in any of the supported formats, and the format will be determined from the file extension.

Usage

read.fs.morph(filepath, format = "auto")

Arguments

filepath

string. Full path to the input file. The suffix determines the expected format as follows: ".mgz" and ".mgh" will be read with the read.fs.mgh function, all other file extensions will be read with the read.fs.curv function.

format

character string, the format to use. One of c("auto", "mgh", "mgz", "curv", "gii"). The default setting "auto" will determine the format from the file extension.

Value

data, vector of floats. The brain morphometry data, one value per vertex.

Examples

curvfile <- system.file("extdata", "lh.thickness",
  package = "freesurferformats", mustWork = TRUE
)
ct <- read.fs.morph(curvfile)
cat(sprintf(
  "Read data for %d vertices. Values: min=%f, mean=%f, max=%f.\n",
  length(ct), min(ct), mean(ct), max(ct)
))
#> Read data for 149244 vertices. Values: min=0.000000, mean=2.437466, max=5.000000.
mghfile <- system.file("extdata", "lh.curv.fwhm10.fsaverage.mgz",
  package = "freesurferformats", mustWork = TRUE
)
curv <- read.fs.morph(mghfile)
cat(sprintf(
  "Read data for %d vertices. Values: min=%f, mean=%f, max=%f.\n",
  length(ct), min(ct), mean(ct), max(ct)
))
#> Read data for 149244 vertices. Values: min=0.000000, mean=2.437466, max=5.000000.