nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
749 stars 530 forks source link

spm.Coregister() error #3460

Open AnnaZhuravleva opened 2 years ago

AnnaZhuravleva commented 2 years ago

Summary

I try to use nipype.iterfaces.spm.Coregister(), but I got the following error

Actual behavior

ValueError Traceback (most recent call last) ~\Desktop\fmri\lib\site-packages\nipype\utils\spm_docs.py in _strip_header(doc) 48 hdr = 'NIPYPE' ---> 49 # There's some weird cruft at the end of the docstring, almost looks like 50 # the hex for the escape character 0x1b.

ValueError: substring not found

The above exception was the direct cause of the following exception:

OSError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_3584\2699162709.py in ----> 1 spm.Coregister()

~\Desktop\fmri\lib\site-packages\nipype\interfaces\spm\base.py in init(self, **inputs) 308 def set_mlab_paths(cls, matlab_cmd=None, paths=None, use_mcr=None): 309 cls._matlab_cmd = matlab_cmd --> 310 cls._paths = paths 311 cls._use_mcr = use_mcr 312 info_dict = Info.getinfo(

~\Desktop\fmri\lib\site-packages\nipype\interfaces\base\core.py in init(self, from_file, resource_monitor, ignore_exception, **inputs) 196 def _check_requires(self, spec, name, value): 197 """ check if required inputs are satisfied --> 198 """ 199 if spec.requires: 200 values = [

~\Desktop\fmri\lib\site-packages\nipype\interfaces\base\core.py in _check_version_requirements(self, trait_object, permissive) 293 due.cite(r) 294 --> 295 def run(self, cwd=None, ignore_exception=None, inputs): 296 """Execute this interface. 297

~\Desktop\fmri\lib\site-packages\nipype\interfaces\spm\base.py in version(self) 359 360 @property --> 361 def jobname(self): 362 return self._jobname 363

~\Desktop\fmri\lib\site-packages\nipype\interfaces\spm\base.py in getinfo(klass, matlab_cmd, paths, use_mcr) 237 klass._path = out_dict['path'] 238 klass._name = out_dict['name'] --> 239 klass._command = matlab_cmd 240 klass._paths = paths 241 return out_dict

~\Desktop\fmri\lib\site-packages\nipype\utils\spm_docs.py in _strip_header(doc) 49 # There's some weird cruft at the end of the docstring, almost looks like 50 # the hex for the escape character 0x1b. ---> 51 cruft = '\x1b' 52 try: 53 index = doc.index(hdr)

OSError: This docstring was not generated by Nipype!

Expected behavior

No errors

Script/Workflow details

import nipype.interfaces.spm as spm coreg = spm.Coregister()

Platform details:

{'commit_hash': 'f2bbcc917',
 'commit_source': 'installation',
 'networkx_version': '2.6.3',
 'nibabel_version': '3.2.2',
 'nipype_version': '1.1.7',
 'numpy_version': '1.21.6',
 'pkg_path': 'C:\\Users\\NeuroLing\\Desktop\\fmri\\lib\\site-packages\\nipype',
 'scipy_version': '1.7.3',
 'sys_executable': 'C:\\Users\\NeuroLing\\Desktop\\fmri\\Scripts\\python.exe',
 'sys_platform': 'win32',
 'sys_version': '3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC '
                'v.1916 64 bit (AMD64)]',
 'traits_version': '6.3.2'}

Execution environment

Choose one

gr33n1 commented 1 year ago

Hi @AnnaZhuravleva, I am getting the same Error but from different way: My code: spm.Realign() When this runs it uses matlab to run the follwing (base.py lines 217):

mlab.inputs.script = """
                  if isempty(which('spm')),
                  throw(MException('SPMCheck:NotFound','SPM not in matlab path'));
                  end;
                  spm_path = spm('dir');
                  [name, version] = spm('ver');
                  fprintf(1, 'NIPYPE path:%s|name:%s|release:%s', spm_path, name, version);
                  exit;
"""
try:
    out = mlab.run()

I run it in Matlab and got :

>> isempty(which('spm'))

        ans =

          logical

           0

>> [name, version] = spm('ver');
fprintf(1, 'NIPYPE path:%s|name:%s|release:%s', spm_path, name, version);
      NIPYPE path:C:\Program Files\MATLAB\R2022b\toolbox\spm12\spm12|name:SPM12|release:7771

so as you can see i have result from this script, but when checking the "out" variable here (line 239): out = sd._strip_header(out.runtime.stdout) Stdout is "" empty string

So I think the problem is Somhow related to the answer of the script from Matlab, how to fix it ?? Thanks!