Creating a workflow - nipype

I’ve just started using Nipype and I’m running into problems setting up a workflow

I created two nodes,
E = Node(EddyCorrect(in_file=‘dat.nii.gz’, out_file=‘dat2.nii.gz’),name=‘E’)
B = Node(BET(out_file=‘dat2_brain.nii.gz’),name=‘B’)

and the workflow,
wf = Workflow(name=“wf”)
wf.connect([ (E,B [(‘out_file’,‘in_file’)]) ])

I thought this would pass out_file to the BET node, so I could perform BET on the corrected image.

But I get this error:
TypeError: ‘Node’ object has no attribute ‘getitem

I’m probably using the wf.connect wrong, but I don’t know why.

Any help would be appreciated.

In the wf.connect line you’re missing comma after B. Also, you probably want to pass "eddy_corrected" (instead of "out_file"). This is the only output EddyCorrect has.

Try: wf.connect([(E,B, [("eddy_corrected","in_file")])])

Also it is always a good idea to specify base_dir when you are using Workflow. Otherwise the output will be in temporary directories, so you should always wf = Workflow(name=“wf”, base_dir="/absolute/path/to/output")

Thank you very much djarecka. It’s working very well now!

1 Like