Learn R Programming

freesurferformats (version 1.1.0)

.canonicalize.gradient.table: Bring a gradient table into the canonical 'one row per volume' layout.

Description

Gradient tables occur in two orientations in the wild: the FSL layout, in which the first axis is the vector component (3 rows of N values for b-vectors, a single row of N values for b-values), and the volumes layout, in which each line is one volume (N rows of 3 values for b-vectors, as used by HCP, and N rows of 4 values for the MRtrix gradient table format). This helper maps both to one row per volume.

Usage

.canonicalize.gradient.table(
  m,
  n_components,
  layout,
  what,
  square_is_ambiguous = FALSE
)

Value

a numeric matrix with one row per volume and n_components columns.

Arguments

m

numeric matrix, the table as read from the file.

n_components

integer, the number of values per volume (3 for b-vectors, 4 for a gradient table, 1 for b-values).

layout

character string, one of 'auto', 'components' or 'volumes'. How to interpret the input. With 'auto' (the default), the orientation is derived from the matrix dimensions.

what

character string, a human-readable description of the data, used in the messages.

square_is_ambiguous

logical, how to handle a table that has exactly n_components rows and columns. The b-vector file reader sets this to TRUE, because for a 3x3 b-vector file the orientation cannot be decided (and the two reference implementations disagree about it). For a matrix passed in memory, and for the MRtrix gradient table, whose format defines one row per volume, the default FALSE means that the rows are read as volumes.