@@ -24,61 +24,6 @@ By subclassing :class:`nipype.interfaces.matlab.MatlabCommand` for your main
2424class, and :class: `nipype.interfaces.matlab.MatlabInputSpec ` for your input and
2525output spec, you gain access to some useful MATLAB hooks
2626
27- .. testcode ::
28-
29- import os
30- from nipype.interfaces.base import File, traits
31- from nipype.interfaces.matlab import MatlabCommand, MatlabInputSpec
32-
33- class HelloWorldInputSpec( MatlabInputSpec):
34- name = traits.Str(mandatory = True,
35- desc = 'Name of person to say hello to')
36-
37- class HelloWorldOutputSpec(MatlabInputSpec):
38- matlab_output = traits.Str()
39-
40- class HelloWorld(MatlabCommand):
41- """ Basic Hello World that displays Hello <name> in MATLAB
42-
43- Returns
44- -------
45-
46- matlab_output : capture of matlab output which may be
47- parsed by user to get computation results
48-
49- Examples
50- --------
51-
52- >>> hello = HelloWorld()
53- >>> hello.inputs.name = ' hello_world'
54- >>> out = hello.run()
55- >>> print (out.outputs.matlab_output)
56- """
57- input_spec = HelloWorldInputSpec
58- output_spec = HelloWorldOutputSpec
59-
60- def _my_script(self):
61- """This is where you implement your script"""
62- script = """
63- disp('Hello %s Python')
64- two = 1 + 1
65- """%(self.inputs.name)
66- return script
67-
68- def run(self, **inputs):
69- ## inject your script
70- self.inputs.script = self._my_script()
71- results = super(MatlabCommand, self).run( **inputs)
72- stdout = results.runtime.stdout
73- # attach stdout to outputs to access matlab results
74- results.outputs.matlab_output = stdout
75- return results
76-
77- def _list_outputs(self):
78- outputs = self._outputs().get()
79- return outputs
80-
81-
8227.. literalinclude :: matlab_example2.py
8328
8429.. admonition :: Example source code
0 commit comments