nipype - sometimes hangs on MatlabCommands

84 views
Skip to first unread message

Dan

unread,
Oct 14, 2014, 2:36:33 AM10/14/14
to nipy...@googlegroups.com
Hi all,

I use a few SPM scripts wrapped as in example 1 here: http://nipy.sourceforge.net/nipype/devel/matlab_interface_devel.html

When running them as part of a workflow (either serially or in parallel), they sometimes "hang". CPU drops to baseline, no further jobs are executed or finished. When I ctrl-c the script, it exists at sleep(2) on line 260, base.py. Further investigation revealed that this is due to "jobids" on line 326 always being empty.

Strangely, as soon as I cancel the script, CPU use increases. The top command says that MATLAB is working very hard on something as it should be. It is as if MATLAB is being held back.

If I keep re-running and canceling, I make progress through the workflow i.e. MATLAB nodes that previously "hanged" are completed. I'd appreciate any thoughts anyone might have regarding this issue.

Best,
Dan

Here is the output of nipype.get_info()

{'commit_hash': '<not found>',
 'commit_source': '(none found)',
 'networkx_version': '1.7',
 'nibabel_version': '1.3.0',
 'numpy_version': '1.7.1',
 'pkg_path': '/usr/local/lib/python2.7/dist-packages/nipype-0.9.2-py2.7.egg/nipype',
 'scipy_version': '0.12.1',
 'sys_executable': '/usr/bin/python',
 'sys_platform': 'linux2',
 'sys_version': '2.7.3 (default, Feb 27 2014, 19:58:35) \n[GCC 4.6.3]',
 'traits_version': '4.3.0'}

Satrajit Ghosh

unread,
Oct 14, 2014, 8:49:31 AM10/14/14
to nipy-user
hi dan,

in addition, could you please let us know your operating system and kernel version as well as the matlab version. we used to have such issues a long time back on debian systems with older versions of matlab, but haven't seen that in a while.

the solution we created was to use the following (but this hasn't been needed in a while):


the other thing you might want to check is whether the matlab command is an alias for something else.

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.

Dan

unread,
Oct 14, 2014, 1:49:31 PM10/14/14
to nipy...@googlegroups.com
Hi Satra,

Thanks for the quick reply.

Ubuntu 12.04
kernel version 3.2.0-70-generic
MATLAB R2014a  8.3.0.532 (64 bit)

Unfortunately the solution in the link didn't make a difference. The matlab command is not aliased to something else.

I'm sure this used to work fine, the main difference since it did is that I updated by Ubuntu installation, I can't think of any other reason.

Best,
Dan

Dan

unread,
Oct 14, 2014, 11:57:32 PM10/14/14
to nipy...@googlegroups.com
FYI, I also tried it on Ubuntu 14.04 (kernel version 3.13.0-30-generic) and MATLAB R2011b, same issue.

Best,
Dan

Satrajit Ghosh

unread,
Oct 15, 2014, 8:21:12 AM10/15/14
to nipy-user
hi dan,

let's try a few debugging steps from a python terminal:

1. check matlab directly
import nipype.interfaces.matlab as mlab
res = mlab.MatlabCommand(script="").run()
print(res.runtime.stdout)

2. check if spm can be found/called - also runs matlab 
import nipype.interfaces.spm as spm
spm.Info.version()

cheers,

satra

Dan McNamee

unread,
Oct 15, 2014, 3:47:48 PM10/15/14
to nipy...@googlegroups.com
Hi Satra,

1. returns a description of my MATLAB environment e.g. 
< M A T L A B (R) >
Copyright 1984-2014 The MathWorks, Inc.
R2014a (8.3.0.532) 64-bit (glnxa64)
February 11, 2014
* list of packages and versions *

2. returns None

Best,
Dan

--

---
You received this message because you are subscribed to a topic in the Google Groups "NiPy Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nipy-user/GxtVagM9hxQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nipy-user+...@googlegroups.com.

Satrajit Ghosh

unread,
Oct 15, 2014, 3:57:21 PM10/15/14
to nipy-user
hi dan,

so it looks like matlab is being called fine, and spm is not in your path (which is ok - it can be added as an input).

next step. minimal matlab workflow:

from nipype import Workflow, Node
import nipype.interfaces.matlab as mlab

wf = Workflow(name='debug_matlab')
node = Node(mlab.MatlabCommand(), name='run_matlab')
node.inputs.script = """
"""
wf.add_nodes([node])
eg = wf.run()
print(eg.nodes()[0].result.runtime.stdout) #same output as before

if the above runs, then there is something weird with the interface. you could try sticking some pieces of the matlab code in the script input above.

cheers,

satra

Dan

unread,
Oct 15, 2014, 4:18:51 PM10/15/14
to nipy...@googlegroups.com
Hi Satra,

That code works fine. I tried some basic MATLAB commands and a VOI extraction command and they worked fine. The VOI extraction script was taken from a pyscript.m file created during my workflow.

Best,
Dan

Satrajit Ghosh

unread,
Oct 15, 2014, 4:24:58 PM10/15/14
to nipy-user
hi dan,

perhaps you can build from here on out. i don't know why things would hang up. 

you could start with a minimal interface add it to your pythonpath and continue? or even write a function node that calls matlabcmd internally.

but these tests demonstrate that communication between nipype and matlab is fine whether as an interface or as a workflow.

cheers,

satra

Dan McNamee

unread,
Oct 16, 2014, 2:58:50 PM10/16/14
to nipy...@googlegroups.com
OK, thanks for the tips Satra.
Reply all
Reply to author
Forward
0 new messages