I was hoping someone could let me know why the following toy example throws an error running the first join node
from nipype.pipeline.engine import Workflow, Node, JoinNode
from nipype.interfaces.utility import IdentityInterface
workflow = Workflow('test_workflow')
subjects = Node(
name='subjects',
interface=IdentityInterface(
fields=['subject_id']))
subjects.iterables = ('subject_id', ['subject1', 'subject2', 'subject3'])
visits = Node(
name='visits',
interface=IdentityInterface(
fields=['visit_id']))
visits.iterables = ('visit_id', ['visit1', 'visit2'])
sessions = Node(
name='sessions',
interface=IdentityInterface(
fields=['subject_id', 'visit_id']))
join_subjects = JoinNode(
name='join_subjects',
interface=IdentityInterface(
fields=['subject_ids', 'visit_ids']),
joinsource='subjects',
joinfield=['subject_ids', 'visit_ids'])
join_visits = JoinNode(
name='join_visits',
interface=IdentityInterface(
fields=['subject_ids', 'visit_ids']),
joinsource='visits',
joinfield=['subject_ids', 'visit_ids'])
workflow.connect(subjects, 'subject_id', sessions, 'subject_id')
workflow.connect(visits, 'visit_id', sessions, 'visit_id')
workflow.connect(sessions, 'subject_id', join_subjects, 'subject_ids')
workflow.connect(sessions, 'visit_id', join_subjects, 'visit_ids')
workflow.connect(join_subjects, 'subject_id', join_visits, 'subject_ids')
workflow.connect(join_subjects, 'visit_id', join_visits, 'visit_ids')
result = workflow.run()
gives the error
Traceback (most recent call last):
File "/Users/tclose/git/ni/nipype/nipype/pipeline/plugins/linear.py", line 48, in run
node.run(updatehash=updatehash)
File "/Users/tclose/git/ni/nipype/nipype/pipeline/engine/nodes.py", line 472, in run
result = self._run_interface(execute=True)
File "/Users/tclose/git/ni/nipype/nipype/pipeline/engine/nodes.py", line 563, in _run_interface
return self._run_command(execute)
File "/Users/tclose/git/ni/nipype/nipype/pipeline/engine/nodes.py", line 888, in _run_command
self._collate_join_field_inputs()
File "/Users/tclose/git/ni/nipype/nipype/pipeline/engine/nodes.py", line 898, in _collate_join_field_inputs
val = self._collate_input_value(field)
File "/Users/tclose/git/ni/nipype/nipype/pipeline/engine/nodes.py", line 928, in _collate_input_value
for idx in range(self._next_slot_index)
File "/Users/tclose/git/ni/nipype/nipype/pipeline/engine/nodes.py", line 928, in <listcomp>
for idx in range(self._next_slot_index)
File "/Users/tclose/git/ni/nipype/nipype/pipeline/engine/nodes.py", line 947, in _slot_value
field, index, e))
AttributeError: The join node test_workflow.join_subjects does not have a slot field visit_idsJ2 to hold the visit_ids value at index 1: 'DynamicTraitedSpec' object has no attribute 'visit_idsJ2'
I was expecting the combination of subjects and visits iterables in the sessions node would result in 6 nodes when the workflow is run, one for each subject/visit ID pair, and that these pairs would then be combined into a list of lists over the two join nodes.