Nipype: accessing output from workflow iterables

Hi, I’ve read posts similar to my issue, but I believe that my situation is slightly different, so I hope I’m not repeating any other posted questions.

I have an inputnode function that iterates over two files for input into a function called afniCopy:

def i2(input_params):
inputnode=pe.Node(niu.IdentityInterface(fields=[‘in_file’]), name=“inputnode”)
funct=‘funct.nii.gz’
struct=‘struct.nii.gz’
inputnode.iterables = [(‘in_file’, [funct, struct])]
return(inputnode)

it runs successfully, and produces output in the following two directories:

in_file…subdir…another_subdir…another_subdir…results…another_subdir…funct.nii.gz

in_file…subdir…another_subdir…another_subdir…results…another_subdir…struct.nii.gz


I need to be able to use the outfile from each directory as two separate inputs to another node.

Is there any way that I can access the outfile from each directory using its unique Exec ID (afniCopy.a0 and afniCopy.a1)?

Thanks very much

for iterables you will have to first use a joinnode to bring them back together and then if you want to send it to two different inputs, you will either have to use the split interface or the connection using an inline function.

iterable_node --> sub graph --> join_node --> split interface
(the nipype tutorial walks through the join node example).

this is the alternative to split (generally not recommended, but can be used for lightweight functions)

def select(val, index):
    return val[index]

connect(source_node, ('out', select, 0), dest_node, 'in1')
connect(source_node, ('out', select, 1), dest_node, 'in2')

Thank you so much, @satra, for your quick reply. I knew about the joinnode, but I didn’t think to use the split interface.