read_diffusion_table

read_diffusion_table#

pypulseqpp.io.read_diffusion_table()[source]#

Read a diffusion table: one b-value and one direction per volume.

Three layouts are read, told apart by the file:

  • x y z b per row (MRtrix’s layout), b in s/mm².

  • An FSL pair, given as the .bvec path with the .bval beside it.

  • A block direction table: one or more blocks, each a line holding a count N followed by N rows x y z. directions picks the block of that count, and a row’s b-value is b_value * (x² + y² + z²), so that shorter vectors make lower shells and a zero row a b = 0 volume.

# starts a comment, and values are separated by any whitespace.

Parameters:
  • path – The table file.

  • b_value (float, default=None) – Largest b-value (s/mm²), which a block direction table’s unit vectors reach. Required for that layout and ignored otherwise.

  • directions (int, default=None) – Count of the block to read from a block direction table; may be omitted when the file holds one block.

Returns:

  • b (numpy.ndarray) – (volumes,), s/mm².

  • g (numpy.ndarray) – (volumes, 3), unit directions along the sequence’s gradient channels x, y and z, and zero where b is zero. Those channels turn with the prescription, so the directions are in its logical frame.

Raises:

ValueError – If the file matches none of the layouts, a block direction table is read without b_value, or no block has directions rows.