write.fs.surface.asc: Write mesh to file in FreeSurfer ASCII surface format

Description Usage Arguments Value See Also Examples

View source: R/write_fs_surface.R

Description

Write vertex coordinates and vertex indices defining faces to a file in FreeSurfer ASCII surface format. For a subject (MRI image pre-processed with FreeSurfer) named 'bert', an example file would be 'bert/surf/lh.white.asc'.

Usage

1
write.fs.surface.asc(filepath, vertex_coords, faces)

Arguments

filepath

string. Full path to the output surface file, should end with '.asc', but that is not enforced.

vertex_coords

n x 3 matrix of doubles. Each row defined the x,y,z coords for a vertex.

faces

n x 3 matrix of integers. Each row defined the 3 vertex indices that make up the face. WARNING: Vertex indices should be given in R-style, i.e., the index of the first vertex is 1. However, they will be written in FreeSurfer style, i.e., all indices will have 1 substracted, so that the index of the first vertex will be zero.

Value

string the format that was written. One of "tris" or "quads". Currently only triangular meshes are supported, so always 'tris'.

See Also

Other mesh functions: faces.quad.to.tris(), read.fs.surface.asc(), read.fs.surface.bvsrf(), read.fs.surface.geo(), read.fs.surface.gii(), read.fs.surface.ico(), read.fs.surface.obj(), read.fs.surface.off(), read.fs.surface.ply(), read.fs.surface.vtk(), read.fs.surface(), read.mesh.brainvoyager(), read_nisurfacefile(), read_nisurface(), write.fs.surface.byu(), write.fs.surface.gii(), write.fs.surface.mz3(), write.fs.surface.vtk(), write.fs.surface()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
    # Read a surface from a file:
    surface_file = system.file("extdata", "lh.tinysurface",
     package = "freesurferformats", mustWork = TRUE);
    mesh = read.fs.surface(surface_file);

    # Now save it:
    write.fs.surface.asc(tempfile(fileext=".asc"), mesh$vertices, mesh$faces);

## End(Not run)

freesurferformats documentation built on Feb. 11, 2022, 5:06 p.m.