From fb8e07ab2685d20b026ba3aaa3b522aa6e9e0eaf Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 14 Jul 2023 14:14:23 -0400 Subject: [PATCH 1/3] FIX: Pass sbref files to SyN workflow --- fmriprep/workflows/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fmriprep/workflows/base.py b/fmriprep/workflows/base.py index a27a04157..39170935a 100644 --- a/fmriprep/workflows/base.py +++ b/fmriprep/workflows/base.py @@ -563,8 +563,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, From b574f6265c7227266dc890819332f7f9b4ad6e80 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Sun, 30 Jul 2023 14:02:36 -0400 Subject: [PATCH 2/3] FIX: Prune fieldmap list when ignoring fieldmaps --- fmriprep/workflows/base.py | 12 +++++++++++- fmriprep/workflows/bold/base.py | 9 ++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/fmriprep/workflows/base.py b/fmriprep/workflows/base.py index 39170935a..edb57edfb 100644 --- a/fmriprep/workflows/base.py +++ b/fmriprep/workflows/base.py @@ -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] + 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]}." ) diff --git a/fmriprep/workflows/bold/base.py b/fmriprep/workflows/bold/base.py index ab6cdc1ee..aabe49c9e 100644 --- a/fmriprep/workflows/bold/base.py +++ b/fmriprep/workflows/bold/base.py @@ -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 From e09c7b54f2bd5d425ff56879602b41ff4eaa8948 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Mon, 31 Jul 2023 10:26:56 -0400 Subject: [PATCH 3/3] Update fmriprep/workflows/base.py --- fmriprep/workflows/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmriprep/workflows/base.py b/fmriprep/workflows/base.py index edb57edfb..44368f1d4 100644 --- a/fmriprep/workflows/base.py +++ b/fmriprep/workflows/base.py @@ -435,7 +435,7 @@ def init_single_subject_wf(subject_id: str): # 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] + unused_ids = fm._estimators.keys() - final_ids for bids_id in unused_ids: del fm._estimators[bids_id]