code: def source_estimate_quantification(stc1, stc2, metric="rms"):
      """Calculate STC similarities across all sources and times.
  
      Parameters
      ----------
      stc1 : SourceEstimate
          First source estimate for comparison.
      stc2 : SourceEstimate
          Second source estimate for comparison.
      metric : str
          Metric to calculate, ``'rms'`` or ``'cosine'``.
  
      Returns
      -------
      score : float | array
          Calculated metric.
  
      Notes
      -----
      Metric calculation has multiple options:
  
          * rms: Root mean square of difference between stc data matrices.
          * cosine: Normalized correlation of all elements in stc data matrices.
  
      .. versionadded:: 0.10.0
      """
      _check_option("metric", metric, ["rms", "cosine"])
  
      # This is checking that the data are having the same size meaning
      # no comparison between distributed and sparse can be done so far.
      _check_stc(stc1, stc2)
      data1, data2 = stc1.data, stc2.data
  
      # Calculate root mean square difference between two matrices
      if metric == "rms":
          score = np.sqrt(np.mean((data1 - data2) ** 2))
      # Calculate correlation coefficient between matrix elements
      elif metric == "cosine":
          score = 1.0 - _cosine(data1, data2)
      return score
  
imports: from functools import partial
  import numpy
  from scipy.spatial.distance import cdist
  from ...utils import _check_option, _validate_type, fill_doc
label_desc: Use image node_id 2 for calling a global function with example usage: source_estimate_quantification(stc1, stc2, metric) and returns: score