code: def select_source_in_label(
      src,
      label,
      random_state=None,
      location="random",
      subject=None,
      subjects_dir=None,
      surf="sphere",
  ):
      """Select source positions using a label.
  
      Parameters
      ----------
      src : list of dict
          The source space.
      label : Label
          The label.
      %(random_state)s
      location : str
          The label location to choose. Can be 'random' (default) or 'center'
          to use :func:`mne.Label.center_of_mass` (restricting to vertices
          both in the label and in the source space). Note that for 'center'
          mode the label values are used as weights.
  
          .. versionadded:: 0.13
      subject : str | None
          The subject the label is defined for.
          Only used with ``location='center'``.
  
          .. versionadded:: 0.13
      %(subjects_dir)s
  
          .. versionadded:: 0.13
      surf : str
          The surface to use for Euclidean distance center of mass
          finding. The default here is "sphere", which finds the center
          of mass on the spherical surface to help avoid potential issues
          with cortical folding.
  
          .. versionadded:: 0.13
  
      Returns
      -------
      lh_vertno : list
          Selected source coefficients on the left hemisphere.
      rh_vertno : list
          Selected source coefficients on the right hemisphere.
      """
      lh_vertno = list()
      rh_vertno = list()
      _check_option("location", location, ["random", "center"])
  
      rng = check_random_state(random_state)
      if label.hemi == "lh":
          vertno = lh_vertno
          hemi_idx = 0
      else:
          vertno = rh_vertno
          hemi_idx = 1
      src_sel = np.intersect1d(src[hemi_idx]["vertno"], label.vertices)
      if location == "random":
          idx = src_sel[rng_uniform(rng)(0, len(src_sel), 1)[0]]
      else:  # 'center'
          idx = label.center_of_mass(
              subject,
              restrict_vertices=src_sel,
              subjects_dir=subjects_dir,
              surf=surf,
          )
      vertno.append(idx)
      return lh_vertno, rh_vertno
  
file_path: mne-python/mne/simulation/source.py
imports: import numpy
  from ..fixes import rng_uniform
  from ..label import Label
  from ..source_estimate import SourceEstimate, VolSourceEstimate
  from ..source_space._source_space import _ensure_src
  from ..surface import _compute_nearest
  from ..utils import _check_option, _ensure_events, _ensure_int, check_random_state, fill_doc, warn
label_desc: Use image node_id 1 for calling a global function with example usage: select_source_in_label(src, label, random_state, location, subject, subjects_dir, surf) and returns: lh_vertno,  rh_vertno