Skip to content

Commit

Permalink
Merge pull request #1080 from karanphil/add_test_single_shell_noddi
Browse files Browse the repository at this point in the history
Add test single shell NODDI
  • Loading branch information
EmmaRenauld authored Dec 12, 2024
2 parents 5b464ae + ae1ce8f commit 524ed37
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
7 changes: 4 additions & 3 deletions scripts/scil_NODDI_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
22 changes: 20 additions & 2 deletions scripts/tests/test_NODDI_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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

0 comments on commit 524ed37

Please sign in to comment.