code: def _process_channel_meg(cur_ch, grad):
      """Convert MEG channel from FieldTrip to MNE.
  
      Parameters
      ----------
      cur_ch: dict
          Channel specific dictionary to populate.
  
      grad: dict
          grad dict as loaded from the FieldTrip structure
  
      Returns
      -------
      dict: The original dict (cur_ch) with the added information
      """
      all_labels = np.asanyarray(grad["label"])
      chan_idx_in_grad = np.where(all_labels == cur_ch["ch_name"])[0][0]
      gradtype = grad["type"]
      chantype = grad["chantype"][chan_idx_in_grad]
      position_unit = grad["unit"]
      position = np.squeeze(grad["chanpos"][chan_idx_in_grad, :])
      position = position * _unit_dict[position_unit]
  
      if (
          gradtype == "neuromag306"
          and "tra" in grad
          and "coilpos" in grad
      ):
          # Try to regenerate original channel pos.
          idx_in_coilpos = np.where(
              grad["tra"][chan_idx_in_grad, :] != 0
          )[0]
          cur_coilpos = grad["coilpos"][idx_in_coilpos, :]
          cur_coilpos = cur_coilpos * _unit_dict[position_unit]
          cur_coilori = grad["coilori"][idx_in_coilpos, :]
          if chantype == "megmag":
              position = cur_coilpos[0] - 0.0003 * cur_coilori[0]
          if chantype == "megplanar":
              tmp_pos = cur_coilpos - 0.0003 * cur_coilori
              position = np.average(tmp_pos, axis=0)
  
      original_orientation = np.squeeze(
          grad["chanori"][chan_idx_in_grad, :]
      )
      try:
          orientation = rotation3d_align_z_axis(original_orientation).T
      except AssertionError:
          orientation = np.eye(3)
      assert orientation.shape == (3, 3)
      orientation = orientation.flatten()
      # chanunit = grad['chanunit'][chan_idx_in_grad]  # not used/needed yet
  
      cur_ch["loc"] = np.hstack((position, orientation))
      cur_ch["kind"] = FIFF.FIFFV_MEG_CH
      if chantype == "megmag":
          cur_ch["coil_type"] = FIFF.FIFFV_COIL_POINT_MAGNETOMETER
          cur_ch["unit"] = FIFF.FIFF_UNIT_T
      elif chantype == "megplanar":
          cur_ch["coil_type"] = FIFF.FIFFV_COIL_VV_PLANAR_T1
          cur_ch["unit"] = FIFF.FIFF_UNIT_T_M
      elif chantype == "refmag":
          cur_ch["coil_type"] = FIFF.FIFFV_COIL_MAGNES_REF_MAG
          cur_ch["unit"] = FIFF.FIFF_UNIT_T
      elif chantype == "refgrad":
          cur_ch["coil_type"] = FIFF.FIFFV_COIL_MAGNES_REF_GRAD
          cur_ch["unit"] = FIFF.FIFF_UNIT_T
      elif chantype == "meggrad":
          cur_ch["coil_type"] = FIFF.FIFFV_COIL_AXIAL_GRAD_5CM
          cur_ch["unit"] = FIFF.FIFF_UNIT_T
      else:
          raise RuntimeError("Unexpected coil type: %s." % (chantype,))
  
      cur_ch["coord_frame"] = FIFF.FIFFV_COORD_HEAD
  
      return cur_ch
  
file_path: mne-python/mne/io/fieldtrip/utils.py
imports: import numpy
  from ..._fiff._digitization import DigPoint, _ensure_fiducials_head
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import create_info
  from ..._fiff.pick import pick_info
  from ...transforms import rotation3d_align_z_axis
  from ...utils import _check_pandas_installed, warn
label_desc: Use image node_id 10 for calling a global function with example usage: _process_channel_meg(cur_ch, grad) and returns: cur_ch