code: def find_parcellation_cut_coords(
      labels_img,
      background_label=0,
      return_label_names=False,
      label_hemisphere="left",
  ):
      """Return coordinates of center of mass of 3D :term:`parcellation` atlas.
  
      Parameters
      ----------
      labels_img : 3D Nifti1Image
          A brain :term:`parcellation` atlas with specific mask labels for each
          parcellated region.
  
      background_label : int, default=0
          Label value used in labels_img to represent background.
  
      return_label_names : bool, default=False
          Returns list of labels.
  
      label_hemisphere : 'left' or 'right', default='left'
          Choice of hemisphere to compute label center coords for.
          Applies only in cases where atlas labels are lateralized.
          Eg. Yeo or Harvard Oxford atlas.
  
      Returns
      -------
      coords : numpy.ndarray of shape (n_labels, 3)
          Label regions cut coordinates in image space (mm).
  
      labels_list : list, optional
          Label region. Returned only when return_label_names is True.
  
      See Also
      --------
      nilearn.plotting.find_probabilistic_atlas_cut_coords : For coordinates
          extraction on probabilistic atlases (4D) (Eg. MSDL atlas)
  
      """
      # check label_hemisphere input
      if label_hemisphere not in ["left", "right"]:
          raise ValueError(
              f"Invalid label_hemisphere name:{label_hemisphere}.\n"
              "Should be one of these 'left' or 'right'."
          )
      # Grab data and affine
      labels_img = reorder_img(check_niimg_3d(labels_img))
      labels_data = get_data(labels_img)
      labels_affine = labels_img.affine
  
      # Grab number of unique values in 3d image
      unique_labels = np.unique(labels_data)
      unique_labels = np.delete(unique_labels, background_label)
  
      # Loop over parcellation labels, grab center of mass and dump into coords
      # list
      coord_list = []
      label_list = []
  
      for cur_label in unique_labels:
          cur_img = labels_data == cur_label
  
          # Grab hemispheres separately
          x, y, z = coord_transform(
              0, 0, 0, np.linalg.inv(labels_affine)
          )
          left_hemi = get_data(labels_img).copy() == cur_label
          right_hemi = get_data(labels_img).copy() == cur_label
          left_hemi[int(x) :] = 0
          right_hemi[: int(x)] = 0
  
          # Two connected component in both hemispheres
          left_hemi_has_values = np.any(left_hemi)
          right_hemi_all_zero = not np.any(right_hemi)
          if left_hemi_has_values or right_hemi_all_zero:
              if label_hemisphere == "left":
                  cur_img = left_hemi.astype(int)
              elif label_hemisphere == "right":
                  cur_img = right_hemi.astype(int)
  
          # Take the largest connected component
          labels, _ = label(cur_img)
          label_count = np.bincount(labels.ravel().astype(int))
          label_count[0] = 0
          component = labels == label_count.argmax()
  
          # Get parcellation center of mass
          x, y, z = center_of_mass(component)
  
          # Dump label region and coordinates into a dictionary
          label_list.append(cur_label)
          coord_list.append((x, y, z))
  
          # Transform coordinates
          coords = [
              coord_transform(i[0], i[1], i[2], labels_affine)
              for i in coord_list
          ]
  
      if return_label_names:
          return np.array(coords), label_list
      else:
          return np.array(coords)
  
file_path: nilearn/nilearn/plotting/find_cuts.py
imports: import numbers
  import warnings
  import numpy
  from scipy.ndimage import center_of_mass, find_objects, label
  from nilearn.image import get_data
  from .._utils import check_niimg_3d, check_niimg_4d
  from .._utils.extmath import fast_abs_percentile
  from .._utils.ndimage import largest_connected_component
  from .._utils.niimg import safe_get_data
  from .._utils.numpy_conversions import as_ndarray
  from ..image import iter_img, new_img_like, reorder_img
  from ..image.image import smooth_array
  from ..image.resampling import coord_transform, get_mask_bounds
label_desc: Use image node_id 5 for calling a global function with example usage: find_parcellation_cut_coords(labels_img, background_label, return_label_names, label_hemisphere) and returns: np,  label_list, np