Skip to contents

This function exports a bundle stored as a bundle object to a file in one of the supported formats. Supported formats include VTK (.vtk), VTP (.vtp), FDS (.fds), TRK (.trk), TCK (.tck), TRX (.trx), FIB (.fib), and DPY (.dpy). For formats that require a reference image (such as TRX, FIB, and DPY), the user must provide the path to a reference image file.

Usage

write_bundle(x, file, reference_file = NULL)

Arguments

x

A bundle object.

file

A string specifying the path to the file containing the tractography data. Currently supported files are:

  • standard VTK formats .vtk and .vtp,

  • medInria .fds format,

  • MRtrix .tck/.tsf format,

  • TrackVis .trk and .trx formats,

  • DIPY .dpy format,

  • .fib format.

reference_file

A string specifying the path to a reference image file. This is only required when importing .trx, .fib, or .dpy files, as these formats do not contain spatial information about the image space. The reference image is used to correctly position the bundle in the appropriate space. Default is NULL.

Value

The input bundle (invisibly) so that the function can be used in pipes.

Details

Warning: we rely on DIPY to provide support to save bundles in .trk, .trx, .tck, .dpy and .fib formats. Among these formats, only .trk and .trx formats are able to keep track of additional attributes assigned to either streamlines or points.

See also

read_bundle() to import bundles into R.

Examples

uf_left  <- read_bundle(system.file("extdata", "UF_left.vtp",  package = "riot"))
#> Number of data points: 38697
#> Number of streamlines: 2042
#> v The bundle stored in /home/runner/work/_temp/Library/riot/extdata/UF_left.vtp has been successfully imported.
if (FALSE) { # \dontrun{
out <- fs::file_temp(ext = ".vtp")
write_bundle(uf_left, file = out)
} # }