code: def get_volume_labels_from_aseg(
      mgz_fname, return_colors=False, atlas_ids=None
  ):
      """Return a list of names and colors of segmented volumes.
  
      Parameters
      ----------
      mgz_fname : path-like
          Filename to read. Typically ``aseg.mgz`` or some variant in the
          freesurfer pipeline.
      return_colors : bool
          If True returns also the labels colors.
      atlas_ids : dict | None
          A lookup table providing a mapping from region names (str) to ID values
          (int). Can be None to use the standard Freesurfer LUT.
  
          .. versionadded:: 0.21.0
  
      Returns
      -------
      label_names : list of str
          The names of segmented volumes included in this mgz file.
      label_colors : list of str
          The RGB colors of the labels included in this mgz file.
  
      See Also
      --------
      read_freesurfer_lut
  
      Notes
      -----
      .. versionchanged:: 0.21.0
         The label names are now sorted in the same order as their corresponding
         values in the MRI file.
  
      .. versionadded:: 0.9.0
      """
      nib = _import_nibabel("load MRI atlas data")
      mgz_fname = _check_fname(
          mgz_fname, overwrite="read", must_exist=True, name="mgz_fname"
      )
      atlas = nib.load(mgz_fname)
      data = np.asarray(atlas.dataobj)  # don't need float here
      want = np.unique(data)
      if atlas_ids is None:
          atlas_ids, colors = read_freesurfer_lut()
      elif return_colors:
          raise ValueError(
              "return_colors must be False if atlas_ids are " "provided"
          )
      # restrict to the ones in the MRI, sorted by label name
      keep = np.isin(list(atlas_ids.values()), want)
      keys = sorted(
          (key for ki, key in enumerate(atlas_ids.keys()) if keep[ki]),
          key=lambda x: atlas_ids[x],
      )
      if return_colors:
          colors = [colors[k] for k in keys]
          out = keys, colors
      else:
          out = keys
      return out
  
imports: import os.path
  from gzip import GzipFile
  from pathlib import Path
  import numpy
  from ._fiff.constants import FIFF
  from ._fiff.meas_info import read_fiducials
  from .surface import _read_mri_surface, read_surface
  from .transforms import Transform, _ensure_trans, apply_trans, combine_transforms, invert_transform, read_ras_mni_t
  from .utils import _check_fname, _check_option, _import_nibabel, _validate_type, get_subjects_dir, logger, verbose
label_desc: Use image node_id 8 for calling a global function with example usage: get_volume_labels_from_aseg(mgz_fname, return_colors, atlas_ids) and returns: out