Skip to content

Commit

Permalink
Merge pull request #317 from effigies/fix/collate_coeffs
Browse files Browse the repository at this point in the history
FIX: Collate fieldmap coefficients into list of lists
  • Loading branch information
effigies authored Dec 9, 2022
2 parents b11551e + 16df78c commit 4b271a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion sdcflows/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 12 additions & 2 deletions sdcflows/workflows/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_")
)

0 comments on commit 4b271a5

Please sign in to comment.