Skip to content

ENH: Do not raise error in all instances of b-vecs/vals inconsistencies #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions dmriprep/utils/vectors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities to operate on diffusion gradients."""
from .. import config
from pathlib import Path
from itertools import permutations
import nibabel as nb
Expand Down Expand Up @@ -265,7 +266,8 @@ def to_filename(self, filename, filetype="rasb"):


def normalize_gradients(bvecs, bvals, b0_threshold=B0_THRESHOLD,
bvec_norm_epsilon=BVEC_NORM_EPSILON, b_scale=True):
bvec_norm_epsilon=BVEC_NORM_EPSILON, b_scale=True,
raise_error=False):
"""
Normalize b-vectors and b-values.

Expand Down Expand Up @@ -329,9 +331,10 @@ def normalize_gradients(bvecs, bvals, b0_threshold=B0_THRESHOLD,

# Check for bval-bvec discrepancy.
if not np.all(b0s == b0_vecs):
raise ValueError(
'Inconsistent bvals and bvecs (%d, %d low-b, respectively).' %
(b0s.sum(), b0_vecs.sum()))
msg = f"Inconsistent bvals and bvecs ({b0s.sum()}, {b0_vecs.sum()} low-b, respectively)."
if raise_error:
raise ValueError(msg)
config.loggers.cli.warning(msg)

# Rescale b-vals if requested
if b_scale:
Expand Down