diff --git a/sdcflows/workflows/base.py b/sdcflows/workflows/base.py index 20f7e4e7aa..7c9c609d10 100644 --- a/sdcflows/workflows/base.py +++ b/sdcflows/workflows/base.py @@ -87,11 +87,15 @@ def init_fmap_preproc_wf( workflow = Workflow(name=name) - out_fields = ("fmap", "fmap_ref", "fmap_coeff", "fmap_mask", "fmap_id", "method") + out_fields = ("fmap", "fmap_coeff", "fmap_ref", "fmap_mask", "fmap_id", "method") out_merge = { f: pe.Node(niu.Merge(len(estimators)), name=f"out_merge_{f}") for f in out_fields } + # Fieldmaps and coefficient files can come in pairs, ensure they are not flattened + out_merge["fmap"].inputs.no_flatten = True + out_merge["fmap_coeff"].inputs.no_flatten = True + outputnode = pe.Node(niu.IdentityInterface(fields=out_fields), name="outputnode") workflow.connect( diff --git a/sdcflows/workflows/tests/test_base.py b/sdcflows/workflows/tests/test_base.py index f9f48a5440..97bf753ed3 100644 --- a/sdcflows/workflows/tests/test_base.py +++ b/sdcflows/workflows/tests/test_base.py @@ -62,5 +62,15 @@ def test_fmap_wf(tmpdir, workdir, outdir, bids_layouts, dataset, subject): if workdir: wf.base_dir = str(workdir) - if os.getenv("GITHUB_ACTIONS") != "true": - wf.run(plugin="Linear") + if os.getenv("GITHUB_ACTIONS") == "true": + return + + res = wf.run(plugin="Linear") + + # Regression test for when out_merge_fmap_coeff was flattened and would + # have twice as many elements as the other nodes + assert all( + len(node.result.outputs.out) == len(estimators) + for node in res.nodes + if node.name.startswith("out_merge_") + )