class_docstr: Handles SPM version information
  
  If you use `SPMCommand.set_mlab_paths` to set alternate entries for
  matlab_cmd, paths, and use_mcr, then you will need to use the same entries
  to any call in the Info class to maintain memoization. Otherwise, it will
  default to the parameters in the `getinfo` function below.
class_docstr_tok: ["Handles","SPM","version","information","If","you","use","`","SPMCommand.set_mlab_paths","`","to","set","alternate","entries","for","matlab_cmd",",","paths",",","and","use_mcr",",","then","you","will","need","to","use","the","same","entries","to","any","call","in","the","Info","class","to","maintain","memoization",".","Otherwise",",","it","will","default","to","the","parameters","in","the","`","getinfo","`","function","below","."]
docstr: Returns the path to the SPM directory in the Matlab path
  If path not found, returns None.
  
  Parameters
  ----------
  matlab_cmd: str
      Sets the default matlab command. If None, the value of the
      environment variable SPMMCRCMD will be used if set and use_mcr
      is True or the environment variable FORCE_SPMMCR is set.
      If one of FORCE_SPMMCR or SPMMCRCMD is not set, the existence
      of the environment variable MATLABCMD is checked and its value
      is used as the matlab command if possible.
      If none of the above was successful, the fallback value of
      'matlab -nodesktop -nosplash' will be used.
  paths : str
      Add paths to matlab session
  use_mcr : bool
      Whether to use the MATLAB Common Runtime. In this case, the
      matlab_cmd is expected to be a valid MCR call.
  
  Returns
  -------
  spm_path : string representing path to SPM directory
  
      returns None of path not found
code: def getinfo(klass, matlab_cmd=None, paths=None, use_mcr=None):
      """
      Returns the path to the SPM directory in the Matlab path
      If path not found, returns None.
  
      Parameters
      ----------
      matlab_cmd: str
          Sets the default matlab command. If None, the value of the
          environment variable SPMMCRCMD will be used if set and use_mcr
          is True or the environment variable FORCE_SPMMCR is set.
          If one of FORCE_SPMMCR or SPMMCRCMD is not set, the existence
          of the environment variable MATLABCMD is checked and its value
          is used as the matlab command if possible.
          If none of the above was successful, the fallback value of
          'matlab -nodesktop -nosplash' will be used.
      paths : str
          Add paths to matlab session
      use_mcr : bool
          Whether to use the MATLAB Common Runtime. In this case, the
          matlab_cmd is expected to be a valid MCR call.
  
      Returns
      -------
      spm_path : string representing path to SPM directory
  
          returns None of path not found
      """
  
      use_mcr = use_mcr or "FORCE_SPMMCR" in os.environ
      matlab_cmd = matlab_cmd or (
          (use_mcr and os.getenv("SPMMCRCMD"))
          or os.getenv("MATLABCMD", "matlab -nodesktop -nosplash")
      )
  
      if (
          klass._name
          and klass._path
          and klass._version
          and klass._command == matlab_cmd
          and klass._paths == paths
      ):
          return {
              "name": klass._name,
              "path": klass._path,
              "release": klass._version,
          }
      logger.debug(
          "matlab command or path has changed. recomputing version."
      )
      mlab = MatlabCommand(
          matlab_cmd=matlab_cmd, resource_monitor=False
      )
      mlab.inputs.mfile = False
      if paths:
          mlab.inputs.paths = paths
      if use_mcr:
          mlab.inputs.nodesktop = Undefined
          mlab.inputs.nosplash = Undefined
          mlab.inputs.single_comp_thread = Undefined
          mlab.inputs.mfile = True
          mlab.inputs.uses_mcr = True
      mlab.inputs.script = """
  if isempty(which('spm')),
  throw(MException('SPMCheck:NotFound','SPM not in matlab path'));
  end;
  spm_path = spm('dir');
  [name, version] = spm('ver');
  fprintf(1, 'NIPYPE path:%s|name:%s|release:%s', spm_path, name, version);
  exit;
          """
      try:
          out = mlab.run()
      except (OSError, RuntimeError) as e:
          # if no Matlab at all -- exception could be raised
          # No Matlab -- no spm
          logger.debug("%s", e)
          klass._version = None
          klass._path = None
          klass._name = None
          klass._command = matlab_cmd
          klass._paths = paths
          return None
  
      out = sd._strip_header(out.runtime.stdout)
      out_dict = {}
      for part in out.split("|"):
          key, val = part.split(":")
          out_dict[key] = val
  
      klass._version = out_dict["release"]
      klass._path = out_dict["path"]
      klass._name = out_dict["name"]
      klass._command = matlab_cmd
      klass._paths = paths
      return out_dict
  
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 4 for calling the Info obj's underlying member method code with example usage: obj.getinfo(klass, matlab_cmd, paths, use_mcr) and returns: out_dict, dict, None