[Neuroimaging] wrap a matlab script for Nipype

Hao wen hao.freesurfer at hotmail.com
Wed Jun 29 04:32:38 EDT 2016

For the function version(runmatlab), in spyder, I got the result like this:

RuntimeError: Command:
matlab -nodesktop -nosplash -singleCompThread -r "addpath('/tmp/tmppHQYo8/runmatlab');pyscript;exit"
Standard output:
Warning: Unable to open display ':1'.  You will not be able to display graphics on the screen.
Warning: No window system found.  Java option 'MWT' ignored

                            < M A T L A B (R) >
                  Copyright 1984-2010 The MathWorks, Inc.
                Version (R2010b) 64-bit (glnxa64)
                              August 16, 2010

  To get started, type one of these: helpwin, helpdesk, or demo.
  For product information, visit www.mathworks.com.

Executing pyscript at 29-Jun-2016 10:28:27:
MATLAB Version (R2010b)
MATLAB License Number: 295724
Operating System: Linux 3.11.0-26-generic #45~precise1-Ubuntu SMP Tue Jul 15 04:02:35 UTC 2014 x86_64
Java VM Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB                                                Version 7.11       (R2010b)
Database Toolbox                                      Version 3.8        (R2010b)
Image Processing Toolbox                              Version 7.1        (R2010b)
MATLAB Compiler                                       Version 4.14       (R2010b)
Neural Network Toolbox                                Version 7.0        (R2010b)
Optimization Toolbox                                  Version 5.1        (R2010b)
Parallel Computing Toolbox                            Version 5.0        (R2010b)
Parallel Computing Toolbox                            Version 5.0        (R2010b)
Signal Processing Toolbox                             Version 6.14       (R2010b)
Statistical Parametric Mapping                        Version 5236       (SPM8)
Statistics Toolbox                                    Version 7.4        (R2010b)
Wavelet Toolbox                                       Version 4.6        (R2010b)

Standard error:
/usr/cenir/matlabR2010b_64/bin/matlab: 1: /servernas/usr_cenir/matlabR2010b_64/bin/util/oscheck.sh: /lib64/libc.so.6: not found
MATLAB code threw an exception:
Undefined function or variable 'testhelloworld'.

Return code: 0
Interface MatlabCommand failed to run.
Interface Function failed to run.

the command line, actually, the addpath points to the wrong path, my matlab script is in : /aramis/home/wen/HAO_lab/testhelloworld.m

Actually, I think it is because I did not find the right documentation for nipype, cuz Im new to nipype...


Bonne journée

De : Hao wen
Envoyé : mercredi 29 juin 2016 10:25
À : neuroimaging at python.org
Objet : wrap a matlab script for Nipype


I am new to nipype, and recently, I want to wrap a matlab script for Nipype, but in your website, the example is not so specific,and I checked out all the posts that you have talked about, it is not so clear, whatever for the command line or to create the matlab interface by ourself, can you just make a good tutorial for us? in fact, the tutorial in the nipype website is not so well-structured, in my opinion...

Specifically, here is my case I wanna wrap a matlab function with a nipype freesurfer node, my matlab function actually just got some jpg files and save it to the output directory, I followed some options from the tutorial and other posts:

By the way, i am on Ubuntu 12.04

def runmatlab():
    from nipype.interfaces.matlab import MatlabCommand
    mlab = MatlabCommand()
    mlab.inputs.script = "/aramis/home/wen/HAO_lab/testhelloworld.m"
    out = mlab.run()
    print out.outputs.matlab_output
    return out.outputs.matlab_output

from nipype.interfaces.utility import Function
import nipype.pipeline.engine as pe

runmatlab = pe.Node(name='runmatlab',


the matlab file is just to print  'hello world'

I got this in the _report file :

Node: utility

 Hierarchy : runmatlab
 Exec ID : runmatlab

Original Inputs

* function_str : S'def runmatlab():\n    from nipype.interfaces.matlab import MatlabCommand\
n    mlab = MatlabCommand()\n    mlab.inputs.script = "/aramis/home/wen/HAO_lab/testhellowor
ld.m"\n    out = mlab.run()\n    out.outputs[\'matlab_output\'] \n    print out.outputs.matl
ab_output\n    return out.outputs.matlab_output\n'
* ignore_exception : False

in the runmatlab node, I got some files

Also, I tried the tutorial example2 in nipype website : http://nipy.org/nipype/devel/matlab_interface_devel.html, In my spyder, I got no display, but in my dir, I got the pyscript.m, I run it in my matlab, I got the result, does that mean that spyder cant find my matlab???? but I saw that in some post that you said the MatlabCommand will not use matlab engine, they just give some matlab script to it to run?

Any advice will be appreciated:)


Neuroimaging in Python - Pipelines and Interfaces - nipy ...<http://nipy.org/nipype/devel/matlab_interface_devel.html>
How to wrap a MATLAB script¶ This is minimal script for wrapping MATLAB code. You should replace the MATLAB code template, and define approriate inputs and outputs.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20160629/7dee222c/attachment.html>

More information about the Neuroimaging mailing list