class_docstr: Morph source space data from one subject to another.
  
  .. note::
      This class should not be instantiated directly via
      ``mne.SourceMorph(...)``. Instead, use one of the functions
      listed in the See Also section below.
  
  Parameters
  ----------
  subject_from : str | None
      Name of the subject from which to morph as named in the SUBJECTS_DIR.
  subject_to : str | array | list of array
      Name of the subject on which to morph as named in the SUBJECTS_DIR.
      The default is 'fsaverage'. If morphing a volume source space,
      subject_to can be the path to a MRI volume. Can also be a list of
      two arrays if morphing to hemisphere surfaces.
  kind : str | None
      Kind of source estimate. E.g. ``'volume'`` or ``'surface'``.
  zooms : float | tuple
      See :func:`mne.compute_source_morph`.
  niter_affine : tuple of int
      Number of levels (``len(niter_affine)``) and number of
      iterations per level - for each successive stage of iterative
      refinement - to perform the affine transform.
  niter_sdr : tuple of int
      Number of levels (``len(niter_sdr)``) and number of
      iterations per level - for each successive stage of iterative
      refinement - to perform the Symmetric Diffeomorphic Registration (sdr)
      transform :footcite:`AvantsEtAl2008`.
  spacing : int | list | None
      See :func:`mne.compute_source_morph`.
  smooth : int | str | None
      See :func:`mne.compute_source_morph`.
  xhemi : bool
      Morph across hemisphere.
  morph_mat : scipy.sparse.csr_matrix
      The sparse surface morphing matrix for spherical surface
      based morphing :footcite:`GreveEtAl2013`.
  vertices_to : list of ndarray
      The destination surface vertices.
  shape : tuple
      The volume MRI shape.
  affine : ndarray
      The volume MRI affine.
  pre_affine : instance of dipy.align.AffineMap
      The transformation that is applied before the before ``sdr_morph``.
  sdr_morph : instance of dipy.align.DiffeomorphicMap
      The class that applies the the symmetric diffeomorphic registration
      (SDR) morph.
  src_data : dict
      Additional source data necessary to perform morphing.
  vol_morph_mat : scipy.sparse.csr_matrix | None
      The volumetric morph matrix, if :meth:`compute_vol_morph_mat`
      was used.
  %(verbose)s
  
  See Also
  --------
  compute_source_morph
  read_source_morph
  
  Notes
  -----
  .. versionadded:: 0.17
  
  References
  ----------
  .. footbibliography::
class_docstr_tok: ["Morph","source","space","data","from","one","subject","to","another",".","..","note",":",":","This","class","should","not","be","instantiated","directly","via","``","mne.SourceMorph","(","...",")","``",".","Instead",",","use","one","of","the","functions","listed","in","the","See","Also","section","below",".","Parameters","--","--","--","--","--","subject_from",":","str","|","None","Name","of","the","subject","from","which","to","morph","as","named","in","the","SUBJECTS_DIR",".","subject_to",":","str","|","array","|","list","of","array","Name","of","the","subject","on","which","to","morph","as","named","in","the","SUBJECTS_DIR",".","The","default","is","'fsaverage","'",".","If","morphing","a","volume","source","space",",","subject_to","can","be","the","path","to","a","MRI","volume",".","Can","also","be","a","list","of","two","arrays","if","morphing","to","hemisphere","surfaces",".","kind",":","str","|","None","Kind","of","source","estimate",".","E.g",".","``","'volume","'","``","or","``","'surface","'","``",".","zooms",":","float","|","tuple","See",":","func",":","`","mne.compute_source_morph","`",".","niter_affine",":","tuple","of","int","Number","of","levels","(","``","len","(","niter_affine",")","``",")","and","number","of","iterations","per","level","-","for","each","successive","stage","of","iterative","refinement","-","to","perform","the","affine","transform",".","niter_sdr",":","tuple","of","int","Number","of","levels","(","``","len","(","niter_sdr",")","``",")","and","number","of","iterations","per","level","-","for","each","successive","stage","of","iterative","refinement","-","to","perform","the","Symmetric","Diffeomorphic","Registration","(","sdr",")","transform",":","footcite",":","`","AvantsEtAl2008","`",".","spacing",":","int","|","list","|","None","See",":","func",":","`","mne.compute_source_morph","`",".","smooth",":","int","|","str","|","None","See",":","func",":","`","mne.compute_source_morph","`",".","xhemi",":","bool","Morph","across","hemisphere",".","morph_mat",":","scipy.sparse.csr_matrix","The","sparse","surface","morphing","matrix","for","spherical","surface","based","morphing",":","footcite",":","`","GreveEtAl2013","`",".","vertices_to",":","list","of","ndarray","The","destination","surface","vertices",".","shape",":","tuple","The","volume","MRI","shape",".","affine",":","ndarray","The","volume","MRI","affine",".","pre_affine",":","instance","of","dipy.align.AffineMap","The","transformation","that","is","applied","before","the","before","``","sdr_morph","``",".","sdr_morph",":","instance","of","dipy.align.DiffeomorphicMap","The","class","that","applies","the","the","symmetric","diffeomorphic","registration","(","SDR",")","morph",".","src_data",":","dict","Additional","source","data","necessary","to","perform","morphing",".","vol_morph_mat",":","scipy.sparse.csr_matrix","|","None","The","volumetric","morph","matrix",",","if",":","meth",":","`","compute_vol_morph_mat","`","was","used",".","%","(","verbose",")","s","See","Also","--","--","--","--","compute_source_morph","read_source_morph","Notes","--","--","-","..","versionadded",":",":","0.17","References","--","--","--","--","--","..","footbibliography",":",":"]
docstr: Morph source space data.
  
  Parameters
  ----------
  stc_from : VolSourceEstimate | VolVectorSourceEstimate | SourceEstimate | VectorSourceEstimate
      The source estimate to morph.
  output : str
      Can be ``'stc'`` (default) or possibly ``'nifti1'``, or
      ``'nifti2'`` when working with a volume source space defined on a
      regular grid.
  mri_resolution : bool | tuple | int | float
      If True the image is saved in MRI resolution. Default False.
  
      .. warning: If you have many time points the file produced can be
                  huge. The default is ``mri_resolution=False``.
  mri_space : bool | None
      Whether the image to world registration should be in mri space. The
      default (None) is mri_space=mri_resolution.
  %(verbose)s
  
  Returns
  -------
  stc_to : VolSourceEstimate | SourceEstimate | VectorSourceEstimate | Nifti1Image | Nifti2Image
      The morphed source estimates.
docstr_tok: ["Morph","source","space","data",".","Parameters","--","--","--","--","--","stc_from",":","VolSourceEstimate","|","VolVectorSourceEstimate","|","SourceEstimate","|","VectorSourceEstimate","The","source","estimate","to","morph",".","output",":","str","Can","be","``","'stc","'","``","(","default",")","or","possibly","``","'nifti1","'","``",",","or","``","'nifti2","'","``","when","working","with","a","volume","source","space","defined","on","a","regular","grid",".","mri_resolution",":","bool","|","tuple","|","int","|","float","If","True","the","image","is","saved","in","MRI","resolution",".","Default","False",".","..","warning",":","If","you","have","many","time","points","the","file","produced","can","be","huge",".","The","default","is","``","mri_resolution=False","``",".","mri_space",":","bool","|","None","Whether","the","image","to","world","registration","should","be","in","mri","space",".","The","default","(","None",")","is","mri_space=mri_resolution",".","%","(","verbose",")","s","Returns","--","--","--","-","stc_to",":","VolSourceEstimate","|","SourceEstimate","|","VectorSourceEstimate","|","Nifti1Image","|","Nifti2Image","The","morphed","source","estimates","."]
code: def apply(
      self,
      stc_from,
      output="stc",
      mri_resolution=False,
      mri_space=None,
      verbose=None,
  ):
      """Morph source space data.
  
      Parameters
      ----------
      stc_from : VolSourceEstimate | VolVectorSourceEstimate | SourceEstimate | VectorSourceEstimate
          The source estimate to morph.
      output : str
          Can be ``'stc'`` (default) or possibly ``'nifti1'``, or
          ``'nifti2'`` when working with a volume source space defined on a
          regular grid.
      mri_resolution : bool | tuple | int | float
          If True the image is saved in MRI resolution. Default False.
  
          .. warning: If you have many time points the file produced can be
                      huge. The default is ``mri_resolution=False``.
      mri_space : bool | None
          Whether the image to world registration should be in mri space. The
          default (None) is mri_space=mri_resolution.
      %(verbose)s
  
      Returns
      -------
      stc_to : VolSourceEstimate | SourceEstimate | VectorSourceEstimate | Nifti1Image | Nifti2Image
          The morphed source estimates.
      """  # noqa: E501
      _validate_type(output, str, "output")
      _validate_type(
          stc_from, _BaseSourceEstimate, "stc_from", "source estimate"
      )
      if isinstance(stc_from, _BaseSurfaceSourceEstimate):
          allowed_kinds = ("stc",)
          extra = "when stc is a surface source estimate"
      else:
          allowed_kinds = ("stc", "nifti1", "nifti2")
          extra = ""
      _check_option("output", output, allowed_kinds, extra)
      stc = copy.deepcopy(stc_from)
  
      mri_space = mri_resolution if mri_space is None else mri_space
      if stc.subject is None:
          stc.subject = self.subject_from
      if self.subject_from is None:
          self.subject_from = stc.subject
      if stc.subject != self.subject_from:
          raise ValueError(
              "stc_from.subject and "
              "morph.subject_from must match. (%s != %s)"
              % (stc.subject, self.subject_from)
          )
      out = _apply_morph_data(self, stc)
      if output != "stc":  # convert to volume
          out = _morphed_stc_as_volume(
              self,
              out,
              mri_resolution=mri_resolution,
              mri_space=mri_space,
              output=output,
          )
      return out
  
imports: import copy
  import os.path
  import warnings
  import numpy
  from scipy import sparse
  from .fixes import _get_img_fdata
  from .morph_map import read_morph_map
  from .parallel import parallel_func
  from .source_estimate import _BaseSourceEstimate, _BaseSurfaceSourceEstimate, _BaseVolSourceEstimate, _get_ico_tris
  from .source_space._source_space import SourceSpaces, _ensure_src, _grid_interp
  from .surface import _compute_nearest, mesh_edges, read_surface
  from .utils import BunchConst, ProgressBar, _check_fname, _check_option, _custom_lru_cache, _ensure_int, _import_h5io_funcs, _import_nibabel, _validate_type, check_version, fill_doc, get_subjects_dir, logger, use_log_level, verbose, warn
  from .utils import warn
label_desc: Use image node_id 5 for calling the SourceMorph obj's underlying member method code with example usage: obj.apply(stc_from, output, mri_resolution, mri_space, verbose) and returns: out