Skip to content

Commit

Permalink
Merge pull request #335 from arnaudbore/update_NODDI_and_freewater
Browse files Browse the repository at this point in the history
Update NODDI and freewater
  • Loading branch information
jchoude authored Oct 14, 2020
2 parents cf9faab + 802fb96 commit 0067ba1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions scilpy/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ def check(path):
if not args.overwrite:
parser.error(
'Output directory {} isn\'t empty and some files could be '
'overwritten. Use -f option if you want to continue.'
.format(path))
'overwritten or even deleted. Use -f option if you want '
'to continue.'.format(path))
else:
for the_file in os.listdir(path):
file_path = os.path.join(path, the_file)
Expand Down
14 changes: 7 additions & 7 deletions scripts/scil_compute_NODDI.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import io
import logging
import os
import tempfile
import sys
import tempfile

import amico
from dipy.io.gradients import read_bvals_bvecs
Expand Down Expand Up @@ -47,7 +47,7 @@ def _build_arg_parser():
p.add_argument('in_bvec',
help='b-vectors filename, in FSL format (.bvec).')

p.add_argument('--in_mask',
p.add_argument('--mask',
help='Brain mask filename.')
p.add_argument('--out_dir', default="results",
help='Output directory for the NODDI results. '
Expand Down Expand Up @@ -95,9 +95,10 @@ def main():
args = parser.parse_args()

assert_inputs_exist(parser, [args.in_dwi, args.in_bval, args.in_bvec],
args.in_mask)
args.mask)

assert_output_dirs_exist_and_empty(parser, args,
os.path.join(args.out_dir, 'NODDI'),
args.out_dir,
optional=args.save_kernels)

# COMMIT has some c-level stdout and non-logging print that cannot
Expand Down Expand Up @@ -130,7 +131,7 @@ def main():
ae = amico.Evaluation('.', '.')
ae.load_data(args.in_dwi,
tmp_scheme_filename,
mask_filename=args.in_mask)
mask_filename=args.mask)
# Compute the response functions
ae.set_model("NODDI")

Expand All @@ -156,8 +157,7 @@ def main():
regenerate_kernels = True

ae.set_config('ATOMS_path', kernels_dir)
out_model_dir = os.path.join(args.out_dir, ae.model.id)
ae.set_config('OUTPUT_path', out_model_dir)
ae.set_config('OUTPUT_path', args.out_dir)
ae.generate_kernels(regenerate=regenerate_kernels)
ae.load_kernels()

Expand Down
17 changes: 9 additions & 8 deletions scripts/scil_compute_freewater.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import io
import logging
import os
import tempfile
import sys
import tempfile

import amico
from dipy.io.gradients import read_bvals_bvecs
Expand Down Expand Up @@ -47,11 +47,11 @@ def _build_arg_parser():
p.add_argument('in_bvec',
help='b-vectors filename, in FSL format (.bvec).')

p.add_argument('--in_mask',
p.add_argument('--mask',
help='Brain mask filename.')
p.add_argument('--out_dir', default="results",
help='Output directory for the Free Water results. '
'[current_directory]')
'[%(default)s]')
p.add_argument('--b_thr', type=int, default=40,
help='Limit value to consider that a b-value is on an '
'existing shell. Above this limit, the b-value is '
Expand Down Expand Up @@ -102,9 +102,11 @@ def main():
parser = _build_arg_parser()
args = parser.parse_args()

assert_inputs_exist(parser, args.in_dwi, args.in_mask)
assert_inputs_exist(parser, [args.in_dwi, args.in_bval, args.in_bvec],
args.mask)

assert_output_dirs_exist_and_empty(parser, args,
os.path.join(args.out_dir, 'FreeWater'),
args.out_dir,
optional=args.save_kernels)

# COMMIT has some c-level stdout and non-logging print that cannot
Expand Down Expand Up @@ -139,7 +141,7 @@ def main():
# Load the data
ae.load_data(args.in_dwi,
scheme_filename=tmp_scheme_filename,
mask_filename=args.in_mask)
mask_filename=args.mask)

# Compute the response functions
ae.set_model("FreeWater")
Expand Down Expand Up @@ -169,8 +171,7 @@ def main():
regenerate_kernels = True

ae.set_config('ATOMS_path', kernels_dir)
out_model_dir = os.path.join(args.out_dir, ae.model.id)
ae.set_config('OUTPUT_path', out_model_dir)
ae.set_config('OUTPUT_path', args.out_dir)
ae.generate_kernels(regenerate=regenerate_kernels)
ae.load_kernels()

Expand Down
8 changes: 4 additions & 4 deletions scripts/tests/test_compute_NODDI.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def test_execution_commit_amico(script_runner):
'dwi.bval')
in_bvec = os.path.join(get_home(), 'commit_amico',
'dwi.bvec')
in_mask = os.path.join(get_home(), 'commit_amico',
'mask.nii.gz')
mask = os.path.join(get_home(), 'commit_amico',
'mask.nii.gz')
ret = script_runner.run('scil_compute_NODDI.py', in_dwi,
in_bval, in_bvec, '--in_mask', in_mask,
'--out_dir', 'noddi/', '--b_thr', '30',
in_bval, in_bvec, '--mask', mask,
'--out_dir', 'noddi', '--b_thr', '30',
'--para_diff', '0.0017', '--iso_diff', '0.003',
'--lambda1', '0.5', '--lambda2', '0.001',
'--processes', '1')
Expand Down
8 changes: 4 additions & 4 deletions scripts/tests/test_compute_freewater.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def test_execution_commit_amico(script_runner):
'dwi.bval')
in_bvec = os.path.join(get_home(), 'commit_amico',
'dwi.bvec')
in_mask = os.path.join(get_home(), 'commit_amico',
'mask.nii.gz')
mask = os.path.join(get_home(), 'commit_amico',
'mask.nii.gz')
ret = script_runner.run('scil_compute_freewater.py', in_dwi,
in_bval, in_bvec, '--in_mask', in_mask,
'--out_dir', 'freewater/', '--b_thr', '30',
in_bval, in_bvec, '--mask', mask,
'--out_dir', 'freewater', '--b_thr', '30',
'--para_diff', '0.0015',
'--perp_diff_min', '0.0001',
'--perp_diff_max', '0.0007',
Expand Down

0 comments on commit 0067ba1

Please sign in to comment.