Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Remove deprecated command-line arguments #1909

Merged
merged 6 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,8 @@ jobs:
--config $PWD/nipype.cfg -w /tmp/ds210/work \
/tmp/data/ds210 /tmp/ds210/derivatives participant \
--fs-no-reconall --t2s-coreg --use-syn-sdc \
--template-resampling-grid native --dummy-scans 1 \
--sloppy --write-graph --mem_mb 4096 --nthreads 2 -vv
--dummy-scans 1 --sloppy --write-graph \
--mem_mb 4096 --nthreads 2 -vv
- run:
name: Checking outputs of fMRIPrep
command: |
Expand Down
71 changes: 2 additions & 69 deletions fmriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ def get_parser():
help='run anatomical workflows only')
g_perfm.add_argument('--boilerplate', action='store_true',
help='generate boilerplate only')
g_perfm.add_argument('--ignore-aroma-denoising-errors', action='store_true',
default=False,
help='DEPRECATED (now does nothing, see --error-on-aroma-warnings) '
'- ignores the errors ICA_AROMA returns when there are no '
'components classified as either noise or signal')
g_perfm.add_argument('--md-only-boilerplate', action='store_true',
default=False,
help='skip generation of HTML and LaTeX formatted citation with pandoc')
Expand All @@ -122,8 +117,6 @@ def get_parser():
'(e.g., if all the components are classified as signal or noise)')
g_perfm.add_argument("-v", "--verbose", dest="verbose_count", action="count", default=0,
help="increases log verbosity for each occurence, debug level is -vvv")
g_perfm.add_argument('--debug', action='store_true', default=False,
help='DEPRECATED - Does not do what you want.')

g_conf = parser.add_argument_group('Workflow configuration')
g_conf.add_argument(
Expand Down Expand Up @@ -157,26 +150,6 @@ def get_parser():
', '.join('"%s"' % s for s in templates()), ', '.join(NONSTANDARD_REFERENCES),
currentv.base_version if is_release else 'latest'))

g_conf.add_argument(
'--output-space', required=False, action='store', type=str, nargs='+',
choices=['T1w', 'template', 'fsnative', 'fsaverage', 'fsaverage6', 'fsaverage5'],
help='DEPRECATED: please use ``--output-spaces`` instead.'
)
g_conf.add_argument(
'--template', required=False, action='store', type=str,
choices=['MNI152NLin2009cAsym'],
help='volume template space (default: MNI152NLin2009cAsym). '
'DEPRECATED: please use ``--output-spaces`` instead.')
g_conf.add_argument(
'--template-resampling-grid', required=False, action='store',
help='Keyword ("native", "1mm", or "2mm") or path to an existing file. '
'Allows to define a reference grid for the resampling of BOLD images in template '
'space. Keyword "native" will use the original BOLD grid as reference. '
'Keywords "1mm" and "2mm" will use the corresponding isotropic template '
'resolutions. If a path is given, the grid of that image will be used. '
'It determines the field of view and resolution of the output images, '
'but is not used in normalization. '
'DEPRECATED: please use ``--output-spaces`` instead.')
g_conf.add_argument('--bold2t1w-dof', action='store', default=6, choices=[6, 9, 12], type=int,
help='Degrees of freedom when registering BOLD to T1w images. '
'6 degrees (rotation and translation) are used by default.')
Expand Down Expand Up @@ -261,11 +234,9 @@ def get_parser():
g_surfs_xor = g_surfs.add_mutually_exclusive_group()
g_surfs_xor.add_argument('--cifti-output', action='store_true', default=False,
help='output BOLD files as CIFTI dtseries')
g_surfs_xor.add_argument('--fs-no-reconall', '--no-freesurfer',
g_surfs_xor.add_argument('--fs-no-reconall',
action='store_false', dest='run_reconall',
help='disable FreeSurfer surface preprocessing.'
' Note : `--no-freesurfer` is deprecated and will be removed in 1.2.'
' Use `--fs-no-reconall` instead.')
help='disable FreeSurfer surface preprocessing.')

g_other = parser.add_argument_group('Other options')
g_other.add_argument('-w', '--work-dir', action='store', type=Path, default=Path('work'),
Expand Down Expand Up @@ -340,10 +311,6 @@ def main():
from ..utils.sentry import sentry_setup
sentry_setup(opts, exec_env)

if opts.debug:
print('WARNING: Option --debug is deprecated and has no effect',
file=sys.stderr)

# Validate inputs
if not opts.skip_bids_validation:
print("Making sure the input data is BIDS compliant (warnings can be ignored in most "
Expand Down Expand Up @@ -730,34 +697,9 @@ def parse_spaces(opts):
"""Ensures the spaces are correctly parsed"""
from sys import stderr
from collections import OrderedDict
from templateflow.api import templates as get_templates
# Set the default template to 'MNI152NLin2009cAsym'
output_spaces = opts.output_spaces or OrderedDict([('MNI152NLin2009cAsym', {})])

if opts.template:
print("""\
The ``--template`` option has been deprecated in version 1.4.0. Your selected template \
"%s" will be inserted at the front of the ``--output-spaces`` argument list. Please update \
your scripts to use ``--output-spaces``.""" % opts.template, file=stderr)
deprecated_tpl_arg = [(opts.template, {})]
# If output_spaces is not set, just replate the default - append otherwise
if opts.output_spaces is not None:
deprecated_tpl_arg += list(output_spaces.items())
output_spaces = OrderedDict(deprecated_tpl_arg)

if opts.output_space:
print("""\
The ``--output_space`` option has been deprecated in version 1.4.0. Your selection of spaces \
"%s" will be inserted at the front of the ``--output-spaces`` argument list. Please update \
your scripts to use ``--output-spaces``.""" % ', '.join(opts.output_space), file=stderr)
missing = set(opts.output_space)
if 'template' in missing:
missing.remove('template')
if not opts.template:
missing.add('MNI152NLin2009cAsym')
missing = missing - set(output_spaces.keys())
output_spaces.update({tpl: {} for tpl in missing})

FS_SPACES = set(['fsnative', 'fsaverage', 'fsaverage6', 'fsaverage5'])
if opts.run_reconall and not list(FS_SPACES.intersection(output_spaces.keys())):
print("""\
Expand Down Expand Up @@ -787,15 +729,6 @@ def parse_spaces(opts):
``fsaverage`` space. The argument ``fsaverage:den-10k`` (a.k.a ``fsaverage5``) has been \
automatically added to the list of output spaces (option ``--output-space``).""", file=stderr)

if opts.template_resampling_grid is not None:
print("""Option ``--template-resampling-grid`` is deprecated, please specify \
resampling grid options as modifiers to templates listed in ``--output-spaces``. \
The configuration value will be applied to ALL output standard spaces.""")
if opts.template_resampling_grid != 'native':
for key in output_spaces.keys():
if key in get_templates():
output_spaces[key]['res'] = opts.template_resampling_grid[0]

return output_spaces


Expand Down
2 changes: 1 addition & 1 deletion fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def init_single_subject_wf(
('outputnode.joint_template', 'inputnode.joint_template'),
('outputnode.joint_anat2std_xfm', 'inputnode.joint_anat2std_xfm'),
('outputnode.joint_std2anat_xfm', 'inputnode.joint_std2anat_xfm'),
# Undefined if --no-freesurfer, but this is safe
# Undefined if --fs-no-reconall, but this is safe
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
('outputnode.subject_id', 'inputnode.subject_id'),
('outputnode.t1w2fsnative_xfm', 'inputnode.t1w2fsnative_xfm'),
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/workflows/bold/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def init_func_preproc_wf(
(inputnode, bold_reg_wf, [
('t1w_brain', 'inputnode.t1w_brain'),
('t1w_dseg', 'inputnode.t1w_dseg'),
# Undefined if --no-freesurfer, but this is safe
# Undefined if --fs-no-reconall, but this is safe
('subjects_dir', 'inputnode.subjects_dir'),
('subject_id', 'inputnode.subject_id'),
('fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm')]),
Expand Down
71 changes: 48 additions & 23 deletions wrapper/fmriprep_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os
import re
import subprocess
from warnings import warn

__version__ = '99.99.99'
__copyright__ = 'Copyright 2019, Center for Reproducible Neuroscience, Stanford University'
Expand All @@ -31,6 +30,30 @@
Image '{}' is missing
Would you like to download? [Y/n] """
PKG_PATH = '/usr/local/miniconda/lib/python3.7/site-packages'
TF_TEMPLATES = (
'MNI152Lin',
'MNI152NLin2009cAsym',
'MNI152NLin6Asym',
'MNI152NLin6Sym',
'MNIInfant',
'MNIPediatricAsym',
'NKI',
'OASIS30ANTs',
'PNC',
'UNCInfant',
'fsLR',
'fsaverage',
'fsaverage5',
'fsaverage6',
)
NONSTANDARD_REFERENCES = (
'anat',
'T1w',
'run',
'func',
'sbref',
'fsnative'
)

# Monkey-patch Py2 subprocess
if not hasattr(subprocess, 'DEVNULL'):
Expand Down Expand Up @@ -141,7 +164,7 @@ def merge_help(wrapper_help, target_help):

# Make sure we're not clobbering options we don't mean to
overlap = set(w_flags).intersection(t_flags)
expected_overlap = set(['h', 'version', 'w', 'template-resampling-grid',
expected_overlap = set(['h', 'version', 'w', 'output-spaces',
'fs-license-file', 'fs-subjects-dir', 'use-plugin'])

assert overlap == expected_overlap, "Clobbering options: {}".format(
Expand Down Expand Up @@ -226,17 +249,19 @@ def get_parser():
g_wrap.add_argument('-w', '--work-dir', action='store', type=os.path.abspath,
help='path where intermediate results should be stored')
g_wrap.add_argument(
'--output-grid-reference', required=False, action='store', type=os.path.abspath,
help='Deprecated after FMRIPREP 1.0.8. Please use --template-resampling-grid instead.')
g_wrap.add_argument(
'--template-resampling-grid', required=False, action='store', type=str,
help='Keyword ("native", "1mm", or "2mm") or path to an existing file. '
'Allows to define a reference grid for the resampling of BOLD images in template '
'space. Keyword "native" will use the original BOLD grid as reference. '
'Keywords "1mm" and "2mm" will use the corresponding isotropic template '
'resolutions. If a path is given, the grid of that image will be used. '
'It determines the field of view and resolution of the output images, '
'but is not used in normalization.')
'--output-spaces', nargs="+",
help="""\
Standard and non-standard spaces to resample anatomical and functional images to. \
Standard spaces may be specified by the form \
``<TEMPLATE>[:res-<resolution>][:cohort-<label>][...]``, where ``<TEMPLATE>`` is \
a keyword (valid keywords: %s) or path pointing to a user-supplied template, and \
may be followed by optional, colon-separated parameters. \
Non-standard spaces (valid keywords: %s) imply specific orientations and sampling \
grids. \
Important to note, the ``res-*`` modifier does not define the resolution used for \
the spatial normalization.""" % (', '.join('"%s"' % s for s in TF_TEMPLATES),
', '.join(NONSTANDARD_REFERENCES)))

g_wrap.add_argument(
'--fs-license-file', metavar='PATH', type=os.path.abspath,
default=os.getenv('FS_LICENSE', None),
Expand Down Expand Up @@ -395,16 +420,16 @@ def main():
'ro'))])
unknown_args.extend(['--use-plugin', '/tmp/plugin.yml'])

template_target = opts.template_resampling_grid or opts.output_grid_reference
if template_target is not None:
if opts.output_grid_reference is not None:
warn('Option --output-grid-reference is deprecated, please use '
'--template-resampling-grid', DeprecationWarning)
if template_target not in ['native', '2mm' '1mm']:
target = '/imports/' + os.path.basename(template_target)
command.extend(['-v', ':'.join((os.path.abspath(
template_target), target, 'ro'))])
unknown_args.extend(['--template-resampling-grid', template_target])
if opts.output_spaces:
spaces = []
for space in opts.output_spaces:
if space.split(':')[0] not in (TF_TEMPLATES + NONSTANDARD_REFERENCES):
target = '/imports/' + os.path.basename(space)
command.extend(['-v', ':'.join((os.path.abspath(space), target, 'ro'))])
spaces.append(target)
else:
spaces.append(space)
unknown_args.extend(['--output-spaces'] + spaces)

if opts.shell:
command.append('--entrypoint=bash')
Expand Down