本文整理汇总了Python中mne.read_cov函数的典型用法代码示例。如果您正苦于以下问题:Python read_cov函数的具体用法?Python read_cov怎么用?Python read_cov使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_cov函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cov_estimation_on_raw_segment
def test_cov_estimation_on_raw_segment():
"""Test estimation from raw on continuous recordings (typically empty room)
"""
tempdir = _TempDir()
raw = Raw(raw_fname, preload=False)
cov = compute_raw_data_covariance(raw)
cov_mne = read_cov(erm_cov_fname)
assert_true(cov_mne.ch_names == cov.ch_names)
assert_true(linalg.norm(cov.data - cov_mne.data, ord='fro')
/ linalg.norm(cov.data, ord='fro') < 1e-4)
# test IO when computation done in Python
cov.save(op.join(tempdir, 'test-cov.fif')) # test saving
cov_read = read_cov(op.join(tempdir, 'test-cov.fif'))
assert_true(cov_read.ch_names == cov.ch_names)
assert_true(cov_read.nfree == cov.nfree)
assert_array_almost_equal(cov.data, cov_read.data)
# test with a subset of channels
picks = pick_channels(raw.ch_names, include=raw.ch_names[:5])
cov = compute_raw_data_covariance(raw, picks=picks)
assert_true(cov_mne.ch_names[:5] == cov.ch_names)
assert_true(linalg.norm(cov.data - cov_mne.data[picks][:, picks],
ord='fro') / linalg.norm(cov.data, ord='fro') < 1e-4)
# make sure we get a warning with too short a segment
raw_2 = raw.crop(0, 1)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
cov = compute_raw_data_covariance(raw_2)
assert_true(len(w) == 1)
示例2: test_cov_estimation_with_triggers
def test_cov_estimation_with_triggers():
"""Test estimation from raw with triggers
"""
events = find_events(raw)
event_ids = [1, 2, 3, 4]
reject = dict(grad=10000e-13, mag=4e-12, eeg=80e-6, eog=150e-6)
# cov with merged events and keep_sample_mean=True
events_merged = merge_events(events, event_ids, 1234)
epochs = Epochs(raw, events_merged, 1234, tmin=-0.2, tmax=0,
baseline=(-0.2, -0.1), proj=True,
reject=reject, preload=True)
cov = compute_covariance(epochs, keep_sample_mean=True)
cov_mne = read_cov(cov_km_fname)
assert_true(cov_mne.ch_names == cov.ch_names)
assert_true((linalg.norm(cov.data - cov_mne.data, ord='fro')
/ linalg.norm(cov.data, ord='fro')) < 0.005)
# Test with tmin and tmax (different but not too much)
cov_tmin_tmax = compute_covariance(epochs, tmin=-0.19, tmax=-0.01)
assert_true(np.all(cov.data != cov_tmin_tmax.data))
assert_true((linalg.norm(cov.data - cov_tmin_tmax.data, ord='fro')
/ linalg.norm(cov_tmin_tmax.data, ord='fro')) < 0.05)
# cov using a list of epochs and keep_sample_mean=True
epochs = [Epochs(raw, events, ev_id, tmin=-0.2, tmax=0,
baseline=(-0.2, -0.1), proj=True, reject=reject)
for ev_id in event_ids]
cov2 = compute_covariance(epochs, keep_sample_mean=True)
assert_array_almost_equal(cov.data, cov2.data)
assert_true(cov.ch_names == cov2.ch_names)
# cov with keep_sample_mean=False using a list of epochs
cov = compute_covariance(epochs, keep_sample_mean=False)
cov_mne = read_cov(cov_fname)
assert_true(cov_mne.ch_names == cov.ch_names)
assert_true((linalg.norm(cov.data - cov_mne.data, ord='fro')
/ linalg.norm(cov.data, ord='fro')) < 0.005)
# test IO when computation done in Python
cov.save('test-cov.fif') # test saving
cov_read = read_cov('test-cov.fif')
assert_true(cov_read.ch_names == cov.ch_names)
assert_true(cov_read.nfree == cov.nfree)
assert_true((linalg.norm(cov.data - cov_read.data, ord='fro')
/ linalg.norm(cov.data, ord='fro')) < 1e-5)
# cov with list of epochs with different projectors
epochs = [Epochs(raw, events[:4], event_ids[0], tmin=-0.2, tmax=0,
baseline=(-0.2, -0.1), proj=True, reject=reject),
Epochs(raw, events[:4], event_ids[0], tmin=-0.2, tmax=0,
baseline=(-0.2, -0.1), proj=False, reject=reject)]
# these should fail
assert_raises(ValueError, compute_covariance, epochs)
assert_raises(ValueError, compute_covariance, epochs, projs=None)
# these should work, but won't be equal to above
cov = compute_covariance(epochs, projs=epochs[0].info['projs'])
cov = compute_covariance(epochs, projs=[])
示例3: test_cov_estimation_on_raw
def test_cov_estimation_on_raw():
"""Test estimation from raw (typically empty room)"""
tempdir = _TempDir()
raw = Raw(raw_fname, preload=False)
cov_mne = read_cov(erm_cov_fname)
cov = compute_raw_covariance(raw, tstep=None)
assert_equal(cov.ch_names, cov_mne.ch_names)
assert_equal(cov.nfree, cov_mne.nfree)
assert_snr(cov.data, cov_mne.data, 1e4)
cov = compute_raw_covariance(raw) # tstep=0.2 (default)
assert_equal(cov.nfree, cov_mne.nfree - 119) # cutoff some samples
assert_snr(cov.data, cov_mne.data, 1e2)
# test IO when computation done in Python
cov.save(op.join(tempdir, 'test-cov.fif')) # test saving
cov_read = read_cov(op.join(tempdir, 'test-cov.fif'))
assert_true(cov_read.ch_names == cov.ch_names)
assert_true(cov_read.nfree == cov.nfree)
assert_array_almost_equal(cov.data, cov_read.data)
# test with a subset of channels
picks = pick_channels(raw.ch_names, include=raw.ch_names[:5])
cov = compute_raw_covariance(raw, picks=picks, tstep=None)
assert_true(cov_mne.ch_names[:5] == cov.ch_names)
assert_snr(cov.data, cov_mne.data[picks][:, picks], 1e4)
cov = compute_raw_covariance(raw, picks=picks)
assert_snr(cov.data, cov_mne.data[picks][:, picks], 90) # cutoff samps
# make sure we get a warning with too short a segment
raw_2 = raw.crop(0, 1)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
cov = compute_raw_covariance(raw_2)
assert_true(any('Too few samples' in str(ww.message) for ww in w))
示例4: test_cov_estimation_on_raw_segment
def test_cov_estimation_on_raw_segment():
"""Estimate raw on continuous recordings (typically empty room)
"""
raw = Raw(raw_fname)
cov = compute_raw_data_covariance(raw)
cov_mne = read_cov(erm_cov_fname)
assert_true(cov_mne.ch_names == cov.ch_names)
print (linalg.norm(cov.data - cov_mne.data, ord='fro')
/ linalg.norm(cov.data, ord='fro'))
assert_true(linalg.norm(cov.data - cov_mne.data, ord='fro')
/ linalg.norm(cov.data, ord='fro')) < 1e-6
# test IO when computation done in Python
cov.save('test-cov.fif') # test saving
cov_read = read_cov('test-cov.fif')
assert_true(cov_read.ch_names == cov.ch_names)
assert_true(cov_read.nfree == cov.nfree)
assert_true((linalg.norm(cov.data - cov_read.data, ord='fro')
/ linalg.norm(cov.data, ord='fro')) < 1e-5)
# test with a subset of channels
picks = pick_channels(raw.ch_names, include=raw.ch_names[:5])
cov = compute_raw_data_covariance(raw, picks=picks)
assert_true(cov_mne.ch_names[:5] == cov.ch_names)
assert_true(linalg.norm(cov.data - cov_mne.data[picks][:, picks],
ord='fro') / linalg.norm(cov.data, ord='fro')) < 1e-6
示例5: test_cov_scaling
def test_cov_scaling():
"""Test rescaling covs"""
evoked = read_evokeds(ave_fname, condition=0, baseline=(None, 0),
proj=True)
cov = read_cov(cov_fname)['data']
cov2 = read_cov(cov_fname)['data']
assert_array_equal(cov, cov2)
evoked.pick_channels([evoked.ch_names[k] for k in pick_types(
evoked.info, meg=True, eeg=True
)])
picks_list = _picks_by_type(evoked.info)
scalings = dict(mag=1e15, grad=1e13, eeg=1e6)
_apply_scaling_cov(cov2, picks_list, scalings=scalings)
_apply_scaling_cov(cov, picks_list, scalings=scalings)
assert_array_equal(cov, cov2)
assert_true(cov.max() > 1)
_undo_scaling_cov(cov2, picks_list, scalings=scalings)
_undo_scaling_cov(cov, picks_list, scalings=scalings)
assert_array_equal(cov, cov2)
assert_true(cov.max() < 1)
data = evoked.data.copy()
_apply_scaling_array(data, picks_list, scalings=scalings)
_undo_scaling_array(data, picks_list, scalings=scalings)
assert_allclose(data, evoked.data, atol=1e-20)
示例6: test_inverse_operator_channel_ordering
def test_inverse_operator_channel_ordering():
"""Test MNE inverse computation is immune to channel reorderings
"""
# These are with original ordering
evoked = _get_evoked()
noise_cov = read_cov(fname_cov)
fwd_orig = make_forward_solution(evoked.info, fname_trans, src_fname,
fname_bem, eeg=True, mindist=5.0)
fwd_orig = convert_forward_solution(fwd_orig, surf_ori=True)
inv_orig = make_inverse_operator(evoked.info, fwd_orig, noise_cov,
loose=0.2, depth=0.8,
limit_depth_chs=False)
stc_1 = apply_inverse(evoked, inv_orig, lambda2, "dSPM")
# Assume that a raw reordering applies to both evoked and noise_cov,
# so we don't need to create those from scratch. Just reorder them,
# then try to apply the original inverse operator
new_order = np.arange(len(evoked.info['ch_names']))
randomiser = np.random.RandomState(42)
randomiser.shuffle(new_order)
evoked.data = evoked.data[new_order]
evoked.info['chs'] = [evoked.info['chs'][n] for n in new_order]
evoked.info._update_redundant()
evoked.info._check_consistency()
cov_ch_reorder = [c for c in evoked.info['ch_names']
if (c in noise_cov.ch_names)]
new_order_cov = [noise_cov.ch_names.index(name) for name in cov_ch_reorder]
noise_cov['data'] = noise_cov.data[np.ix_(new_order_cov, new_order_cov)]
noise_cov['names'] = [noise_cov['names'][idx] for idx in new_order_cov]
fwd_reorder = make_forward_solution(evoked.info, fname_trans, src_fname,
fname_bem, eeg=True, mindist=5.0)
fwd_reorder = convert_forward_solution(fwd_reorder, surf_ori=True)
inv_reorder = make_inverse_operator(evoked.info, fwd_reorder, noise_cov,
loose=0.2, depth=0.8,
limit_depth_chs=False)
stc_2 = apply_inverse(evoked, inv_reorder, lambda2, "dSPM")
assert_equal(stc_1.subject, stc_2.subject)
assert_array_equal(stc_1.times, stc_2.times)
assert_allclose(stc_1.data, stc_2.data, rtol=1e-5, atol=1e-5)
assert_true(inv_orig['units'] == inv_reorder['units'])
# Reload with original ordering & apply reordered inverse
evoked = _get_evoked()
noise_cov = read_cov(fname_cov)
stc_3 = apply_inverse(evoked, inv_reorder, lambda2, "dSPM")
assert_allclose(stc_1.data, stc_3.data, rtol=1e-5, atol=1e-5)
示例7: test_io_cov
def test_io_cov():
"""Test IO for noise covariance matrices
"""
cov = read_cov(cov_fname)
cov.save('cov.fif')
cov2 = read_cov('cov.fif')
assert_array_almost_equal(cov.data, cov2.data)
cov['bads'] = ['EEG 039']
cov_sel = pick_channels_cov(cov, exclude=cov['bads'])
assert_true(cov_sel['dim'] == (len(cov['data']) - len(cov['bads'])))
assert_true(cov_sel['data'].shape == (cov_sel['dim'], cov_sel['dim']))
cov_sel.save('cov.fif')
示例8: test_cov_estimation_on_raw
def test_cov_estimation_on_raw():
"""Test estimation from raw (typically empty room)"""
tempdir = _TempDir()
raw = read_raw_fif(raw_fname, preload=True)
cov_mne = read_cov(erm_cov_fname)
# The pure-string uses the more efficient numpy-based method, the
# the list gets triaged to compute_covariance (should be equivalent
# but use more memory)
for method in (None, ['empirical']): # None is cast to 'empirical'
cov = compute_raw_covariance(raw, tstep=None, method=method)
assert_equal(cov.ch_names, cov_mne.ch_names)
assert_equal(cov.nfree, cov_mne.nfree)
assert_snr(cov.data, cov_mne.data, 1e4)
cov = compute_raw_covariance(raw, method=method) # tstep=0.2 (default)
assert_equal(cov.nfree, cov_mne.nfree - 119) # cutoff some samples
assert_snr(cov.data, cov_mne.data, 1e2)
# test IO when computation done in Python
cov.save(op.join(tempdir, 'test-cov.fif')) # test saving
cov_read = read_cov(op.join(tempdir, 'test-cov.fif'))
assert_true(cov_read.ch_names == cov.ch_names)
assert_true(cov_read.nfree == cov.nfree)
assert_array_almost_equal(cov.data, cov_read.data)
# test with a subset of channels
picks = pick_channels(raw.ch_names, include=raw.ch_names[:5])
raw_pick = raw.copy().pick_channels(
[raw.ch_names[pick] for pick in picks])
raw_pick.info.normalize_proj()
cov = compute_raw_covariance(raw_pick, picks=picks, tstep=None,
method=method)
assert_true(cov_mne.ch_names[:5] == cov.ch_names)
assert_snr(cov.data, cov_mne.data[picks][:, picks], 1e4)
cov = compute_raw_covariance(raw_pick, picks=picks, method=method)
assert_snr(cov.data, cov_mne.data[picks][:, picks], 90) # cutoff samps
# make sure we get a warning with too short a segment
raw_2 = read_raw_fif(raw_fname).crop(0, 1, copy=False)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
cov = compute_raw_covariance(raw_2, method=method)
assert_true(any('Too few samples' in str(ww.message) for ww in w))
# no epochs found due to rejection
assert_raises(ValueError, compute_raw_covariance, raw, tstep=None,
method='empirical', reject=dict(eog=200e-6))
# but this should work
cov = compute_raw_covariance(raw.copy().crop(0, 10., copy=False),
tstep=None, method=method,
reject=dict(eog=1000e-6))
示例9: test_io_cov
def test_io_cov():
"""Test IO for noise covariance matrices
"""
tempdir = _TempDir()
cov = read_cov(cov_fname)
cov.save(op.join(tempdir, 'test-cov.fif'))
cov2 = read_cov(op.join(tempdir, 'test-cov.fif'))
assert_array_almost_equal(cov.data, cov2.data)
cov2 = read_cov(cov_gz_fname)
assert_array_almost_equal(cov.data, cov2.data)
cov2.save(op.join(tempdir, 'test-cov.fif.gz'))
cov2 = read_cov(op.join(tempdir, 'test-cov.fif.gz'))
assert_array_almost_equal(cov.data, cov2.data)
cov['bads'] = ['EEG 039']
cov_sel = pick_channels_cov(cov, exclude=cov['bads'])
assert_true(cov_sel['dim'] == (len(cov['data']) - len(cov['bads'])))
assert_true(cov_sel['data'].shape == (cov_sel['dim'], cov_sel['dim']))
cov_sel.save(op.join(tempdir, 'test-cov.fif'))
cov2 = read_cov(cov_gz_fname)
assert_array_almost_equal(cov.data, cov2.data)
cov2.save(op.join(tempdir, 'test-cov.fif.gz'))
cov2 = read_cov(op.join(tempdir, 'test-cov.fif.gz'))
assert_array_almost_equal(cov.data, cov2.data)
# test warnings on bad filenames
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
cov_badname = op.join(tempdir, 'test-bad-name.fif.gz')
write_cov(cov_badname, cov)
read_cov(cov_badname)
assert_true(len(w) == 2)
示例10: test_io_cov
def test_io_cov():
"""Test IO for noise covariance matrices
"""
cov = read_cov(cov_fname)
cov.save(op.join(tempdir, "test-cov.fif"))
cov2 = read_cov(op.join(tempdir, "test-cov.fif"))
assert_array_almost_equal(cov.data, cov2.data)
cov2 = read_cov(cov_gz_fname)
assert_array_almost_equal(cov.data, cov2.data)
cov2.save(op.join(tempdir, "test-cov.fif.gz"))
cov2 = read_cov(op.join(tempdir, "test-cov.fif.gz"))
assert_array_almost_equal(cov.data, cov2.data)
cov["bads"] = ["EEG 039"]
cov_sel = pick_channels_cov(cov, exclude=cov["bads"])
assert_true(cov_sel["dim"] == (len(cov["data"]) - len(cov["bads"])))
assert_true(cov_sel["data"].shape == (cov_sel["dim"], cov_sel["dim"]))
cov_sel.save(op.join(tempdir, "test-cov.fif"))
cov2 = read_cov(cov_gz_fname)
assert_array_almost_equal(cov.data, cov2.data)
cov2.save(op.join(tempdir, "test-cov.fif.gz"))
cov2 = read_cov(op.join(tempdir, "test-cov.fif.gz"))
assert_array_almost_equal(cov.data, cov2.data)
# test warnings on bad filenames
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
cov_badname = op.join(tempdir, "test-bad-name.fif.gz")
write_cov(cov_badname, cov)
read_cov(cov_badname)
assert_true(len(w) == 2)
示例11: test_cov_estimation_on_raw
def test_cov_estimation_on_raw(method, tmpdir):
"""Test estimation from raw (typically empty room)."""
tempdir = str(tmpdir)
raw = read_raw_fif(raw_fname, preload=True)
cov_mne = read_cov(erm_cov_fname)
# The pure-string uses the more efficient numpy-based method, the
# the list gets triaged to compute_covariance (should be equivalent
# but use more memory)
with pytest.warns(None): # can warn about EEG ref
cov = compute_raw_covariance(raw, tstep=None, method=method,
rank='full')
assert_equal(cov.ch_names, cov_mne.ch_names)
assert_equal(cov.nfree, cov_mne.nfree)
assert_snr(cov.data, cov_mne.data, 1e4)
# tstep=0.2 (default)
with pytest.warns(None): # can warn about EEG ref
cov = compute_raw_covariance(raw, method=method, rank='full')
assert_equal(cov.nfree, cov_mne.nfree - 119) # cutoff some samples
assert_snr(cov.data, cov_mne.data, 1e2)
# test IO when computation done in Python
cov.save(op.join(tempdir, 'test-cov.fif')) # test saving
cov_read = read_cov(op.join(tempdir, 'test-cov.fif'))
assert cov_read.ch_names == cov.ch_names
assert cov_read.nfree == cov.nfree
assert_array_almost_equal(cov.data, cov_read.data)
# test with a subset of channels
raw_pick = raw.copy().pick_channels(raw.ch_names[:5])
raw_pick.info.normalize_proj()
cov = compute_raw_covariance(raw_pick, tstep=None, method=method,
rank='full')
assert cov_mne.ch_names[:5] == cov.ch_names
assert_snr(cov.data, cov_mne.data[:5, :5], 1e4)
cov = compute_raw_covariance(raw_pick, method=method, rank='full')
assert_snr(cov.data, cov_mne.data[:5, :5], 90) # cutoff samps
# make sure we get a warning with too short a segment
raw_2 = read_raw_fif(raw_fname).crop(0, 1)
with pytest.warns(RuntimeWarning, match='Too few samples'):
cov = compute_raw_covariance(raw_2, method=method)
# no epochs found due to rejection
pytest.raises(ValueError, compute_raw_covariance, raw, tstep=None,
method='empirical', reject=dict(eog=200e-6))
# but this should work
cov = compute_raw_covariance(raw.copy().crop(0, 10.),
tstep=None, method=method,
reject=dict(eog=1000e-6),
verbose='error')
示例12: test_cov_estimation_with_triggers
def test_cov_estimation_with_triggers():
"""Estimate raw with triggers
"""
raw = Raw(raw_fname)
events = find_events(raw)
event_ids = [1, 2, 3, 4]
reject = dict(grad=10000e-13, mag=4e-12, eeg=80e-6, eog=150e-6)
# cov with merged events and keep_sample_mean=True
events_merged = merge_events(events, event_ids, 1234)
epochs = Epochs(raw, events_merged, 1234, tmin=-0.2, tmax=0,
baseline=(-0.2, -0.1), proj=True,
reject=reject, preload=True)
cov = compute_covariance(epochs, keep_sample_mean=True)
cov_mne = read_cov(cov_km_fname)
assert_true(cov_mne.ch_names == cov.ch_names)
assert_true((linalg.norm(cov.data - cov_mne.data, ord='fro')
/ linalg.norm(cov.data, ord='fro')) < 0.005)
# Test with tmin and tmax (different but not too much)
cov_tmin_tmax = compute_covariance(epochs, tmin=-0.19, tmax=-0.01)
assert_true(np.all(cov.data != cov_tmin_tmax.data))
assert_true((linalg.norm(cov.data - cov_tmin_tmax.data, ord='fro')
/ linalg.norm(cov_tmin_tmax.data, ord='fro')) < 0.05)
# cov using a list of epochs and keep_sample_mean=True
epochs = [Epochs(raw, events, ev_id, tmin=-0.2, tmax=0,
baseline=(-0.2, -0.1), proj=True, reject=reject)
for ev_id in event_ids]
cov2 = compute_covariance(epochs, keep_sample_mean=True)
assert_array_almost_equal(cov.data, cov2.data)
assert_true(cov.ch_names == cov2.ch_names)
# cov with keep_sample_mean=False using a list of epochs
cov = compute_covariance(epochs, keep_sample_mean=False)
cov_mne = read_cov(cov_fname)
assert_true(cov_mne.ch_names == cov.ch_names)
assert_true((linalg.norm(cov.data - cov_mne.data, ord='fro')
/ linalg.norm(cov.data, ord='fro')) < 0.005)
# test IO when computation done in Python
cov.save('test-cov.fif') # test saving
cov_read = read_cov('test-cov.fif')
assert_true(cov_read.ch_names == cov.ch_names)
assert_true(cov_read.nfree == cov.nfree)
assert_true((linalg.norm(cov.data - cov_read.data, ord='fro')
/ linalg.norm(cov.data, ord='fro')) < 1e-5)
示例13: test_io_cov
def test_io_cov():
"""Test IO for noise covariance matrices
"""
fid, tree, _ = fiff_open(fname)
cov_type = 1
cov = mne.read_cov(fid, tree, cov_type)
fid.close()
mne.write_cov_file('cov.fif', cov)
fid, tree, _ = fiff_open('cov.fif')
cov2 = mne.read_cov(fid, tree, cov_type)
fid.close()
print assert_array_almost_equal(cov['data'], cov2['data'])
示例14: test_ad_hoc_cov
def test_ad_hoc_cov(tmpdir):
"""Test ad hoc cov creation and I/O."""
out_fname = op.join(str(tmpdir), 'test-cov.fif')
evoked = read_evokeds(ave_fname)[0]
cov = make_ad_hoc_cov(evoked.info)
cov.save(out_fname)
assert 'Covariance' in repr(cov)
cov2 = read_cov(out_fname)
assert_array_almost_equal(cov['data'], cov2['data'])
std = dict(grad=2e-13, mag=10e-15, eeg=0.1e-6)
cov = make_ad_hoc_cov(evoked.info, std)
cov.save(out_fname)
assert 'Covariance' in repr(cov)
cov2 = read_cov(out_fname)
assert_array_almost_equal(cov['data'], cov2['data'])
示例15: test_gamma_map_vol_sphere
def test_gamma_map_vol_sphere():
"""Gamma MAP with a sphere forward and volumic source space"""
evoked = read_evokeds(fname_evoked, condition=0, baseline=(None, 0),
proj=False)
evoked.resample(50, npad=100)
evoked.crop(tmin=0.1, tmax=0.16) # crop to window around peak
cov = read_cov(fname_cov)
cov = regularize(cov, evoked.info)
info = evoked.info
sphere = mne.make_sphere_model(r0=(0., 0., 0.), head_radius=0.080)
src = mne.setup_volume_source_space(subject=None, pos=15., mri=None,
sphere=(0.0, 0.0, 0.0, 80.0),
bem=None, mindist=5.0,
exclude=2.0)
fwd = mne.make_forward_solution(info, trans=None, src=src, bem=sphere,
eeg=False, meg=True)
alpha = 0.5
assert_raises(ValueError, gamma_map, evoked, fwd, cov, alpha,
loose=0, return_residual=False)
assert_raises(ValueError, gamma_map, evoked, fwd, cov, alpha,
loose=0.2, return_residual=False)
stc = gamma_map(evoked, fwd, cov, alpha, tol=1e-4,
xyz_same_gamma=False, update_mode=2,
return_residual=False)
assert_array_almost_equal(stc.times, evoked.times, 5)