class_docstr: Extends `BaseInterface` class to implement SPM specific interfaces.
  
  WARNING: Pseudo prototype class, meant to be subclassed
class_docstr_tok: ["Extends","`","BaseInterface","`","class","to","implement","SPM","specific","interfaces",".","WARNING",":","Pseudo","prototype","class",",","meant","to","be","subclassed"]
docstr: Generates a mfile to build job structure
  Parameters
  ----------
  
  contents : list
      a list of dicts generated by _parse_inputs
      in each subclass
  
  cwd : string
      default os.getcwd()
  
  Returns
  -------
  mscript : string
      contents of a script called by matlab
code: def _make_matlab_command(self, contents, postscript=None):
      """Generates a mfile to build job structure
      Parameters
      ----------
  
      contents : list
          a list of dicts generated by _parse_inputs
          in each subclass
  
      cwd : string
          default os.getcwd()
  
      Returns
      -------
      mscript : string
          contents of a script called by matlab
  
      """
      cwd = os.getcwd()
      mscript = """
          %% Generated by nipype.interfaces.spm
          if isempty(which('spm')),
               throw(MException('SPMCheck:NotFound', 'SPM not in matlab path'));
          end
          [name, version] = spm('ver');
          fprintf('SPM version: %s Release: %s\\n',name, version);
          fprintf('SPM path: %s\\n', which('spm'));
          spm('Defaults','fMRI');
  
          if strcmp(name, 'SPM8') || strcmp(name(1:5), 'SPM12'),
             spm_jobman('initcfg');
             spm_get_defaults('cmdline', 1);
          end\n
          """
      if self.mlab.inputs.mfile:
          if (
              isdefined(self.inputs.use_v8struct)
              and self.inputs.use_v8struct
          ):
              mscript += self._generate_job(
                  f"jobs{{1}}.spm.{self.jobtype}.{self.jobname}",
                  contents[0],
              )
          else:
              if self.jobname in [
                  "st",
                  "smooth",
                  "preproc",
                  "preproc8",
                  "fmri_spec",
                  "fmri_est",
                  "factorial_design",
                  "defs",
              ]:
                  # parentheses
                  mscript += self._generate_job(
                      f"jobs{{1}}.{self.jobtype}{{1}}.{self.jobname}(1)",
                      contents[0],
                  )
              else:
                  # curly brackets
                  mscript += self._generate_job(
                      f"jobs{{1}}.{self.jobtype}{{1}}.{self.jobname}{{1}}",
                      contents[0],
                  )
      else:
          from scipy.io import savemat
  
          jobdef = {
              "jobs": [
                  {
                      self.jobtype: [
                          {
                              self.jobname: self.reformat_dict_for_savemat(
                                  contents[0]
                              )
                          }
                      ]
                  }
              ]
          }
          savemat(
              os.path.join(cwd, "pyjobs_%s.mat" % self.jobname), jobdef
          )
          mscript += "load pyjobs_%s;\n\n" % self.jobname
      mscript += """
          spm_jobman(\'run\', jobs);\n
          """
      if self.inputs.use_mcr:
          mscript += """
          if strcmp(name, 'SPM8') || strcmp(name(1:5), 'SPM12'),
              close(\'all\', \'force\');
          end;
              """
      if postscript is not None:
          mscript += postscript
      return mscript
  
imports: import os
  from copy import deepcopy
  from nibabel import load
  import numpy
  from ...None import logging
  from ...utils import spm_docs
  from ..base import BaseInterface, traits, isdefined, InputMultiPath, BaseInterfaceInputSpec, Directory, Undefined, ImageFile, PackageInfo
  from ..base.traits_extension import NoDefaultSpecified
  from ..matlab import MatlabCommand
  from ...external.due import due, Doi, BibTeX
label_desc: Use image node_id 15 for calling the SPMCommand obj's underlying member method code with example usage: obj._make_matlab_command(contents, postscript) and returns: mscript