Skip to content

Commit

Permalink
FIX: Pass sbref files to SyN workflow (#3060)
Browse files Browse the repository at this point in the history
## 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.

-->
  • Loading branch information
mgxd committed Jul 31, 2023
2 parents b5619db + e09c7b5 commit fdfb699
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 13 additions & 3 deletions 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 = fm._estimators.keys() - final_ids
for bids_id in unused_ids:
del fm._estimators[bids_id]

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 Expand Up @@ -563,8 +573,8 @@ def init_single_subject_wf(subject_id: str):
elif estimator.method == fm.EstimatorType.ANAT:
from sdcflows.workflows.fit.syn import init_syn_preprocessing_wf

sources = [str(s.path) for s in estimator.sources if s.suffix == "bold"]
source_meta = [s.metadata for s in estimator.sources if s.suffix == "bold"]
sources = [str(s.path) for s in estimator.sources if s.suffix in ("bold", "sbref")]
source_meta = [s.metadata for s in estimator.sources if s.suffix in ("bold", "sbref")]
syn_preprocessing_wf = init_syn_preprocessing_wf(
omp_nthreads=config.nipype.omp_nthreads,
debug=config.execution.sloppy,
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

# We may have pruned the estimator collection due to `--ignore fieldmaps`
estimator_key = [
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 fdfb699

Please sign in to comment.