code: def resolution_metrics(
      resmat,
      src,
      function="psf",
      metric="peak_err",
      threshold=0.5,
      verbose=None,
  ):
      """Compute spatial resolution metrics for linear solvers.
  
      Parameters
      ----------
      resmat : array, shape (n_orient * n_vertices, n_vertices)
          The resolution matrix.
          If not a square matrix and if the number of rows is a multiple of
          number of columns (e.g. free or loose orientations), then the Euclidean
          length per source location is computed (e.g. if inverse operator with
          free orientations was applied to forward solution with fixed
          orientations).
      src : instance of SourceSpaces
          Source space object from forward or inverse operator.
      function : 'psf' | 'ctf'
          Whether to compute metrics for columns (point-spread functions, PSFs)
          or rows (cross-talk functions, CTFs) of the resolution matrix.
      metric : str
          The resolution metric to compute. Allowed options are:
  
          Localization-based metrics:
  
          - ``'peak_err'`` Peak localization error (PLE), Euclidean distance
            between peak and true source location.
          - ``'cog_err'`` Centre-of-gravity localisation error (CoG), Euclidean
            distance between CoG and true source location.
  
          Spatial-extent-based metrics:
  
          - ``'sd_ext'`` Spatial deviation
            (e.g. :footcite:`MolinsEtAl2008,HaukEtAl2019`).
          - ``'maxrad_ext'`` Maximum radius to 50%% of max amplitude.
  
          Amplitude-based metrics:
  
          - ``'peak_amp'`` Ratio between absolute maximum amplitudes of peaks
            per location and maximum peak across locations.
          - ``'sum_amp'`` Ratio between sums of absolute amplitudes.
  
      threshold : float
          Amplitude fraction threshold for spatial extent metric 'maxrad_ext'.
          Defaults to 0.5.
      %(verbose)s
  
      Returns
      -------
      resolution_metric : instance of SourceEstimate
          The resolution metric.
  
      Notes
      -----
      For details, see :footcite:`MolinsEtAl2008,HaukEtAl2019`.
  
      .. versionadded:: 0.20
  
      References
      ----------
      .. footbibliography::
      """
      # Check if input options are valid
      metrics = (
          "peak_err",
          "cog_err",
          "sd_ext",
          "maxrad_ext",
          "peak_amp",
          "sum_amp",
      )
      if metric not in metrics:
          raise ValueError('"%s" is not a recognized metric.' % metric)
  
      if function not in ["psf", "ctf"]:
          raise ValueError(
              "Not a recognised resolution function: %s." % function
          )
  
      if metric in ("peak_err", "cog_err"):
          resolution_metric = _localisation_error(
              resmat, src, function=function, metric=metric
          )
  
      elif metric in ("sd_ext", "maxrad_ext"):
          resolution_metric = _spatial_extent(
              resmat,
              src,
              function=function,
              metric=metric,
              threshold=threshold,
          )
  
      elif metric in ("peak_amp", "sum_amp"):
          resolution_metric = _relative_amplitude(
              resmat, src, function=function, metric=metric
          )
  
      # get vertices from source space
      vertno_lh = src[0]["vertno"]
      vertno_rh = src[1]["vertno"]
      vertno = [vertno_lh, vertno_rh]
  
      # Convert array to source estimate
      resolution_metric = SourceEstimate(
          resolution_metric, vertno, tmin=0.0, tstep=1.0
      )
  
      return resolution_metric
  
file_path: mne-python/mne/minimum_norm/spatial_resolution.py
imports: import numpy
  from ..source_estimate import SourceEstimate
  from ..utils import _check_option, logger, verbose
label_desc: Use image node_id 1 for calling a global function with example usage: resolution_metrics(resmat, src, function, metric, threshold, verbose) and returns: resolution_metric