| read.fs.surface.vtk | R Documentation |
Reads meshes from files in the VTK legacy format. Both the ASCII and the binary encoding are supported, as are the cell array layouts written by VTK 4.2 and older and by VTK 5.1 and newer, see the notes. See https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf for the format specification. Note that this function does not read arbitrary VTK datasets, it supports only the geometry of POLYDATA datasets (meshes and point clouds); attribute data such as normals, texture coordinates or scalars is ignored. Only triangular meshes are supported, files containing other polygons are rejected with an error.
read.fs.surface.vtk(filepath)
filepath |
string. Full path to the input surface file in VTK format. |
named list. The list has the following named entries: "vertices": nx3 double matrix, where n is the number of vertices. Each row contains the x,y,z coordinates of a single vertex. "faces": nx3 integer matrix. Each row contains the vertex indices of the 3 vertices defining the face. WARNING: The indices are returned starting with index 1 (as used in GNU R). Keep in mind that you need to adjust the index (by substracting 1) to compare with data from other software.
This is by far not a complete VTK format reader. Files that store
streamlines instead of a mesh (i.e., that contain a LINES section) are read
with read.fs.tracts.vtk.
Other mesh functions:
faces.quad.to.tris(),
read.fs.surface(),
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.mesh.brainvoyager(),
read_nisurface(),
read_nisurfacefile(),
write.fs.surface(),
write.fs.surface.asc(),
write.fs.surface.byu(),
write.fs.surface.gii(),
write.fs.surface.mz3(),
write.fs.surface.vtk()
surface_file <- system.file("extdata", "cube.vtk", package = "freesurferformats", mustWork = TRUE)
mesh <- read.fs.surface.vtk(surface_file)
cat(sprintf("Read a mesh with %d vertices and %d faces.\n", nrow(mesh$vertices), nrow(mesh$faces)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.