Expand description
DWI gradient table parsing (.bval and .bvec files).
BIDS diffusion-weighted imaging stores gradient information in two companion files alongside the NIfTI image:
_dwi.bval— b-values, one per volume, whitespace-separated_dwi.bvec— gradient directions, 3 rows × N columns
This module parses both files into typed structures.
§Example
use std::path::Path;
use bids_io::gradient::{read_bvals, read_bvecs, GradientTable};
let bvals = read_bvals(Path::new("sub-01_dwi.bval")).unwrap();
let bvecs = read_bvecs(Path::new("sub-01_dwi.bvec")).unwrap();
let table = GradientTable::new(bvals, bvecs).unwrap();
println!("{} volumes, {} non-zero", table.n_volumes(), table.n_diffusion_volumes());
for (i, (bval, dir)) in table.iter().enumerate() {
println!("vol {i}: b={bval:.0}, dir=[{:.3}, {:.3}, {:.3}]", dir[0], dir[1], dir[2]);
}Structs§
- Gradient
Table - Combined b-value + b-vector gradient table for a DWI acquisition.
Functions§
- read_
bvals - Read a
.bvalfile — whitespace-separated b-values on one or more lines. - read_
bvecs - Read a
.bvecfile — 3 rows of whitespace-separated values (x, y, z directions).