Learn R Programming

freesurfer (version 1.6.10)

surface_to_triangles: Convert Freesurfer Surface to Triangles

Description

Reads in a surface file from Freesurfer and converts it into triangles

Usage

surface_to_triangles(infile, ...)

Value

Matrix of triangles with the number of rows equal to the number of faces (not the triplets - total faces)

Arguments

infile

Input surface file

...

additional arguments to pass to convert_surface

Examples

Run this code
if (have_fs()) {
infile = file.path(fs_subj_dir(), 
                   "bert", "surf", "rh.pial")
right_triangles = surface_to_triangles(infile = infile)
infile = file.path(fs_subj_dir(), 
                   "bert", "surf", "lh.pial")
left_triangles = surface_to_triangles(infile = infile) 
if (requireNamespace("rgl", quietly = TRUE)) {
  rgl::open3d()
  rgl::triangles3d(right_triangles, 
  color = rainbow(nrow(right_triangles)))
  rgl::triangles3d(left_triangles, 
  color = rainbow(nrow(left_triangles)))
}
infile = file.path(fs_subj_dir(), 
                   "bert", "surf", "rh.inflated")
right_triangles = surface_to_triangles(infile = infile)  
infile = file.path(fs_subj_dir(), 
                   "bert", "surf", "lh.inflated") 
left_triangles = surface_to_triangles(infile = infile)  
if (requireNamespace("rgl", quietly = TRUE)) {
  rgl::open3d()
  rgl::triangles3d(left_triangles, 
  color = rainbow(nrow(left_triangles)))
  rgl::triangles3d(right_triangles, 
  color = rainbow(nrow(right_triangles)))   
} 
}

Run the code above in your browser using DataLab