1

I'm trying to run a simple matlab interface on Nipype as below, but somehow it gets stuck in run() code. My command line does not proceed anymore . But it works perfectly if I copy mlab.cmdline (matlab -nodesktop -nosplash -singleCompThread -r "addpath('/somepath');pyscript;exit") and past it to the Command Line.

import nipype.interfaces.matlab as matlab

mlab = matlab.MatlabCommand()
mlab.inputs.script = """ 1+2 """

print mlab.cmdline
res = mlab.run()

print res.runtime

here is ipython keyboard interruption :

    ^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
    173             else:
    174                 filename = fname
--> 175             __builtin__.execfile(filename, *where)

/new_home/intern2012/yasin/example.py in <module>()
      6
      7 print mlab.cmdline
----> 8 res = mlab.run()
      9
     10 print res.runtime

/usr/lib/pymodules/python2.7/nipype/interfaces/base.pyc in run(self, **inputs)
    944                         version=self.version)
    945         try:
--> 946             runtime = self._run_interface(runtime)
    947             outputs = self.aggregate_outputs(runtime)
    948             runtime.endTime = dt.isoformat(dt.utcnow())

/usr/lib/pymodules/python2.7/nipype/interfaces/matlab.pyc in _run_interface(self, runtime)
    136     def _run_interface(self,runtime):
    137         self.inputs.terminal_output = 'allatonce'
--> 138         runtime = super(MatlabCommand, self)._run_interface(runtime)
    139         try:
    140             # Matlab can leave the terminal in a barbbled state


/usr/lib/pymodules/python2.7/nipype/interfaces/base.pyc in _run_interface(self, runtime, correct_return_codes)
   1378         setattr(runtime, 'dependencies', get_dependencies(executable_name,
   1379                                                           runtime.environ))
-> 1380         runtime = run_command(runtime, output=self.inputs.terminal_output)
   1381         if runtime.returncode is None or \
   1382                         runtime.returncode not in correct_return_codes:

/usr/lib/pymodules/python2.7/nipype/interfaces/base.pyc in run_command(runtime, output, timeout)
   1150         result['merged'] = [r[1] for r in temp]
   1151     if output == 'allatonce':
-> 1152         stdout, stderr = proc.communicate()
   1153         result['stdout'] = stdout.split('\n')
   1154         result['stderr'] = stderr.split('\n')

/usr/lib/python2.7/subprocess.pyc in communicate(self, input)
    752             return (stdout, stderr)
    753
--> 754         return self._communicate(input)
    755
    756

/usr/lib/python2.7/subprocess.pyc in _communicate(self, input)
   1310
   1311             if _has_poll:
-> 1312                 stdout, stderr = self._communicate_with_poll(input)
   1313             else:
   1314                 stdout, stderr = self._communicate_with_select(input)

/usr/lib/python2.7/subprocess.pyc in _communicate_with_poll(self, input)
   1364             while fd2file:
   1365                 try:
-> 1366                     ready = poller.poll()
   1367                 except select.error, e:
   1368                     if e.args[0] == errno.EINTR:

I have read other subprocess problems in this site but they all are related with Popen(). In my case something wrong with poller.poll(). It does not process anymore when it reaches this line.

yasin.yazici
  • 275
  • 1
  • 2
  • 12
  • Could it have something to do with that matlab only is single thread you think? – patrik Jul 03 '14 at 06:41
  • I dont think the problem is related with matlab. Actually, the same code works on my mac. I think the problem is on computer that I use on a server. Somehow it can not complete `_communicate_with_poll`. – yasin.yazici Jul 03 '14 at 12:59

1 Answers1

0

I failed to replicate this behaviour (aka "works for me!"). Which version of nipype are you using?

  • '{'nibabel_version': '1.3.0', 'networkx_version': '1.6', 'numpy_version': '1.6.1', 'sys_platform': 'linux2', 'sys_version': '2.7.3 (default, Sep 26 2013, 20:03:06) \n[GCC 4.6.3]', 'commit_source': 'archive substitution', 'commit_hash': '162f65d', 'pkg_path': '/usr/lib/pymodules/python2.7/nipype', 'sys_executable': '/usr/bin/python', 'traits_version': '4.0.0', 'scipy_version': '0.9.0'}' – yasin.yazici Jul 03 '14 at 12:58
  • I just re-installed nipype now but again the same problem. Something wrong in `poller.poll()`. Even this one gets stuck : `python -c "import nipype; nipype.test()"`. Exactly at the same location. – yasin.yazici Jul 04 '14 at 01:31
  • nipype.__version__ ? can you run anything using Popen? – Chris Gorgolewski Jul 04 '14 at 13:08
  • I'm away of sever for now but it must be the last version because I just re-installed it today by using NeuroDebian. I can use Popen without any problem and Gzip code([link](http://nipy.sourceforge.net/nipype/devel/cmd_interface_devel.html)) . But cannot call matlab, mipav or even simplest code on commandline. It gets stucks always. I even tried to run the code with admin account. It works on my mac but not on ubuntu. I think something wrong in base.py like parent function waiting for child and it gets stuck. – yasin.yazici Jul 04 '14 at 14:36
  • >>> nipype.__version__ '0.9.1' – yasin.yazici Jul 07 '14 at 03:06
  • MatlabCommand codes are running now after the server backup. So it was about server. – yasin.yazici Jul 08 '14 at 06:36