nipype.interfaces.matlab module

Interfaces to run MATLAB scripts.

MatlabCommand

Link to code

Bases: CommandLine

Wrapped executable: matlab.

Interface that runs matlab code

>>> import nipype.interfaces.matlab as matlab
>>> mlab = matlab.MatlabCommand(mfile=False)  # don't write script file
>>> mlab.inputs.script = "which('who')"
>>> out = mlab.run()  
Mandatory Inputs:

script (a string) – M-code to run. Maps to a command-line argument: -r "%s;exit" (position: -1).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • logfile (a pathlike object or string representing a file) – Save matlab output to log. Maps to a command-line argument: -logfile %s.

  • mfile (a boolean) – Run m-code using m-file. (Nipype default value: True)

  • nodesktop (a boolean) – Switch off desktop mode on unix platforms. Maps to a command-line argument: -nodesktop. (Nipype default value: True)

  • nosplash (a boolean) – Switch of splash screen. Maps to a command-line argument: -nosplash. (Nipype default value: True)

  • paths (a list of items which are a pathlike object or string representing a directory) – Paths to add to matlabpath.

  • postscript (a list of items which are any value) – Script added after code. (Nipype default value: ['\n,catch ME,', "fprintf(2,'MATLAB code threw an exception:\\n');", "fprintf(2,'%s\\n',ME.message);", "if length(ME.stack) ~= 0, fprintf(2,'File:%s\\nName:%s\\nLine:%d\\n',ME.stack.file,ME.stack.name,ME.stack.line);, end;", 'end;'])

  • prescript (a list of items which are any value) – Prescript to be added before code. (Nipype default value: ['ver,', 'try,'])

  • script_file (a pathlike object or string representing a file) – Name of file to write m-code to. (Nipype default value: pyscript.m)

  • single_comp_thread (a boolean) – Force single threaded operation. Maps to a command-line argument: -singleCompThread.

  • uses_mcr (a boolean) – Use MCR interface. Mutually exclusive with inputs: nodesktop, nosplash, single_comp_thread.

classmethod MatlabCommand.set_default_matlab_cmd(matlab_cmd)

Set the default MATLAB command line for MATLAB classes.

This method is used to set values for all MATLAB subclasses. However, setting this will not update the output type for any existing instances. For these, assign the <instance>.inputs.matlab_cmd.

classmethod MatlabCommand.set_default_mfile(mfile)

Set the default MATLAB script file format for MATLAB classes.

This method is used to set values for all MATLAB subclasses. However, setting this will not update the output type for any existing instances. For these, assign the <instance>.inputs.mfile.

classmethod MatlabCommand.set_default_paths(paths)

Set the default MATLAB paths for MATLAB classes.

This method is used to set values for all MATLAB subclasses. However, setting this will not update the output type for any existing instances. For these, assign the <instance>.inputs.paths.

nipype.interfaces.matlab.get_matlab_command()

Determine whether Matlab is installed and can be executed.