io-vtk-streamlines {ieegio}R Documentation

Read or write streamline data in 'VTK' format

Description

This reader uses 'Python' 'vtk' package, supports '.vtk', '.vtp', '.pvtp', '.vtpb' formats.

Usage

io_read_vtk_streamlines(file)

io_write_vtk_streamlines(x, con, binary = TRUE)

Arguments

file, con

file path to the 'VTK' file, the format will be inferred from the file extension (with default '.vtk')

x

An imaging-streamlines object

binary

for legacy '.vtk' file only, whether to store the data as binary file or 'ASCII' plain text; default is true (binary).

Value

io_read_vtk_streamlines returns an imaging-streamlines object, while io_write_vtk_streamlines writes the data to file

Examples


# This example shows how to convert tck to vtk

# run `ieegio_sample_data("streamlines/CNVII_R.tck")` to
# download sample data

if( ieegio_sample_data("streamlines/CNVII_R.tck", test = TRUE) ) {

  path <- ieegio_sample_data("streamlines/CNVII_R.tck")

  streamlines <- as_ieegio_streamlines(path)

  # write to vtk
  tfile <- tempfile(fileext = ".vtk")
  io_write_vtk_streamlines(streamlines, con = tfile)

  # read
  vtk_streamlines <- io_read_vtk_streamlines(tfile)

  # compare
  plot(streamlines)
  plot(vtk_streamlines)

  # 0 0
  range(streamlines[[1]]$coords - vtk_streamlines[[1]]$coords)

}



[Package ieegio version 0.0.5 Index]