0

The partial code below works without any error:

#fslorient forceneurological
fslorient = pe.Node(interface = fslorient.FslOrient(), name = 'fslorient')
fslorient.inputs.main_option = 'forceneurological'

However, when I add a second Node with the same script(fslorient) an Attribute Error raises:

#fslorient deleteorient
fslorient1 = pe.Node(interface = fslorient.FslOrient(), name = 'fslorient1')
fslorient1.inputs.main_option = 'deleteorient'

Attribute Error:

    Traceback (most recent call last):
  File "bs_pipeline.py", line 139, in <module>
    fslorient1 = pe.Node(interface = fslorient.FslOrient(), name = 'fslorient1')
AttributeError: 'Node' object has no attribute 'FslOrient'

This code below is named fslorient.py

from nipype.interfaces.fsl.base import FSLCommand, FSLCommandInputSpec
from nipype.interfaces.base import TraitedSpec, File, traits
import os

class FslOrientInputSpec(FSLCommandInputSpec):

    main_option = traits.Str(desc='main option', argstr='-%s', position=0, mandatory=True)

    code = traits.Int(argstr='%d', desc='code for setsformcode', position=1)

    in_file = File(exists=True, desc='input file', argstr='%s', position=2, mandatory=True)

class FslOrientOutputSpec(TraitedSpec):

    out_file = File(desc = "out file", exists = True)

class FslOrient(FSLCommand):

    _cmd = 'fslorient'
    input_spec = FslOrientInputSpec
    output_spec = FslOrientOutputSpec

    def _list_outputs(self):
            outputs = self.output_spec().get()
            outputs['out_file'] = os.path.abspath(self.inputs.in_file)
            return outputs

I could not find the problem.

Edit: I also used other wraps and encounter the same error!

yasin.yazici
  • 275
  • 1
  • 2
  • 12

1 Answers1

0

You are overwritting fslorient namespace. Try:

#fslorient forceneurological
fslorient1 = pe.Node(interface = fslorient.FslOrient(), name = 'fslorient1')
fslorient1.inputs.main_option = 'forceneurological'

#fslorient deleteorient
fslorient2 = pe.Node(interface = fslorient.FslOrient(), name = 'fslorient2')
fslorient2.inputs.main_option = 'deleteorient'
  • Their name are not the same. One of them is 'fslorient' and the other is 'fslorient1'. I found another way: importing 'fslorient'module with different names (f1,f2 etc) but this is a bit creepy. I want to do it in a neat way and want to understand where the problem is. – yasin.yazici Jul 12 '14 at 05:46
  • Just don't use the same name (fslorient) for a variable and module. There is no need to import the module twice. Also please sent a pull request on github with this new interaface so we could add it the new release. – Chris Gorgolewski Jul 13 '14 at 09:12