ICA-AROMA: help with writing nipype wrapper

I wrote a very rough wrapper for ICA-AROMA to use in nipype, but I’m having trouble doing specific things to make sure the user uses the options correctly and handling output. The specific questions are written in the code via this pastebin. Can anyone point me in the right direction/give me advice on how to improve this code? Many thanks!


I would like to become a regular contributor to codebases like nipype, but I still have much to learn.

Hi @jdkent,

It’ll be easier if you submit a pull request on Nipype, because then we can comment directly on the code, but:

How do I format different processing streams (featdir versus manual inputs)? e.g. I want featDir to be mutually exclusive with infile,mask,affmat,warp, and mc.
…xor can make all the options mutually exclusive with eachother, but I want to group the options (infile,mask,affmat,warp,mc)

I believe you can simply set xor=['featDir'] on infile, mask, affmat, warp, mc and xor=['infile', 'mask', 'affmat', 'warp', 'mc'] in the featDir trait. They should all also have mandatory=True.

How do the outputs output_spec actually relate to the output filenames?

The output of _list_outputs should be a dict with a key for each item in the output spec, and a value that matches the trait.

this is a tuple, versus the single outputs, how do I return a variable number of outputs?

You can specify something like this with OutputMultiPath. For instance, judging from your _list_outputs, I’d say your output spec could be:

class ICA_AROMAOutputSpec(TraitedSpec):
    out_file = OutputMultiPath(File(exists=True), desc='...')

This makes it so that you always get a list of files that exist, though it may be empty. However, this requires users to know the order of the aggressive and non-aggressive files in the list.

1 Like

Thank you for the feedback @effigies! I didn’t know how formal the code should be before I submitted a pull request, but I’ll incorporate your comments into my code and submit a pull request.