@testing.requires_testing_data
@pytest.mark.slowtest
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)
    info['bads'] = info['ch_names'][:200]
    pytest.raises(ValueError, _make_surface_mapping, info, surf, 'foo')
    pytest.raises(ValueError, _make_surface_mapping, info, surf, 'meg', mode='foo')
    evoked_eeg = evoked.copy().pick_types(meg=False, eeg=True)
    pytest.raises(RuntimeError, _make_surface_mapping, evoked_eeg.info, surf, 'meg')
    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
    evoked.pick_types(meg=True, eeg=False)
    evoked.info.normalize_proj()
    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))
    assert (len(fmd[0]['ch_names']) == 106)
    pytest.raises(ValueError, make_field_map, evoked, ch_type='foobar')
    evoked.pick_types(meg=True, eeg=False)
    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))
    assert (len(fmd[0]['ch_names']) == 106)
    pytest.raises(ValueError, make_field_map, evoked, meg_surf='foobar', subjects_dir=subjects_dir, trans=trans_fname)
Test interpolation of MEG field onto helmet | head.
@testing.requires_testing_data
@pytest.mark.slowtest
def test_make_field_map_meg():
    
    evoked = read_evokeds(evoked_fname, condition='Left Auditory')
    info = evoked.info
    surf = get_meg_helmet_surf(info)
    info['bads'] = info['ch_names'][:200]
    pytest.raises(ValueError, _make_surface_mapping, info, surf, 'foo')
    pytest.raises(ValueError, _make_surface_mapping, info, surf, 'meg', mode='foo')
    evoked_eeg = evoked.copy().pick_types(meg=False, eeg=True)
    pytest.raises(RuntimeError, _make_surface_mapping, evoked_eeg.info, surf, 'meg')
    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
    evoked.pick_types(meg=True, eeg=False)
    evoked.info.normalize_proj()
    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))
    assert (len(fmd[0]['ch_names']) == 106)
    pytest.raises(ValueError, make_field_map, evoked, ch_type='foobar')
    evoked.pick_types(meg=True, eeg=False)
    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))
    assert (len(fmd[0]['ch_names']) == 106)
    pytest.raises(ValueError, make_field_map, evoked, meg_surf='foobar', subjects_dir=subjects_dir, trans=trans_fname)