code: def _check_meg_type(meg, allow_auto=False):
      """Ensure a valid meg type."""
      if isinstance(meg, str):
          allowed_types = ["grad", "mag", "planar1", "planar2"]
          allowed_types += ["auto"] if allow_auto else []
          if meg not in allowed_types:
              raise ValueError(
                  f"meg value must be one of {allowed_types} or bool, not {meg}"
              )
  
imports: import re
  from copy import deepcopy
  import numpy
  from ..utils import _check_option, _ensure_int, _validate_type, fill_doc, logger, verbose, warn
  from .constants import FIFF
label_desc: Use image node_id 8 for calling a global function with example usage: _check_meg_type(meg, allow_auto) without return types