Passing complex outputs to the next node

28 views
Skip to first unread message

Arman Eshaghi

unread,
May 26, 2014, 3:28:45 PM5/26/14
to nipy...@googlegroups.com
Hi,

I'm wondering when the output of a node is not a simple output, how I can go about connecting the node to the next. So as an example in ANTs Atropos there are 3 outputs for posterior images, but only one output has been defined in Nipype:

    segment = pe.Node(interface = ants.Atropos(), 
                       name = 'segment') 
    segment.inputs.initialization = 'KMeans'
    segment.inputs.number_of_tissue_classes = 3
    segment.inputs.dimension = 3
    segment.inputs.out_classified_image_name = 'out_classified.nii.gz'
    segment.inputs.save_posteriors = True
    segment.inputs.posterior_formulation = 'POSTERIOR_%02d.nii.gz'

From Nipype Atropos help we will have the following outputs:

        classified_image: (an existing file name)

        posteriors: (a file name)


Now, say I want to pass only white matter segmentation, which is 'POSTERIOR_3.nii.gz' to the next node, what would you recommend to do in the following workflow connection: 

    workflow.connect([( segment, next_node,
                             [('posteriors', 'next_input)]
                             ]) 
maybe this
   
  'posteriors %(3)' 

But then I get:

    Module segment has no output called posteriors %(3)


All the best,
Arman

Augustine Koh

unread,
Jun 2, 2014, 2:30:42 AM6/2/14
to nipy...@googlegroups.com
Dear Arman,

I think the issue might be that you did not specify a filename (which is essentially a Python string if you code the nipype workflow) for the output file. Although you would eventually be connecting the outputs of segment node to another node, and you do so through the attribute name, you must also specify specific filenames for your outputs and inputs wile coding the node itself. Take a look at this page and you will see that there are inputs and outputs which are mandatory to specify. If you add in another 2 lines with 

segment.inputs.posteriors = 'filename.nii.gz'
segment.inputs.classified_image = 'filename.nii.gz'

Then things should work.

Best regards,
Augustine 

Arman Eshaghi

unread,
Jun 6, 2014, 9:49:57 AM6/6/14
to nipy...@googlegroups.com
Thanks for your response. I will respond to my own question for posterity:

Since Atropos provides a number of tissue classes (according to user defined inputs), the output is a Python list and therefore can not be readily passed to the next node. So I made another node (custom node) that takes a list and outputs the desired probability map for the next node. 


All the best,
Arman
Reply all
Reply to author
Forward
0 new messages