Skip to content

Instantly share code, notes, and snippets.

@satra
Created October 8, 2014 16:28
Show Gist options
  • Save satra/a6e2d373671867b4977c to your computer and use it in GitHub Desktop.
Save satra/a6e2d373671867b4977c to your computer and use it in GitHub Desktop.
passing pythonic outputs in nipype
from nipype import Workflow, Node, Function
def myrandomfunc(N):
import numpy as np
return np.random.random_integers(1, 10, N)
def mysumfunc(X):
return X.sum()
wf = Workflow(name='test')
node1 = Node(Function(input_names='N', output_names='out', function=myrandomfunc),
name='randomgenerator')
node2 = Node(Function(input_names='X', output_names='out', function=mysumfunc),
name='add')
wf.connect(node1, 'out', node2, 'X')
node1.inputs.N = 10
eg = wf.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment