code: def _set_stimchannels(inst, info, stim, stim_code):
      """Specify how the trigger channel is synthesized from analog channels.
  
      Has to be done before loading data. For a RawKIT instance that has been
      created with preload=True, this method will raise a
      NotImplementedError.
  
      Parameters
      ----------
      %(info_not_none)s
      stim : list of int | '<' | '>'
          Can be submitted as list of trigger channels.
          If a list is not specified, the default triggers extracted from
          misc channels will be used with specified directionality.
          '<' means that largest values assigned to the first channel
          in sequence.
          '>' means the largest trigger assigned to the last channel
          in sequence.
      stim_code : 'binary' | 'channel'
          How to decode trigger values from stim channels. 'binary' read stim
          channel events as binary code, 'channel' encodes channel number.
      """
      if inst.preload:
          raise NotImplementedError(
              "Can't change stim channel after loading data"
          )
      _check_option("stim_code", stim_code, ["binary", "channel"])
  
      if stim is not None:
          if isinstance(stim, str):
              picks = _default_stim_chs(info)
              if stim == "<":
                  stim = picks[::-1]
              elif stim == ">":
                  stim = picks
              else:
                  raise ValueError(
                      "stim needs to be list of int, '>' or "
                      "'<', not %r" % str(stim)
                  )
          else:
              stim = np.asarray(stim, int)
              if stim.max() >= inst._raw_extras[0]["nchan"]:
                  raise ValueError(
                      "Got stim=%s, but sqd file only has %i channels"
                      % (stim, inst._raw_extras[0]["nchan"])
                  )
  
          # modify info
          nchan = inst._raw_extras[0]["nchan"] + 1
          info["chs"].append(
              dict(
                  cal=KIT.CALIB_FACTOR,
                  logno=nchan,
                  scanno=nchan,
                  range=1.0,
                  unit=FIFF.FIFF_UNIT_NONE,
                  unit_mul=FIFF.FIFF_UNITM_NONE,
                  ch_name="STI 014",
                  coil_type=FIFF.FIFFV_COIL_NONE,
                  loc=np.full(12, np.nan),
                  kind=FIFF.FIFFV_STIM_CH,
                  coord_frame=FIFF.FIFFV_COORD_UNKNOWN,
              )
          )
          info._update_redundant()
  
      inst._raw_extras[0]["stim"] = stim
      inst._raw_extras[0]["stim_code"] = stim_code
  
imports: from collections import OrderedDict, defaultdict
  from math import cos, sin
  from os import SEEK_CUR, PathLike
  from os import path
  from pathlib import Path
  import numpy
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import _empty_info
  from ..._fiff.pick import pick_types
  from ..._fiff.utils import _mult_cal_one
  from ...epochs import BaseEpochs
  from ...event import read_events
  from ...transforms import als_ras_trans, apply_trans
  from ...utils import _check_fname, _check_option, _stamp_to_dt, fill_doc, logger, verbose, warn
  from ..base import BaseRaw
  from .constants import KIT, LEGACY_AMP_PARAMS
  from .coreg import _set_dig_kit, read_mrk
label_desc: Use image node_id 2 for calling a global function with example usage: _set_stimchannels(inst, info, stim, stim_code) without return types