class_docstr: 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()  # doctest: +SKIP
class_docstr_tok: ["Interface","that","runs","matlab","code",">",">",">","import","nipype.interfaces.matlab","as","matlab",">",">",">","mlab","=","matlab.MatlabCommand","(","mfile=False",")","#","do","n't","write","script","file",">",">",">","mlab.inputs.script","=","``","which","(","'who","'",")","''",">",">",">","out","=","mlab.run","(",")","#","doctest",":","+SKIP"]
docstr: Generates commands and, if mfile specified, writes it to disk.
docstr_tok: ["Generates","commands","and",",","if","mfile","specified",",","writes","it","to","disk","."]
code: def _gen_matlab_command(self, argstr, script_lines):
      """Generates commands and, if mfile specified, writes it to disk."""
      cwd = os.getcwd()
      mfile = self.inputs.mfile or self.inputs.uses_mcr
      paths = []
      if isdefined(self.inputs.paths):
          paths = self.inputs.paths
      # prescript
      prescript = self.inputs.prescript
      postscript = self.inputs.postscript
  
      # prescript takes different default value depending on the mfile argument
      if mfile:
          prescript.insert(
              0,
              "fprintf(1,'Executing %s at %s:\\n',mfilename(),datestr(now));",
          )
      else:
          prescript.insert(
              0, "fprintf(1,'Executing code at %s:\\n',datestr(now));"
          )
      for path in paths:
          # addpath() is not available after compilation
          # https://www.mathworks.com/help/compiler/ismcc.html
          # https://www.mathworks.com/help/compiler/isdeployed.html
          prescript.append(
              "if ~(ismcc || isdeployed), addpath('%s'); end;\n" % path
          )
  
      if not mfile:
          # clean up the code of comments and replace newlines with commas
          script_lines = ",".join(
              [
                  line
                  for line in script_lines.split("\n")
                  if not line.strip().startswith("%")
              ]
          )
  
      script_lines = (
          "\n".join(prescript) + script_lines + "\n".join(postscript)
      )
      if mfile:
          with open(
              os.path.join(cwd, self.inputs.script_file), "w"
          ) as mfile:
              mfile.write(script_lines)
          if self.inputs.uses_mcr:
              script = "%s" % (
                  os.path.join(cwd, self.inputs.script_file)
              )
          else:
              script = "addpath('{}');{}".format(
                  cwd,
                  self.inputs.script_file.split(".")[0],
              )
      else:
          script = "".join(script_lines.split("\n"))
      return argstr % script
  
file_path: nipype/nipype/interfaces/matlab.py
imports: import os
  from ..None import config
  from .base import CommandLineInputSpec, InputMultiPath, isdefined, CommandLine, traits, File, Directory
label_desc: Use image node_id 7 for calling the MatlabCommand obj's underlying member method code with example usage: obj._gen_matlab_command(argstr, script_lines) and returns: unknown