Hi,
I was trying to recreate the example in the docs on the use of JoinNodes found here http://nipype.readthedocs.io/en/latest/users/joinnode_and_itersource.html with the following MWE
import os
from nipype.pipeline import engine as pe
from nipype.interfaces.base import (traits, TraitedSpec, BaseInterface)
class InputSpec(TraitedSpec):
in_file = traits.Str()
class OutputSpec(TraitedSpec):
out_file = traits.Str()
class BInputSpec(InputSpec):
m = traits.Int()
class DInputSpec(InputSpec):
n = traits.Int()
class EInputSpec(TraitedSpec):
in_files = traits.List(traits.Str())
class DummyInterface(BaseInterface):
input_spec = InputSpec
output_spec = OutputSpec
def _run_interface(self, runtime):
return runtime
def _list_outputs(self):
outputs = self.output_spec().get()
outputs['out_file'] = self.inputs.in_file
return outputs
A = C = DummyInterface
class B(DummyInterface):
input_spec = BInputSpec
class D(DummyInterface):
input_spec = DInputSpec
class E(BaseInterface):
input_spec = EInputSpec
def _run_interface(self, runtime):
return runtime
a = pe.Node(interface=A(), name="a")
a.inputs.in_file = 'a_file'
b = pe.Node(interface=B(), name="b")
b.iterables = ("m", [1, 2])
c = pe.Node(interface=C(), name="c")
d = pe.Node(interface=D(), name="d")
d.itersource = ("b", "m")
d.iterables = [("n", {1: [3, 4], 2: [5, 6]})]
my_workflow = pe.Workflow(name="my_workflow", base_dir=os.getcwd())
my_workflow.connect([(a, b, [('out_file', 'in_file')]),
(b, c, [('out_file', 'in_file')]),
(c, d, [('out_file', 'in_file')])])
e = pe.JoinNode(interface=E(), joinsource="d",
joinfield="in_files", name="e")
my_workflow.connect(d, 'out_file',
e, 'in_files')
my_workflow.run()
But the output execution logs came back with
170301-12:37:25,768 workflow INFO:
['check', 'execution', 'logging']
170301-12:37:25,865 workflow INFO:
Running serially.
170301-12:37:25,870 workflow INFO:
Executing node a in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/a
170301-12:37:25,872 workflow INFO:
Collecting precomputed outputs
170301-12:37:25,892 workflow INFO:
Executing node b.aI.a1 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_2/b
170301-12:37:25,894 workflow INFO:
Collecting precomputed outputs
170301-12:37:25,912 workflow INFO:
Executing node b.aI.a0 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_1/b
170301-12:37:25,913 workflow INFO:
Collecting precomputed outputs
170301-12:37:25,932 workflow INFO:
Executing node c.a0 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_1/c
170301-12:37:25,933 workflow INFO:
Collecting precomputed outputs
170301-12:37:25,952 workflow INFO:
Executing node d.a0.aI.a1 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_1/_n_4/d
170301-12:37:25,953 workflow INFO:
Collecting precomputed outputs
170301-12:37:25,972 workflow INFO:
Executing node d.a0.aI.a0 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_1/_n_3/d
170301-12:37:25,973 workflow INFO:
Collecting precomputed outputs
170301-12:37:26,0 workflow INFO:
Executing node e.a0 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_1/e
170301-12:37:26,49 workflow INFO:
Executing node c.a1 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_2/c
170301-12:37:26,51 workflow INFO:
Collecting precomputed outputs
170301-12:37:26,70 workflow INFO:
Executing node d.a1.aI.a0 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_2/_n_5/d
170301-12:37:26,72 workflow INFO:
Collecting precomputed outputs
170301-12:37:26,92 workflow INFO:
Executing node d.a1.aI.a1 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_2/_n_6/d
170301-12:37:26,93 workflow INFO:
Collecting precomputed outputs
170301-12:37:26,120 workflow INFO:
Executing node e.a1 in dir: /Users/tclose/git/mbi/nianalysis/scripts/my_workflow/_m_2/e
which appears to show Node āeā being executed twice for both m=1 and m=2 in contrast to the figure at the bottom of that page.
Now this execution graph was actually what I was hoping to achieve and what I would have expected a priori so I am happy about that but it seems the figure needs to be updated unless I am missing something.
Cheers,
Tom