Repeat the output of a Node as an input iterfield for a MapNode

My design is as follows:

  • Node a takes an iterfield with n input files and produces 1 output file
  • MapNode b takes an iterfield with n input files and produces n output files
  • MapNode c takes the 1 output file from a and processes it with the n output files of b to produce n new output files

Here is a minimal code example:

a = MapNode(..., iterfield=['in_file']) # output: 'out_files' (xn)
b = Node(..., iterfield=['in_file']) # output: 'out_file' (x1)
c = MapNode(..., iterfield=['in_files', 'in_file'])
wf.connect([
    (a, b, [('out_files', 'in_file']),
    (b, c, [('out_file', 'in_file']),
    (a, c, [('out_files', 'in_files'])
])

This results in the following error:

ValueError: All iterfields of a MapNode have to have the same length. 
in_file = ['/hidden-location1/file.nii']
in_files = ['/hidden-location2/file1.nii', '/hidden-location2/file2.nii', '/hidden-location2/file3.nii', '/hidden-location2/file4.nii', '/hidden-location2/file5.nii', '/hidden-location2/file6.nii', '/hidden-location2/file7.nii', '/hidden-location2/file8.nii', '/hidden-location2/file9.nii', '/hidden-location2/file10.nii']

I understand the problem, and that of course the lengths of the iterfields must match. I imagine the solution is to somehow repeat the contents of the in_file list in c so that its length matches the in_files list (where each index is just a duplicate).

Any assistance would be greatly appreciated! :slight_smile: