Nipype: multiparameter functions in connection strings

Hi nipype users,

Background/Use Case
I’m working to better understand MapNode and functions in connection strings, and I’ve hit a roadblock learning how to define multiparameter functions in connection strings.

Question
In the example below, how would I be able to incorporate add_y_list in a connection string?
I would like to be able to set y for the function without calling the function, the example below is not correct but gets at the functionality I want:
(testnode, testnode2, [(('out1', add_y_list(y=3)), 'in2')])

I feel like this has to be a basic python thing that I just don’t know what to google to find the answer. Any pointers in the right direction are greatly appreciated.

#!/usr/bin/env python
import nipype.pipeline.engine as pe
from nipype.interfaces import utility as niu

def squared(x):
    print(str(x))
    return x**2

def add_one(x):
    return x+1

def add_one_list(num_lst):
    return [num+1 for num in num_lst]

def add_y_list(num_lst,y):
    return [num+y for num in num_lst]

# test workflow
workflow = pe.Workflow(name='test_wf')

# setup inputs
inputnode = pe.Node(niu.IdentityInterface(fields=['mylist']), name='inputnode')
inputnode.inputs.mylist = [1,2,3,4,5,6,7,8,9,10]

# make a couple nodes to test MapNode
testnode = pe.MapNode(niu.Function(input_names=['in1'], output_names=['out1'], function=squared), iterfield=['x'], name='testnode')
testnode2 = pe.MapNode(niu.Function(input_names=['in2'], output_names=['out2'], function=squared), iterfield=['x'], name='testnode2')

# where it all ends up
outputnode = pe.Node(niu.IdentityInterface(fields=['outlist']), name='outputnode')

# connect the nodes
workflow.connect([
    (inputnode, testnode, [('mylist', 'in1')]),
    (testnode, testnode2, [(('out1', add_one_list), 'in2')]),
    (testnode2, outputnode, [(('out2', add_one), 'outlist')]),
])

# execute the workflow
workflow.run()

Thanks!
James

Solution
(testnode, testnode2, [(('out1', add_y_list, 3), 'in2')])

In context

#!/usr/bin/env python
import nipype.pipeline.engine as pe
from nipype.interfaces import utility as niu

def squared(x):
    print(str(x))
    return x**2

def add_one(x):
    return x+1

def add_one_list(num_lst):
    return [num+1 for num in num_lst]

def add_y_list(num_lst,y):
    return [num+y for num in num_lst]

# test workflow
workflow = pe.Workflow(name='test_wf')

# setup inputs
inputnode = pe.Node(niu.IdentityInterface(fields=['mylist']), name='inputnode')
inputnode.inputs.mylist = [1,2,3,4,5,6,7,8,9,10]

# make a couple nodes to test MapNode
testnode = pe.MapNode(niu.Function(input_names=['in1'], output_names=['out1'], function=squared), iterfield=['x'], name='testnode')
testnode2 = pe.MapNode(niu.Function(input_names=['in2'], output_names=['out2'], function=squared), iterfield=['x'], name='testnode2')

# where it all ends up
outputnode = pe.Node(niu.IdentityInterface(fields=['outlist']), name='outputnode')

# connect the nodes
workflow.connect([
    (inputnode, testnode, [('mylist', 'in1')]),
    (testnode, testnode2, [(('out1', add_y_list, 3), 'in2')]),
    (testnode2, outputnode, [(('out2', add_one), 'outlist')]),
])

# execute the workflow
workflow.run()

I’m guessing this is standard mapping syntax, but since I’m used to list comprehension taking over instances where map would be used in python, I haven’t really touched maps in python. Hopefully this helps anyone else that has the same problem.