code: def _prepare_ppe_sd(stc_true, stc_est, src, threshold="50%"):
      stc_true = stc_true.copy()
      stc_est = stc_est.copy()
      n_dipoles = 0
      for i, v in enumerate(stc_true.vertices):
          if len(v):
              n_dipoles += len(v)
              r_true = src[i]["rr"][v]
      if n_dipoles != 1:
          raise ValueError(
              "True source must contain only one dipole, got %d."
              % n_dipoles
          )
  
      _, stc_est = _thresholding(None, stc_est, threshold)
  
      r_est = np.empty([0, 3])
      for i, v in enumerate(stc_est.vertices):
          if len(v):
              r_est = np.vstack([r_est, src[i]["rr"][v]])
      return stc_est, r_true, r_est
  
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 20 for calling a global function with example usage: _prepare_ppe_sd(stc_true, stc_est, src, threshold) and returns: stc_est,  r_true,  r_est