code: def _convert_channel_info(chans):
      """Convert the imported _channels.tsv into the chs element of raw.info."""
      nmeg = nstim = nmisc = nref = 0
  
      if not all(p is None for p in chans["pos"]):
          _, sf = _get_pos_units(chans["pos"])
  
      chs = list()
      for ii in range(len(chans["name"])):
          ch = dict(
              scanno=ii + 1,
              range=1.0,
              cal=1.0,
              loc=np.full(12, np.nan),
              unit_mul=FIFF.FIFF_UNITM_NONE,
              ch_name=chans["name"][ii],
              coil_type=FIFF.FIFFV_COIL_NONE,
          )
          chs.append(ch)
  
          # create the channel information
          if chans["pos"][ii] is not None:
              r0 = chans["pos"][ii].copy() / sf  # mm to m
              ez = chans["ori"][ii].copy()
              ez = ez / np.linalg.norm(ez)
              ex, ey = _get_plane_vectors(ez)
              ch["loc"] = np.concatenate([r0, ex, ey, ez])
  
          if chans["type"][ii] == "MEGMAG":
              nmeg += 1
              ch.update(
                  logno=nmeg,
                  coord_frame=FIFF.FIFFV_COORD_DEVICE,
                  kind=FIFF.FIFFV_MEG_CH,
                  unit=FIFF.FIFF_UNIT_T,
                  coil_type=FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG2,
              )
          elif chans["type"][ii] == "MEGREFMAG":
              nref += 1
              ch.update(
                  logno=nref,
                  coord_frame=FIFF.FIFFV_COORD_UNKNOWN,
                  kind=FIFF.FIFFV_REF_MEG_CH,
                  unit=FIFF.FIFF_UNIT_T,
                  coil_type=FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG2,
              )
          elif chans["type"][ii] == "TRIG":
              nstim += 1
              ch.update(
                  logno=nstim,
                  coord_frame=FIFF.FIFFV_COORD_UNKNOWN,
                  kind=FIFF.FIFFV_STIM_CH,
                  unit=FIFF.FIFF_UNIT_V,
              )
          else:
              nmisc += 1
              ch.update(
                  logno=nmisc,
                  coord_frame=FIFF.FIFFV_COORD_UNKNOWN,
                  kind=FIFF.FIFFV_MISC_CH,
                  unit=FIFF.FIFF_UNIT_NONE,
              )
  
          # set the calibration based on the units - MNE expects T units for meg
          # and V for eeg
          if chans["units"][ii] == "fT":
              ch.update(cal=1e-15)
          elif chans["units"][ii] == "pT":
              ch.update(cal=1e-12)
          elif chans["units"][ii] == "nT":
              ch.update(cal=1e-9)
          elif chans["units"][ii] == "mV":
              ch.update(cal=1e3)
          elif chans["units"][ii] == "uV":
              ch.update(cal=1e6)
  
      return chs
  
imports: import json
  import pathlib
  import numpy
  from ..._fiff._digitization import _make_dig_points
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import _empty_info
  from ..._fiff.utils import _read_segments_file
  from ..._fiff.write import get_new_file_id
  from ...transforms import Transform, apply_trans, get_ras_to_neuromag_trans
  from ...utils import _check_fname, fill_doc, verbose, warn
  from ..base import BaseRaw
  from .sensors import _get_plane_vectors, _get_pos_units, _refine_sensor_orientation, _size2units
label_desc: Use image node_id 2 for calling a global function with example usage: _convert_channel_info(chans) and returns: chs