code: def _localisation_error(resmat, src, function, metric):
      """Compute localisation error metrics for resolution matrix.
  
      Parameters
      ----------
      resmat : array, shape (n_orient * n_locations, n_locations)
          The resolution matrix.
          If not a square matrix and if the number of rows is a multiple of
          number of columns (i.e. n_orient>1), 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 : Source Space
          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).
      metric : str
          What type of localisation error to compute.
  
          - 'peak_err': Peak localisation error (PLE), Euclidean distance between
            peak and true source location, in centimeters.
          - 'cog_err': Centre-of-gravity localisation error (CoG), Euclidean
            distance between CoG and true source location, in centimeters.
  
      Returns
      -------
      locerr : array, shape (n_locations,)
          Localisation error per location (in cm).
      """
      # ensure resolution matrix is square
      # combine rows (Euclidean length) if necessary
      resmat = _rectify_resolution_matrix(resmat)
      locations = _get_src_locations(
          src
      )  # locs used in forw. and inv. operator
      locations = 100.0 * locations  # convert to cm (more common)
      # we want to use absolute values, but doing abs() mases a copy and this
      # can be quite expensive in memory. So let's just use abs() in place below.
  
      # The code below will operate on columns, so transpose if you want CTFs
      if function == "ctf":
          resmat = resmat.T
  
      # Euclidean distance between true location and maximum
      if metric == "peak_err":
          resmax = [
              abs(col).argmax() for col in resmat.T
          ]  # max inds along cols
          maxloc = locations[resmax, :]  # locations of maxima
          diffloc = (
              locations - maxloc
          )  # diff btw true locs and maxima locs
          locerr = np.linalg.norm(diffloc, axis=1)  # Euclidean distance
  
      # centre of gravity
      elif metric == "cog_err":
          locerr = np.empty(
              locations.shape[0]
          )  # initialise result array
          for ii, rr in enumerate(locations):
              resvec = abs(
                  resmat[:, ii].T
              )  # corresponding column of resmat
              cog = resvec.dot(locations) / np.sum(
                  resvec
              )  # centre of gravity
              locerr[ii] = np.sqrt(
                  np.sum((rr - cog) ** 2)
              )  # Euclidean distance
  
      return locerr
  
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 2 for calling a global function with example usage: _localisation_error(resmat, src, function, metric) and returns: locerr