Skip to content

Commit

Permalink
RF: Cast nan bvecs to 0's before checking for their length.
Browse files Browse the repository at this point in the history
  • Loading branch information
arokem committed Dec 21, 2015
1 parent 9687e2c commit 2cfdad1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dipy/core/gradients.py
Expand Up @@ -129,11 +129,11 @@ def gradient_table_from_bvals_bvecs(bvals, bvecs, b0_threshold=0, atol=1e-2,
"respectively, where N is the number of diffusion "
"gradients")

bvecs[np.isnan(bvecs)] = 0
bvecs_close_to_1 = abs(vector_norm(bvecs) - 1) <= atol
if bvecs.shape[1] != 3 or not np.all(bvecs_close_to_1[dwi_mask]):
raise ValueError("bvecs should be (N, 3), a set of N unit vectors")

bvecs = np.where(bvecs_close_to_1[:, None], bvecs, 0)
bvals = bvals * bvecs_close_to_1
gradients = bvals[:, None] * bvecs

Expand Down

0 comments on commit 2cfdad1

Please sign in to comment.