code: def _create_info(ft_struct, raw_info):
      """Create MNE info structure from a FieldTrip structure."""
      if raw_info is None:
          warn(NOINFO_WARNING)
  
      sfreq = _set_sfreq(ft_struct)
      ch_names = ft_struct["label"]
      if raw_info:
          info = raw_info.copy()
          missing_channels = set(ch_names) - set(info["ch_names"])
          if missing_channels:
              warn(
                  "The following channels are present in the FieldTrip data "
                  "but cannot be found in the provided info: %s.\n"
                  "These channels will be removed from the resulting data!"
                  % (str(missing_channels),)
              )
  
              missing_chan_idx = [
                  ch_names.index(ch) for ch in missing_channels
              ]
              new_chs = [
                  ch for ch in ch_names if ch not in missing_channels
              ]
              ch_names = new_chs
              ft_struct["label"] = ch_names
  
              if "trial" in ft_struct:
                  ft_struct[
                      "trial"
                  ] = _remove_missing_channels_from_trial(
                      ft_struct["trial"], missing_chan_idx
                  )
  
              if "avg" in ft_struct:
                  if ft_struct["avg"].ndim == 2:
                      ft_struct["avg"] = np.delete(
                          ft_struct["avg"], missing_chan_idx, axis=0
                      )
  
          with info._unlock():
              info["sfreq"] = sfreq
          ch_idx = [info["ch_names"].index(ch) for ch in ch_names]
          pick_info(info, ch_idx, copy=False)
      else:
          info = create_info(ch_names, sfreq)
          chs, dig = _create_info_chs_dig(ft_struct)
          with info._unlock(update_redundant=True):
              info.update(chs=chs, dig=dig)
  
      return info
  
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 2 for calling a global function with example usage: _create_info(ft_struct, raw_info) and returns: info