code: def test_make_field_map_meg():
      """Test interpolation of MEG field onto helmet | head."""
      evoked = read_evokeds(evoked_fname, condition="Left Auditory")
      info = evoked.info
      surf = get_meg_helmet_surf(info)
      # let's reduce the number of channels by a bunch to speed it up
      info["bads"] = info["ch_names"][:200]
      # bad ch_type
      pytest.raises(
          ValueError, _make_surface_mapping, info, surf, "foo"
      )
      # bad mode
      pytest.raises(
          ValueError,
          _make_surface_mapping,
          info,
          surf,
          "meg",
          mode="foo",
      )
      # no picks
      evoked_eeg = evoked.copy().pick(picks="eeg")
      pytest.raises(
          RuntimeError,
          _make_surface_mapping,
          evoked_eeg.info,
          surf,
          "meg",
      )
      # bad surface def
      nn = surf["nn"]
      del surf["nn"]
      pytest.raises(KeyError, _make_surface_mapping, info, surf, "meg")
      surf["nn"] = nn
      cf = surf["coord_frame"]
      del surf["coord_frame"]
      pytest.raises(KeyError, _make_surface_mapping, info, surf, "meg")
      surf["coord_frame"] = cf
  
      # now do it with make_field_map
      evoked.pick(picks="meg")
      evoked.info.normalize_proj()  # avoid projection warnings
      fmd = make_field_map(
          evoked, None, subject="sample", subjects_dir=subjects_dir
      )
      assert len(fmd) == 1
      assert_array_equal(
          fmd[0]["data"].shape, (304, 106)
      )  # maps data onto surf
      assert len(fmd[0]["ch_names"]) == 106
  
      pytest.raises(
          ValueError, make_field_map, evoked, ch_type="foobar"
      )
  
      # now test the make_field_map on head surf for MEG
      evoked.pick(picks="meg")
      evoked.info.normalize_proj()
      fmd = make_field_map(
          evoked,
          trans_fname,
          meg_surf="head",
          subject="sample",
          subjects_dir=subjects_dir,
      )
      assert len(fmd) == 1
      assert_array_equal(
          fmd[0]["data"].shape, (642, 106)
      )  # maps data onto surf
      assert len(fmd[0]["ch_names"]) == 106
  
      pytest.raises(
          ValueError,
          make_field_map,
          evoked,
          meg_surf="foobar",
          subjects_dir=subjects_dir,
          trans=trans_fname,
      )
  
imports: from os import path
  from pathlib import Path
  import numpy
  import pytest
  from numpy.polynomial import legendre
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy.interpolate import interp1d
  import mne
  from mne import Epochs, make_fixed_length_events, pick_types, read_evokeds
  from mne.datasets import testing
  from mne.forward import _make_surface_mapping, make_field_map
  from mne.forward._field_interpolation import _setup_dots
  from mne.forward._lead_dots import _comp_sum_eeg, _comp_sums_meg, _do_cross_dots, _get_legen_table
  from mne.forward._make_forward import _create_meg_coils
  from mne.io import read_raw_fif
  from mne.surface import get_head_surf, get_meg_helmet_surf
label_desc: Use image node_id 5 for calling a global function with example usage: test_make_field_map_meg() without return types