scil_gradients_validate_correct.py

usage: __main__.py [-h] [--mask MASK] [--fa_threshold FA_THRESHOLD]
                   [--column_wise] [-v [{DEBUG,INFO,WARNING}]] [-f]
                   in_bvec in_peaks in_FA out_bvec

Detect sign flips and/or axes swaps in the gradients table from a fiber
coherence index [1]. The script takes as input the principal direction(s)
at each voxel, the b-vectors and the fractional anisotropy map and outputs
a corrected b-vectors file.

A typical pipeline could be:
>>> scil_dti_metrics.py dwi.nii.gz bval bvec --not_all --fa fa.nii.gz
    --evecs peaks.nii.gz
>>> scil_gradients_validate_correct.py bvec peaks_v1.nii.gz fa.nii.gz bvec_corr

Note that peaks_v1.nii.gz is the file containing the direction associated
to the highest eigenvalue at each voxel.

It is also possible to use a file containing multiple principal directions per
voxel, given that they are sorted by decreasing amplitude. In that case, the
first direction (with the highest amplitude) will be chosen for validation.
Only 4D data is supported, so the directions must be stored in a single
dimension. For example, peaks.nii.gz from scil_fodf_metrics.py could be used.

Formerly: scil_validate_and_correct_bvecs.py

positional arguments:
  in_bvec               Path to bvec file.
  in_peaks              Path to peaks file.
  in_FA                 Path to the fractional anisotropy file.
  out_bvec              Path to corrected bvec file (FSL format).

options:
  -h, --help            show this help message and exit
  --mask MASK           Path to an optional mask. If set, FA and Peaks will only be used inside the mask.
  --fa_threshold FA_THRESHOLD
                        FA threshold. Only voxels with FA higher than fa_threshold will be considered. [0.2]
  --column_wise         Specify if input peaks are column-wise (..., 3, N) instead of row-wise (..., N, 3).
  -v [{DEBUG,INFO,WARNING}]
                        Produces verbose output depending on the provided level.
                        Default level is warning, default when using -v is info.
  -f                    Force overwriting of the output files.

[1] Schilling KG, Yeh FC, Nath V, Hansen C, Williams O, Resnick S, Anderson AW,
Landman BA. A fiber coherence index for quality control of B-table orientation
in diffusion MRI scans. Magn Reson Imaging. 2019 May;58:82-89.
doi: 10.1016/j.mri.2019.01.018.