code: def make_1020_channel_selections(
      info, midline="z", *, return_ch_names=False
  ):
      """Map hemisphere names to corresponding EEG channel names or indices.
  
      This function uses a simple heuristic to separate channel names into three
      Region of Interest-based selections: ``Left``, ``Midline`` and ``Right``.
  
      The heuristic is that any of the channel names ending
      with odd numbers are filed under ``Left``; those ending with even numbers
      are filed under ``Right``; and those ending with the character(s) specified
      in ``midline`` are filed under ``Midline``. Other channels are ignored.
  
      This is appropriate for 10/20, 10/10, 10/05, …, sensor arrangements, but
      not for other naming conventions.
  
      Parameters
      ----------
      %(info_not_none)s If channel locations are present, the channel lists will
          be sorted from posterior to anterior; otherwise, the order specified in
          ``info["ch_names"]`` will be kept.
      midline : str
          Names ending in any of these characters are stored under the
          ``Midline`` key. Defaults to ``'z'``. Capitalization is ignored.
      return_ch_names : bool
          Whether to return channel names instead of channel indices.
  
          .. versionadded:: 1.4.0
  
      Returns
      -------
      selections : dict
          A dictionary mapping from region of interest name to a list of channel
          indices (if ``return_ch_names=False``) or to a list of channel names
          (if ``return_ch_names=True``).
      """
      _validate_type(info, "info")
  
      try:
          from .layout import find_layout
  
          layout = find_layout(info)
          pos = layout.pos
          ch_names = layout.names
      except RuntimeError:  # no channel positions found
          ch_names = info["ch_names"]
          pos = None
  
      selections = dict(Left=[], Midline=[], Right=[])
      for pick, channel in enumerate(ch_names):
          last_char = channel[
              -1
          ].lower()  # in 10/20, last char codes hemisphere
          if last_char in midline:
              selection = "Midline"
          elif last_char.isdigit():
              selection = "Left" if int(last_char) % 2 else "Right"
          else:  # ignore the channel
              continue
          selections[selection].append(pick)
  
      if pos is not None:
          # sort channels from front to center
          # (y-coordinate of the position info in the layout)
          selections = {
              selection: np.array(picks)[pos[picks, 1].argsort()]
              for selection, picks in selections.items()
          }
  
      # convert channel indices to names if requested
      if return_ch_names:
          for selection, ch_indices in selections.items():
              selections[selection] = [
                  info.ch_names[idx] for idx in ch_indices
              ]
  
      return selections
  
imports: import os.path
  import string
  import sys
  from collections import OrderedDict
  from copy import deepcopy
  from dataclasses import dataclass
  from functools import partial
  from pathlib import Path
  from typing import Union
  import numpy
  from scipy.io import loadmat
  from scipy.sparse import csr_matrix, lil_matrix
  from scipy.spatial import Delaunay
  from scipy.stats import zscore
  from .._fiff.constants import FIFF
  from .._fiff.meas_info import Info, MontageMixin, _merge_info, _rename_comps, _unit2human, create_info
  from .._fiff.pick import _check_excludes_includes, _pick_data_channels, _picks_by_type, _picks_to_idx, _second_rules, channel_indices_by_type, channel_type, pick_channels, pick_info, pick_types
  from .._fiff.proj import setup_proj
  from .._fiff.reference import add_reference_channels, set_eeg_reference
  from .._fiff.tag import _rename_list
  from ..bem import _check_origin
  from ..defaults import HEAD_SIZE_DEFAULT, _handle_default
  from ..utils import _check_dict_keys, _check_fname, _check_option, _check_preload, _get_stim_channel, _on_missing, _validate_type, fill_doc, legacy, logger, verbose, warn
label_desc: Use image node_id 14 for calling a global function with example usage: make_1020_channel_selections(info, midline) and returns: selections