surface_to_triangles: Convert Freesurfer Surface to Triangles

Description Usage Arguments Value Examples

View source: R/convert_surface.R

Description

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

Usage

1

Arguments

infile

Input surface file

...

additional arguments to pass to convert_surface

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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::rgl.open()
  rgl::rgl.triangles(right_triangles, 
  color = rainbow(nrow(right_triangles)))
  rgl::rgl.triangles(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::rgl.open()
  rgl::rgl.triangles(left_triangles, 
  color = rainbow(nrow(left_triangles)))
  rgl::rgl.triangles(right_triangles, 
  color = rainbow(nrow(right_triangles)))   
} 
}

Example output



freesurfer documentation built on Dec. 9, 2020, 1:07 a.m.