| read.fs.tracts.vtk | R Documentation |
Reads streamline (tractography) data from files in the VTK legacy format, i.e. from POLYDATA datasets that contain a LINES section. 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. This is the format that Paraview, TrackVis and DSI Studio export streamlines in. Attribute data such as scalar values per point is ignored.
read.fs.tracts.vtk(filepath)
filepath |
character string, path to the input file in VTK legacy format. |
an fs.tracts instance with the streamlines. Use
tracts[[i]] to get the n x 3 coordinate matrix of a single
streamline, and fs.tracts.lengths for the number of points of
each streamline.
Points that are not part of any streamline are dropped, because the
fs.tracts data structure stores the coordinates of the streamlines
without gaps. A warning is issued if that happens.
# The example file was written by VTK and contains 3 streamlines.
# It also has a point that is not part of any streamline, which is dropped with a warning.
tracts_file <- system.file("extdata", "tracts_v51_binary.vtk",
package = "freesurferformats", mustWork = TRUE
)
tracts <- suppressWarnings(read.fs.tracts.vtk(tracts_file))
cat(sprintf(
"Read %d streamlines with %d points.\n",
length(tracts), nrow(fs.tracts.coords(tracts))
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.