Skip to content

Commit

Permalink
FIX: Prune fieldmap list when ignoring fieldmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jul 30, 2023
1 parent fb8e07a commit b574f62
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 11 additions & 1 deletion fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,20 @@ def init_single_subject_wf(subject_id: str):

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

# Simplification: Unused estimators are removed from registry
# This fiddles with a private attribute, so it may break in future
# versions. However, it does mean the BOLD workflow doesn't need to
# replicate the logic that got us to the pared down set of estimators
# here.
final_ids = {fmap.bids_id for fmap in fmap_estimators}
unused_ids = [bids_id for bids_id in fm._estimators if bids_id not in final_ids]
for bids_id in unused_ids:
del fm._estimators[bids_id]

Check warning on line 440 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L437-L440

Added lines #L437 - L440 were not covered by tests

if fmap_estimators:
config.loggers.workflow.info(
"B0 field inhomogeneity map will be estimated with "
f" the following {len(fmap_estimators)} estimators: "
f"the following {len(fmap_estimators)} estimator(s): "
f"{[e.method for e in fmap_estimators]}."
)

Expand Down
9 changes: 8 additions & 1 deletion fmriprep/workflows/bold/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,14 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
config.loggers.workflow.info(sbref_msg)

if has_fieldmap:
estimator_key = get_estimator(layout, bold_file if not multiecho else bold_file[0])
from sdcflows import fieldmaps as fm

Check warning on line 292 in fmriprep/workflows/bold/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/bold/base.py#L292

Added line #L292 was not covered by tests

# We may have pruned the estimator collection due to `--ignore fieldmaps`
estimator_key = [

Check warning on line 295 in fmriprep/workflows/bold/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/bold/base.py#L295

Added line #L295 was not covered by tests
key
for key in get_estimator(layout, bold_file if not multiecho else bold_file[0])
if key in fm._estimators
]

if not estimator_key:
has_fieldmap = False
Expand Down

0 comments on commit b574f62

Please sign in to comment.