Matlab Interface does not proceed

95 views
Skip to first unread message

Yasin Yazıcı

unread,
Jul 2, 2014, 12:05:28 AM7/2/14
to nipy...@googlegroups.com
Hi,

I'm trying to run a simple matlab interface 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('/new_home/intern2012/yasin');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 :

lewsk77@neuro:/new_home/intern2012/yasin$ ipython example.py
matlab
-nodesktop -nosplash -singleCompThread -r "addpath('/new_home/intern2012/yasin');pyscript;exit"
^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:


Regards,
Yasin

Satrajit Ghosh

unread,
Jul 2, 2014, 9:41:57 AM7/2/14
to nipy-user
hi yasin,

this works for me on osx and ubuntu. i'm running matlab2010b on ubuntu and 2012b on osx.

cheers,

satra


--

---
You received this message because you are subscribed to the Google Groups "NiPy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nipy-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yasin Yazıcı

unread,
Jul 2, 2014, 11:32:21 PM7/2/14
to nipy...@googlegroups.com

Hi Satra

I tried it on my mac and it works but not on ubuntu on a server. There is a problem in subprocess at communication part as it can be seen at the first post. It is a kind of deadlock. It does not proceed.

The code below actually do the same thing without any error or deadlock.
import os
p
= os.popen('matlab -nodesktop -nosplash -nojvm -r "1+2;exit"')
while 1:
    line
= p.readline()
   
if not line: break
   
print line

Regards
Yasin

Satrajit Ghosh

unread,
Jul 3, 2014, 12:23:33 AM7/3/14
to nipy-user
hi yasin,

can you please check if this creates an issue with current nipype master? there were deadlocks that could happen but that was a long time back when we used lock files.

it would be great if you could post the output of the following:

import nipype
print nipype.get_info()

cheers,

satra


Yasin Yazıcı

unread,
Jul 3, 2014, 12:42:03 AM7/3/14
to nipy...@googlegroups.com
Hi Satra

Here is output:

{'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'}

I searched through internet and there are many deadlocks on subprocess, however they are related with Popen() not poller.poll().
 
Regards
Yasin

Augustine Koh

unread,
Jul 6, 2014, 11:22:34 AM7/6/14
to nipy...@googlegroups.com
Dear Yasin,

Thanks for letting me know about this issue when we corresponded. Although I'm not interning with you guys anymore, I'm still keen on getting this thing working for our lab just as you are. This problem that you are experiencing with running the matlab interface on our workstation actually reminds me of the installation problem that I had raised in this post:
https://groups.google.com/forum/#!topic/nipy-user/Q3YjfkSMPtI ; I was never able to resolve it before I left. 

Dear Satra,

My guess is that the problem Yasin is facing is the same the problem that I encountered when I tried running the Nipype installation test on the Ubuntu server. I've observed that the part where the installation test stalls is the part where MATLAB is called in the background (and is perhaps the part of the test where MATLAB interfaces are tested?). I believe this is so because I have Nipype installed on my Macbook, and when I ran the installation test on my Mac, the parts of the installation test (as I can see from the command-line) when I saw the MATLAB icon appear in my Dock, is the part on the workstation where the whole test stalls. I raised this issue back in https://groups.google.com/forum/#!topic/nipy-user/Q3YjfkSMPtI and have not yet found resolution for it, and that may be why Yasin is also facing this problem now. It is unlikely to do with permissions as from what Yasin posted, I can see that he used an account that had permission to run MATLAB, and I believe the MATALB binaries are added to our $PATH variable as we can always open MATLAB from our command line. We are running MATLAB version 2008b if I remember correctly (Yasin, is that our version?). What could be the issue?
Thank you very much for your help!

Best Regards,
Augustine

Yasin Yazıcı

unread,
Jul 7, 2014, 1:00:10 AM7/7/14
to nipy...@googlegroups.com

MatlabCommand codes are running now after the server backup. So it was about server.

Regards
Yasin
Reply all
Reply to author
Forward
0 new messages