Nipype Custom Interface not showing output

87 views Asked by At

I am trying to build a custom interface that will dynamically generate the outputspec attribute based on the dictionary input. However, the output is not showing up when I do .help()

Here is what I have previously and if I run help() it will show the inputs and outputs of the node.

class _GatherInputsOutputSpec(TraitedSpec):

    a_file = traits.Str()
    b_file = traits.Str()
    c_file = traits.Str()


class GatherInputs(SimpleInterface):

    def __init__(self, dict_a):
        super().__init__()
        self.dict_a = dict_a
        self.outputspec = _GatherInputsOutputSpec

   

But when I tried to build the outputspec class dynamically like below, the outputs will not show up when I do help() and run() function is not working as well.

class Context(SimpleInterface):

    def __init__(self, dict_a):
        super().__init__()
        self.dict_a = dict_a
        self.outputspec = self._outputspec_build(dict_a)

    @staticmethod
    def _outputspec_build(dict_a):
        outputspec_class = type("ConfigOutputSpec", (nipype.interfaces.base.specs.TraitedSpec, ),{'__module__': '__main__'})
        for k in dict_a.get('inputs').keys():
            setattr(outputspec_class, k, traits.Str())
            
        return outputspec_class

Am I setting the attribute incorrectly?

0

There are 0 answers