write.dti.bvec: Write b-vectors to a FSL-style bvecs file.

View source: R/write_dwi_gradients.R

write.dti.bvecR Documentation

Write b-vectors to a FSL-style bvecs file.

Description

Writes the diffusion gradient directions of a diffusion MRI dataset to a plain text file, which is the bvecs part of the FSL bvecs/bvals format. Note that these vectors are interpreted relative to the image axes, so the file is only meaningful together with the image it was derived from.

Usage

write.dti.bvec(filepath, bvec, layout = "components")

Arguments

filepath

character string, path to the output file. The conventional extension is .bvec or .bvecs, but that is not enforced. Files ending in .gz are gzip-compressed.

bvec

numeric matrix with 3 columns (one row per volume) or 3 rows (one column per volume), the gradient direction of each volume.

layout

character string, one of 'components' or 'volumes'. components (the default) writes the file with 3 lines, one per vector component, which is the FSL layout, while volumes writes one volume per line, which is what the Human Connectome Project distributes.

Value

NULL, invisibly. Called for the side effect of writing the file.

Note

A square 3x3 input is ambiguous. Since a matrix passed in memory follows the R convention of one row per volume, the rows are written as the volumes here; read.dti.bvec assumes the components for a square file, so reading such a file back yields the transposed matrix and warns about the ambiguity.

See Also

Other dti functions: read.dti.bval(), read.dti.bvec(), read.dti.grad(), read.dti.gradients(), write.dti.bval(), write.dti.grad()


freesurferformats documentation built on Sept. 25, 2026, 1:07 a.m.