Skip to content

Commit fdfb699

Browse files
authored
FIX: Pass sbref files to SyN workflow (#3060)
## Changes proposed in this pull request The improvements to SDC to detect sbref files and prefer them needed to come with passing sbrefs to the SyN workflow. Fixes #3046. ## Documentation that should be reviewed <!-- Please summarize here the main changes to the documentation that the reviewers should be aware of. --> <!-- Welcome, new contributors! We ask you to read through the Contributing Guide: https://github.com/nipreps/fmriprep/blob/master/CONTRIBUTING.md These are guidelines intended to make communication easier by describing a consistent process, but don't worry if you don't get it everything exactly "right" on the first try. To boil it down, here are some highlights: 1) Consider starting a conversation in the issues list before submitting a pull request. The discussion might save you a lot of time coding. 2) Please use descriptive prefixes in your pull request title, such as "ENH:" for an enhancement or "FIX:" for a bug fix. (See the Contributing guide for the full set.) And consider adding a "WIP" tag for works-in-progress. 3) Any code you submit will be licensed under the same terms (Apache License 2.0) as the rest of fMRIPrep. 4) We invite every contributor to add themselves to the `.zenodo.json` file (https://github.com/nipreps/fmriprep/blob/master/.zenodo.json), which will result in your being listed as an author at the next release. Please add yourself as the next-to-last entry, just above Russ. A pull request is a conversation. We may ask you to make some changes before accepting your PR, and likewise, you should feel free to ask us any questions you have. -->
2 parents b5619db + e09c7b5 commit fdfb699

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

fmriprep/workflows/base.py

Lines changed: 13 additions & 3 deletions
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 = fm._estimators.keys() - 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

@@ -563,8 +573,8 @@ def init_single_subject_wf(subject_id: str):
563573
elif estimator.method == fm.EstimatorType.ANAT:
564574
from sdcflows.workflows.fit.syn import init_syn_preprocessing_wf
565575

566-
sources = [str(s.path) for s in estimator.sources if s.suffix == "bold"]
567-
source_meta = [s.metadata for s in estimator.sources if s.suffix == "bold"]
576+
sources = [str(s.path) for s in estimator.sources if s.suffix in ("bold", "sbref")]
577+
source_meta = [s.metadata for s in estimator.sources if s.suffix in ("bold", "sbref")]
568578
syn_preprocessing_wf = init_syn_preprocessing_wf(
569579
omp_nthreads=config.nipype.omp_nthreads,
570580
debug=config.execution.sloppy,

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)