diff --git a/scripts/scil_NODDI_maps.py b/scripts/scil_NODDI_maps.py index 96be2f227..2d067c5ff 100755 --- a/scripts/scil_NODDI_maps.py +++ b/scripts/scil_NODDI_maps.py @@ -120,12 +120,13 @@ def main(): shells_centroids, indices_shells = identify_shells(bvals, args.tolerance, round_centroids=True) - nb_shells = len(shells_centroids) + non_b0_shells = shells_centroids[shells_centroids > args.tolerance] + nb_shells = len(non_b0_shells) if nb_shells <= 1: raise ValueError("Amico's NODDI works with data with more than one " "shell, but you seem to have single-shell data (we " - "found shells {}). Change tolerance if necessary." - .format(np.sort(shells_centroids))) + "found shell {}). Change tolerance if necessary." + .format(non_b0_shells[0])) logging.info('Will compute NODDI with AMICO on {} shells at found at {}.' .format(len(shells_centroids), np.sort(shells_centroids))) diff --git a/scripts/tests/test_NODDI_maps.py b/scripts/tests/test_NODDI_maps.py index 105bb72e6..ed7e66b9f 100644 --- a/scripts/tests/test_NODDI_maps.py +++ b/scripts/tests/test_NODDI_maps.py @@ -8,7 +8,8 @@ from scilpy.io.fetcher import fetch_data, get_testing_files_dict # If they already exist, this only takes 5 seconds (check md5sum) -fetch_data(get_testing_files_dict(), keys=['commit_amico.zip']) +fetch_data(get_testing_files_dict(), keys=['commit_amico.zip', + 'processing.zip']) tmp_dir = tempfile.TemporaryDirectory() @@ -32,5 +33,22 @@ def test_execution_commit_amico(script_runner, monkeypatch): '--out_dir', 'noddi', '--tol', '30', '--para_diff', '0.0017', '--iso_diff', '0.003', '--lambda1', '0.5', '--lambda2', '0.001', - '--processes', '1') + '--processes', '1', '-f') assert ret.success + + +def test_single_shell_fail(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + in_dwi = os.path.join(SCILPY_HOME, 'processing', + 'dwi_crop_1000.nii.gz') + in_bval = os.path.join(SCILPY_HOME, 'processing', + '1000.bval') + in_bvec = os.path.join(SCILPY_HOME, 'processing', + '1000.bvec') + ret = script_runner.run('scil_NODDI_maps.py', in_dwi, + in_bval, in_bvec, + '--out_dir', 'noddi', '--tol', '30', + '--para_diff', '0.0017', '--iso_diff', '0.003', + '--lambda1', '0.5', '--lambda2', '0.001', + '--processes', '1', '-f') + assert not ret.success