Skip to content

Commit 03b0302

Browse files
committed
fix: update the --output-spaces option to be more consistent
with fmriprep 20 and with the objectives of dmriprep.
1 parent 3496a2e commit 03b0302

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

dmriprep/cli/run.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def check_deps(workflow):
3333

3434
def get_parser():
3535
"""Build parser object."""
36-
from niworkflows.utils.spaces import Reference, SpatialReferences, OutputReferencesAction
36+
from niworkflows.utils.spaces import Reference, OutputReferencesAction
3737
from packaging.version import Version
3838
from ..__about__ import __version__
3939
from .version import check_latest, is_flagged
@@ -102,19 +102,21 @@ def get_parser():
102102
'--longitudinal', action='store_true',
103103
help='treat dataset as longitudinal - may increase runtime')
104104
g_conf.add_argument(
105-
'--output-spaces', nargs='*', action=OutputReferencesAction, default=SpatialReferences(),
105+
'--output-spaces', nargs='*', action=OutputReferencesAction,
106106
help="""\
107107
Standard and non-standard spaces to resample anatomical and functional images to. \
108108
Standard spaces may be specified by the form \
109109
``<SPACE>[:cohort-<label>][:res-<resolution>][...]``, where ``<SPACE>`` is \
110110
a keyword designating a spatial reference, and may be followed by optional, \
111111
colon-separated parameters. \
112112
Non-standard spaces imply specific orientations and sampling grids. \
113+
The default value of this flag (meaning, if the argument is not include in the command line) \
114+
is ``--output-spaces orig`` - the original space and sampling grid of the original DWI data. \
113115
Important to note, the ``res-*`` modifier does not define the resolution used for \
114-
the spatial normalization. To generate no DWI outputs, use this option without specifying \
115-
any spatial references. For further details, please check out \
116-
https://www.nipreps.org/dmriprep/en/%s/spaces.html""" % (currentv.base_version
117-
if is_release else 'latest'))
116+
the spatial normalization. To generate no DWI outputs (if that is intended for some reason), \
117+
use this option without specifying any spatial references. For further details, please check out \
118+
https://fmriprep.readthedocs.io/en/%s/spaces.html""" % (currentv.base_version
119+
if is_release else 'latest'))
118120

119121
# ANTs options
120122
g_ants = parser.add_argument_group('Specific options for ANTs registrations')
@@ -416,7 +418,11 @@ def build_workflow(opts, retval):
416418
retval['return_code'] = 1
417419
return retval
418420

419-
output_spaces = parse_spaces(opts)
421+
# Initialize --output-spaces if not defined
422+
output_spaces = opts.output_spaces
423+
if opts.output_spaces is None:
424+
from niworkflows.utils.spaces import Reference, SpatialReferences
425+
output_spaces = SpatialReferences([Reference("orig", {})])
420426

421427
# Set up some instrumental utilities
422428
run_uuid = '%s_%s' % (strftime('%Y%m%d-%H%M%S'), uuid.uuid4())
@@ -563,23 +569,6 @@ def build_workflow(opts, retval):
563569
return retval
564570

565571

566-
def parse_spaces(opts):
567-
"""Ensure the spaces are correctly parsed."""
568-
from sys import stderr
569-
from collections import OrderedDict
570-
# Set the default template to 'MNI152NLin2009cAsym'
571-
output_spaces = opts.output_spaces or OrderedDict([('MNI152NLin2009cAsym', {})])
572-
573-
FS_SPACES = set(['fsnative', 'fsaverage', 'fsaverage6', 'fsaverage5'])
574-
if opts.run_reconall and not list(FS_SPACES.intersection(output_spaces.keys())):
575-
print("""\
576-
Although ``--fs-no-reconall`` was not set (i.e., FreeSurfer is to be run), no FreeSurfer \
577-
output space (valid values are: %s) was selected. Adding default "fsaverage5" to the \
578-
list of output spaces.""" % ', '.join(FS_SPACES), file=stderr)
579-
output_spaces['fsaverage5'] = {}
580-
return output_spaces
581-
582-
583572
if __name__ == '__main__':
584573
raise RuntimeError("dmriprep/cli/run.py should not be run directly;\n"
585574
"Please `pip install` dmriprep and use the `dmriprep` command")

0 commit comments

Comments
 (0)