Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentBeaud authored Jan 17, 2025
2 parents 9c7b861 + 2476ec2 commit 964e629
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
13 changes: 10 additions & 3 deletions scilpy/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ def save_matrix_in_any_format(filepath, output_data):
raise ValueError('Extension {} is not supported'.format(ext))


def assert_fsl_options_exist(parser, options_args, command):
def assert_fsl_options_exist(parser, options_args, command, overwrite=False):
"""
Assert that all options for topup or eddy exist.
If not, print parser's usage and exit.
Expand All @@ -1063,6 +1063,8 @@ def assert_fsl_options_exist(parser, options_args, command):
Options for fsl command
command: string
Command used (eddy or topup).
overwrite: bool
If true, will only print a warning if an option is not valid.
"""
if command == 'eddy':
fsl_options = eddy_options
Expand All @@ -1078,8 +1080,13 @@ def assert_fsl_options_exist(parser, options_args, command):

for nOption in res:
if nOption not in fsl_options:
parser.error('--{} is not a valid option for '
'{} command.'.format(nOption, command))
if overwrite:
logging.warning('--{} may not be a valid option for '
'{} command depending '
'of its version.'.format(nOption, command))
else:
parser.error('--{} is not a valid option for '
'{} command.'.format(nOption, command))


def parser_color_type(arg):
Expand Down
3 changes: 3 additions & 0 deletions scripts/scil_NODDI_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
add_verbose_arg,
assert_inputs_exist,
assert_output_dirs_exist_and_empty,
assert_headers_compatible,
redirect_stdout_c, add_tolerance_arg,
add_skip_b0_check_arg)
from scilpy.gradients.bvec_bval_tools import (check_b0_threshold,
Expand Down Expand Up @@ -113,6 +114,8 @@ def main():
assert_output_dirs_exist_and_empty(parser, args, args.out_dir,
optional=args.save_kernels)

assert_headers_compatible(parser, args.in_dwi, optional=args.mask)

# Generate a scheme file from the bvals and bvecs files
bvals, _ = read_bvals_bvecs(args.in_bval, args.in_bvec)
_ = check_b0_threshold(bvals.min(), b0_thr=args.tolerance,
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_dwi_prepare_eddy_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def main():
required_args = [args.in_dwi, args.in_bvals, args.in_bvecs, args.in_mask]

assert_inputs_exist(parser, required_args)
assert_fsl_options_exist(parser, args.eddy_options, 'eddy')
assert_fsl_options_exist(parser, args.eddy_options, 'eddy', args.overwrite)

if os.path.splitext(args.out_prefix)[1] != '':
parser.error('The prefix must not contain any extension.')
Expand Down
3 changes: 2 additions & 1 deletion scripts/scil_dwi_prepare_topup_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def main():

assert_inputs_exist(parser, required_args)
assert_outputs_exist(parser, args, [], args.out_b0s)
assert_fsl_options_exist(parser, args.topup_options, 'topup')
assert_fsl_options_exist(parser, args.topup_options, 'topup',
overwrite=args.overwrite)

if os.path.splitext(args.out_prefix)[1] != '':
parser.error('The prefix must not contain any extension.')
Expand Down

0 comments on commit 964e629

Please sign in to comment.