Skip to content

Commit

Permalink
Merge pull request #2692 from effigies/fix/multi_syn_atlases
Browse files Browse the repository at this point in the history
FIX: Create single fmap_select_std node for use with all ANAT estimators
  • Loading branch information
effigies authored Jan 20, 2022
2 parents 2530ea8 + f68ece8 commit 32dac40
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,25 @@ def init_single_subject_wf(subject_id):
if node.split(".")[-1].startswith("ds_"):
fmap_wf.get_node(node).interface.out_path_base = ""

# Step 3: Manually connect PEPOLAR
# Step 3: Manually connect PEPOLAR and ANAT workflows

# Select "MNI152NLin2009cAsym" from standard references.
# This node may be used by multiple ANAT estimators, so define outside loop.
from niworkflows.interfaces.utility import KeySelect
fmap_select_std = pe.Node(
KeySelect(fields=["std2anat_xfm"], key="MNI152NLin2009cAsym"),
name="fmap_select_std",
run_without_submitting=True,
)
if any(estimator.method == fm.EstimatorType.ANAT for estimator in fmap_estimators):
# fmt:off
workflow.connect([
(anat_preproc_wf, fmap_select_std, [
("outputnode.std2anat_xfm", "std2anat_xfm"),
("outputnode.template", "keys")]),
])
# fmt:on

for estimator in fmap_estimators:
config.loggers.workflow.info(f"""\
Setting-up fieldmap "{estimator.bids_id}" ({estimator.method}) with \
Expand All @@ -455,7 +473,6 @@ def init_single_subject_wf(subject_id):
)

elif estimator.method == fm.EstimatorType.ANAT:
from niworkflows.interfaces.utility import KeySelect
from sdcflows.workflows.fit.syn import init_syn_preprocessing_wf

sources = [str(s.path) for s in estimator.sources if s.suffix == "bold"]
Expand All @@ -470,18 +487,8 @@ def init_single_subject_wf(subject_id):
syn_preprocessing_wf.inputs.inputnode.in_epis = sources
syn_preprocessing_wf.inputs.inputnode.in_meta = source_meta

# Select "MNI152NLin2009cAsym" from standard references.
fmap_select_std = pe.Node(
KeySelect(fields=["std2anat_xfm"], key="MNI152NLin2009cAsym"),
name="fmap_select_std",
run_without_submitting=True,
)

# fmt:off
workflow.connect([
(anat_preproc_wf, fmap_select_std, [
("outputnode.std2anat_xfm", "std2anat_xfm"),
("outputnode.template", "keys")]),
(anat_preproc_wf, syn_preprocessing_wf, [
("outputnode.t1w_preproc", "inputnode.in_anat"),
("outputnode.t1w_mask", "inputnode.mask_anat"),
Expand Down

0 comments on commit 32dac40

Please sign in to comment.