code: def _get_montage_information(eeg, get_pos, *, montage_units):
      """Get channel name, type and montage information from ['chanlocs']."""
      ch_names, ch_types, pos_ch_names, pos = (
          list(),
          list(),
          list(),
          list(),
      )
      unknown_types = dict()
      for chanloc in eeg.chanlocs:
          # channel name
          ch_names.append(chanloc["labels"])
  
          # channel type
          ch_type = "eeg"
          try_type = chanloc.get("type", None)
          if isinstance(try_type, str):
              try_type = try_type.strip().lower()
              if try_type in _PICK_TYPES_KEYS:
                  ch_type = try_type
              else:
                  if try_type in unknown_types:
                      unknown_types[try_type].append(chanloc["labels"])
                  else:
                      unknown_types[try_type] = [chanloc["labels"]]
          ch_types.append(ch_type)
  
          # channel loc
          if get_pos:
              loc_x = _to_loc(chanloc["X"])
              loc_y = _to_loc(chanloc["Y"])
              loc_z = _to_loc(chanloc["Z"])
              locs = np.r_[-loc_y, loc_x, loc_z]
              pos_ch_names.append(chanloc["labels"])
              pos.append(locs)
  
      # warn if unknown types were provided
      if len(unknown_types):
          warn(
              "Unknown types found, setting as type EEG:\n"
              + "\n".join(
                  [
                      f"{key}: {sorted(unknown_types[key])}"
                      for key in sorted(unknown_types)
                  ]
              )
          )
  
      lpa, rpa, nasion = None, None, None
      if hasattr(eeg, "chaninfo") and isinstance(
          eeg.chaninfo["nodatchans"], dict
      ):
          nodatchans = eeg.chaninfo["nodatchans"]
          types = nodatchans.get("type", [])
          descriptions = nodatchans.get("description", [])
          xs = nodatchans.get("X", [])
          ys = nodatchans.get("Y", [])
          zs = nodatchans.get("Z", [])
  
          for type_, description, x, y, z in zip(
              types, descriptions, xs, ys, zs
          ):
              if type_ != "FID":
                  continue
              if description == "Nasion":
                  nasion = np.array([x, y, z])
              elif description == "Right periauricular point":
                  rpa = np.array([x, y, z])
              elif description == "Left periauricular point":
                  lpa = np.array([x, y, z])
  
      # Always check this even if it's not used
      _check_option(
          "montage_units",
          montage_units,
          ("m", "dm", "cm", "mm", "auto"),
      )
      if pos_ch_names:
          pos_array = np.array(pos, float)
          pos_array.shape = (-1, 3)
  
          # roughly estimate head radius and check if its reasonable
          is_nan_pos = np.isnan(pos).any(axis=1)
          if not is_nan_pos.all():
              mean_radius = np.mean(
                  np.linalg.norm(pos_array[~is_nan_pos], axis=1)
              )
              scale_units = _handle_montage_units(
                  montage_units, mean_radius
              )
              mean_radius *= scale_units
              pos_array *= scale_units
              additional_info = (
                  " Check if the montage_units argument is correct (the default "
                  'is "mm", but your channel positions may be in different units'
                  ")."
              )
              _check_head_radius(mean_radius, add_info=additional_info)
  
          montage = make_dig_montage(
              ch_pos=dict(zip(ch_names, pos_array)),
              coord_frame="head",
              lpa=lpa,
              rpa=rpa,
              nasion=nasion,
          )
          _ensure_fiducials_head(montage.dig)
      else:
          montage = None
  
      return ch_names, ch_types, montage
  
imports: import os.path
  from os import PathLike
  from pathlib import Path
  import numpy
  from mne.utils.check import _check_option
  from ..._fiff._digitization import _ensure_fiducials_head
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import create_info
  from ..._fiff.pick import _PICK_TYPES_KEYS
  from ..._fiff.utils import _find_channels, _read_segments_file
  from ...annotations import Annotations, read_annotations
  from ...channels import make_dig_montage
  from ...defaults import DEFAULTS
  from ...epochs import BaseEpochs
  from ...event import read_events
  from ...utils import Bunch, _check_fname, _check_head_radius, fill_doc, logger, verbose, warn
  from ..base import BaseRaw
  from ._eeglab import _readmat
label_desc: Use image node_id 5 for calling a global function with example usage: _get_montage_information(eeg, get_pos) and returns: ch_names,  ch_types,  montage