Skip to content

Commit

Permalink
Merge pull request scilus#1117 from arnaudbore/enh_allow_extra_option…
Browse files Browse the repository at this point in the history
…s_eddy_topup

[ENH] Allow extra option for topup and eddy
  • Loading branch information
arnaudbore authored Jan 16, 2025
2 parents 736ac7e + 6008524 commit 2476ec2
Show file tree
Hide file tree
Showing 3 changed files with 13 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
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 2476ec2

Please sign in to comment.