Tries to read the file with all implemented surface format reader methods. The file must exist. With the default settings, one can read files in the following surface formats: 1) FreeSurfer binary surface format (e.g., `surf/lh.white`). 2) FreeSurfer ASCII surface format (e.g., `surf/lh.white,asc`). 3) GIFTI surface format, only if package `gifti` is installed. See gifti::read_gifti for details. Feel free to implement additional methods. Hint:keep in mind that they should return one-based indices.

read_nisurfacefile(filepath, methods = c("fsnative", "fsascii", "gifti"), ...)

Arguments

filepath

character string, the full path to the input surface file.

methods

list of character strings, the formats to try. Each of these must have a function called read_nisurface.<method>, which must return an `fs.surface` instance on success.

...

parameters passed on to the individual methods

Value

an instance of `fs.surface`, read from the file. See read.fs.surface for details. If none of the reader methods succeed, an error is raised.

See also

Examples

    surface_file = system.file("extdata", "lh.tinysurface",
                            package = "freesurferformats", mustWork = TRUE);
    mesh = read_nisurface(surface_file);
    mesh;
#> Brain surface trimesh with 5 vertices and 3 faces.
#> -Surface coordinates: minimal values are (0.30, 0.30, 0.30), maximal values are (0.30, 0.30, 0.30).