Skip to content

Commit 881993e

Browse files
committed
fix: bug identified by @mgxd on edge --output-spaces cases
1 parent 8dc07e2 commit 881993e

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

fmriprep/cli/parser.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _bids_filter(value):
142142
'option is not enabled, standard EPI-T1 coregistration is performed '
143143
'using the middle echo.')
144144
g_conf.add_argument(
145-
'--output-spaces', nargs='+', action=OutputReferencesAction, default=SpatialReferences(),
145+
'--output-spaces', nargs='*', action=OutputReferencesAction,
146146
help="""\
147147
Standard and non-standard spaces to resample anatomical and functional images to. \
148148
Standard spaces may be specified by the form \
@@ -151,8 +151,8 @@ def _bids_filter(value):
151151
colon-separated parameters. \
152152
Non-standard spaces imply specific orientations and sampling grids. \
153153
Important to note, the ``res-*`` modifier does not define the resolution used for \
154-
the spatial normalization.
155-
For further details, please check out \
154+
the spatial normalization. To generate no BOLD outputs, use this option without specifying \
155+
any spatial references. For further details, please check out \
156156
https://fmriprep.readthedocs.io/en/%s/spaces.html""" % (currentv.base_version
157157
if is_release else 'latest'))
158158

@@ -304,12 +304,19 @@ def _bids_filter(value):
304304
def parse_args(args=None, namespace=None):
305305
"""Parse args and run further checks on the command line."""
306306
import logging
307+
from niworkflows.utils.spaces import Reference, SpatialReferences
307308
parser = _build_parser()
308309
opts = parser.parse_args(args, namespace)
309310
config.execution.log_level = int(max(25 - 5 * opts.verbose_count, logging.DEBUG))
310311
config.from_dict(vars(opts))
311312
config.loggers.init()
312313

314+
# Initialize --output-spaces if not defined
315+
if config.execution.output_spaces is None:
316+
config.execution.output_spaces = SpatialReferences(
317+
[Reference("MNI152NLin2009cAsym", {"res": "native"})]
318+
)
319+
313320
# Retrieve logging level
314321
build_log = config.loggers.cli
315322

fmriprep/config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,22 +551,22 @@ def to_filename(filename):
551551
def init_spaces(checkpoint=True):
552552
"""Initialize the :attr:`~workflow.spaces` setting."""
553553
from niworkflows.utils.spaces import Reference, SpatialReferences
554-
spaces = execution.output_spaces
554+
spaces = execution.output_spaces or SpatialReferences()
555555
if not isinstance(spaces, SpatialReferences):
556556
spaces = SpatialReferences(
557-
[ref for s in execution.output_spaces.split(' ')
557+
[ref for s in spaces.split(' ')
558558
for ref in Reference.from_string(s)]
559559
)
560560

561+
if checkpoint and not spaces.is_cached():
562+
spaces.checkpoint()
563+
561564
# Add the default standard space if not already present (required by several sub-workflows)
562565
if "MNI152NLin2009cAsym" not in spaces.get_spaces(nonstandard=False, dim=(3,)):
563566
spaces.add(
564-
Reference("MNI152NLin2009cAsym", {"res": "native"})
567+
Reference("MNI152NLin2009cAsym", {})
565568
)
566569

567-
if checkpoint:
568-
spaces.checkpoint()
569-
570570
# Ensure user-defined spatial references for outputs are correctly parsed.
571571
# Certain options require normalization to a space not explicitly defined by users.
572572
# These spaces will not be included in the final outputs.

fmriprep/tests/test_config.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ def test_config_spaces():
3939
format_reference((s.fullname, s.spec))
4040
for s in spaces.references if s.standard and s.dim == 3
4141
]
42+
43+
config.execution.output_spaces = None
44+
config.workflow.use_aroma = False
45+
config.init_spaces()
46+
spaces = config.workflow.spaces
47+
48+
assert [str(s) for s in spaces.get_standard(full_spec=True)] == []
49+
50+
assert [
51+
format_reference((s.fullname, s.spec))
52+
for s in spaces.references if s.standard and s.dim == 3
53+
] == ['MNI152NLin2009cAsym']

0 commit comments

Comments
 (0)