Nipype属性错误:'节点'对象没有属性

时间:2014-07-11 08:25:50

标签: python nipype

以下部分代码可以正常运行:

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

但是,当我使用相同的脚本(Node)添加第二个fslorient时,属性错误会引发:

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

属性错误:

    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'

以下代码名为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

我找不到问题。

编辑:我还使用了其他包裹并遇到同样的错误!

1 个答案:

答案 0 :(得分:0)

您正在覆盖fslorient命名空间。尝试:

#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'