首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nipype AttributeError:“节点”对象没有属性

Nipype AttributeError:“节点”对象没有属性
EN

Stack Overflow用户
提问于 2014-07-11 08:25:50
回答 1查看 1.5K关注 0票数 0

下面的部分代码工作正常,没有任何错误:

代码语言:javascript
复制
#fslorient forceneurological
fslorient = pe.Node(interface = fslorient.FslOrient(), name = 'fslorient')
fslorient.inputs.main_option = 'forceneurological'

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

代码语言:javascript
复制
#fslorient deleteorient
fslorient1 = pe.Node(interface = fslorient.FslOrient(), name = 'fslorient1')
fslorient1.inputs.main_option = 'deleteorient'

属性错误:

代码语言:javascript
复制
    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

代码语言:javascript
复制
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

我找不到问题。

编辑:我也使用其他包装和遇到同样的错误!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-11 11:52:18

您正在重写fslorient命名空间。尝试:

代码语言:javascript
复制
#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'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24693252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档