Skip to content

Commit b574f62

Browse files
committed
FIX: Prune fieldmap list when ignoring fieldmaps
1 parent fb8e07a commit b574f62

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

fmriprep/workflows/base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,20 @@ def init_single_subject_wf(subject_id: str):
429429

430430
fmap_estimators = [fmap for fmap in fmap_estimators if fmap.bids_id in used_estimators]
431431

432+
# Simplification: Unused estimators are removed from registry
433+
# This fiddles with a private attribute, so it may break in future
434+
# versions. However, it does mean the BOLD workflow doesn't need to
435+
# replicate the logic that got us to the pared down set of estimators
436+
# here.
437+
final_ids = {fmap.bids_id for fmap in fmap_estimators}
438+
unused_ids = [bids_id for bids_id in fm._estimators if bids_id not in final_ids]
439+
for bids_id in unused_ids:
440+
del fm._estimators[bids_id]
441+
432442
if fmap_estimators:
433443
config.loggers.workflow.info(
434444
"B0 field inhomogeneity map will be estimated with "
435-
f" the following {len(fmap_estimators)} estimators: "
445+
f"the following {len(fmap_estimators)} estimator(s): "
436446
f"{[e.method for e in fmap_estimators]}."
437447
)
438448

fmriprep/workflows/bold/base.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,14 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
289289
config.loggers.workflow.info(sbref_msg)
290290

291291
if has_fieldmap:
292-
estimator_key = get_estimator(layout, bold_file if not multiecho else bold_file[0])
292+
from sdcflows import fieldmaps as fm
293+
294+
# We may have pruned the estimator collection due to `--ignore fieldmaps`
295+
estimator_key = [
296+
key
297+
for key in get_estimator(layout, bold_file if not multiecho else bold_file[0])
298+
if key in fm._estimators
299+
]
293300

294301
if not estimator_key:
295302
has_fieldmap = False

0 commit comments

Comments
 (0)