Skip to content

Commit

Permalink
Merge pull request #1683 from ShreyasFadnavis/csd-b0
Browse files Browse the repository at this point in the history
test for new error in IVIM
  • Loading branch information
skoudoro committed Dec 7, 2018
2 parents ca6e573 + dffcc48 commit 62d30d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dipy/data/fetcher.py
Expand Up @@ -1092,7 +1092,7 @@ def read_ivim():
fbval = pjoin(folder, 'ivim.bval')
fbvec = pjoin(folder, 'ivim.bvec')
bvals, bvecs = read_bvals_bvecs(fbval, fbvec)
gtab = gradient_table(bvals, bvecs)
gtab = gradient_table(bvals, bvecs, b0_threshold=0)
img = nib.load(fraw)
return img, gtab

Expand Down
2 changes: 1 addition & 1 deletion dipy/reconst/ivim.py
Expand Up @@ -135,7 +135,7 @@ def __init__(self, gtab, split_b_D=400.0, split_b_S0=200., bounds=None,
x_scale=[1000., 0.1, 0.001, 0.0001],
options={'gtol': 1e-15, 'ftol': 1e-15,
'eps': 1e-15, 'maxiter': 1000}):
"""
r"""
Initialize an IVIM model.
The IVIM model assumes that biological tissue includes a volume
Expand Down
17 changes: 17 additions & 0 deletions dipy/reconst/tests/test_ivim.py
Expand Up @@ -202,6 +202,23 @@ def test_with_higher_S0():
assert_array_almost_equal(ivim_fit.model_params, params2)


def test_b0_threshold_greater_than0():
"""
Added test case for default b0_threshold set to 50.
Checks if error is thrown correctly.
"""
bvals_b0t = np.array([50., 10., 20., 30., 40., 60., 80., 100.,
120., 140., 160., 180., 200., 300., 400.,
500., 600., 700., 800., 900., 1000.])
N = len(bvals_b0t)
bvecs = generate_bvecs(N)
gtab = gradient_table(bvals_b0t, bvecs.T)
with assert_raises(ValueError) as vae:
_ = IvimModel(gtab)
b0_s = "The IVIM model requires a measurement at b==0. As of "
assert b0_s in vae.exception


def test_bounds_x0():
"""
Test to check if setting bounds for signal where initial value is
Expand Down

0 comments on commit 62d30d5

Please sign in to comment.