Skip to content

spm.DARTEL() ; spm.DARTELNorm2MNI() - unable to use files located in folders different than current working directory #2579

Open
@gacek91

Description

@gacek91

Summary

While running spm.DARTEL(), I'm getting an unexpected error when Template_6.nii is created. No error occurs with Templates 0-5.

Edit: similar error occurs when I try to use a different function: spm.DARTELNorm2MNI()

Actual behavior

Error output below:

---------------------------------------------------------------------------
TraitError                                Traceback (most recent call last)
<ipython-input-28-3d03449a9e1d> in <module>()
      1 dartel = spm.DARTEL()
      2 dartel.inputs.image_files = [rc1DartelPaths,rc2DartelPaths]
----> 3 dartel.run()

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nipype/interfaces/base/core.py in run(self, cwd, ignore_exception, **inputs)
    519         try:
    520             runtime = self._run_interface(runtime)
--> 521             outputs = self.aggregate_outputs(runtime)
    522         except Exception as e:
    523             import traceback

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nipype/interfaces/base/core.py in aggregate_outputs(self, runtime, needed_outputs)
    616                                "'%s'." % (val, self.__class__.__name__, key))
    617                         raise FileNotFoundError(msg)
--> 618                     raise error
    619 
    620         return outputs

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nipype/interfaces/base/core.py in aggregate_outputs(self, runtime, needed_outputs)
    609                                                       self.__class__.__name__))
    610                 try:
--> 611                     setattr(outputs, key, val)
    612                 except TraitError as error:
    613                     if getattr(error, 'info',

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nipype/interfaces/base/traits_extension.py in validate(self, object, name, value)
    110                 args='The trait \'{}\' of {} instance is {}, but the path '
    111                 ' \'{}\' does not exist.'.format(name, class_of(object),
--> 112                                                  self.info_text, value))
    113 
    114         self.error(object, name, value)

TraitError: The trait 'final_template_file' of a DARTELOutputSpec instance is an existing file name, but the path  '/Users/Gacek/Documents/VBM/Template_6.nii' does not exist.

Expected behavior

Obviously no error. I can see that TraitError refers to a non-existent file which is supposed to be in my current working directory (when in fact all the templates are saved in ../segmentation/dartel/, which is the place where my rc1 and rc2 files are stored).

How to replicate the behavior

Put rc1 and rc2 files in a folder (change pth and niiFnames variables accordingly)

Script/Workflow details

import nipype.interfaces.spm as spm
import os, os.path as op, shutil
import nipype
from nipype.interfaces.matlab import MatlabCommand


pth = op.join(os.getcwd(),'GL','niftis_py')

niiFnames = [f for f in os.listdir(pth) if f.endswith('.nii') if f.startswith('GL')]
niiPaths = [op.join(pth,nii) for nii in niiFnames]
segmNativeFnames = [c + nii for c in ['c1','c2','c3'] for nii in niiFnames]
segmDartelFnames = [rc + nii for rc in ['rc1','rc2'] for nii in niiFnames]

segmNativePathsNew = [op.join(pth,'segmentation','native', c) for c in segmNativeFnames]
segmDartelPathsNew = [op.join(pth,'segmentation','dartel',rc) for rc in segmDartelFnames]
rc1DartelPaths = [rc for rc in segmDartelPathsNew if op.split(rc)[-1].startswith('rc1')]
rc2DartelPaths = [rc for rc in segmDartelPathsNew if op.split(rc)[-1].startswith('rc2')]

dartel = spm.DARTEL()
dartel.inputs.image_files = [rc1DartelPaths,rc2DartelPaths]
dartel.run()

Platform details:

'pkg_path': '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nipype', 'commit_source': 'installation', 'commit_hash': '7d3966f', 'nipype_version': '1.0.3', 'sys_version': '3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55) \n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]', 'sys_executable': '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6', 'sys_platform': 'darwin', 'numpy_version': '1.13.3', 'scipy_version': '0.19.0', 'networkx_version': '2.1', 'nibabel_version': '2.2.0', 'traits_version': '4.6.0'

Execution environment

Choose one

  • Container [Tag: ???]
  • My python environment inside container [Base Tag: ???]
  • My python environment outside container

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions