本文整理汇总了Python中mne.minimum_norm.inverse.write_inverse_operator函数的典型用法代码示例。如果您正苦于以下问题:Python write_inverse_operator函数的具体用法?Python write_inverse_operator怎么用?Python write_inverse_operator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_inverse_operator函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_io_inverse_operator
def test_io_inverse_operator():
"""Test IO of inverse_operator
"""
tempdir = _TempDir()
inverse_operator = read_inverse_operator(fname_inv)
x = repr(inverse_operator)
assert_true(x)
assert_true(isinstance(inverse_operator['noise_cov'], Covariance))
# just do one example for .gz, as it should generalize
_compare_io(inverse_operator, '.gz')
# test warnings on bad filenames
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
inv_badname = op.join(tempdir, 'test-bad-name.fif.gz')
write_inverse_operator(inv_badname, inverse_operator)
read_inverse_operator(inv_badname)
assert_naming(w, 'test_inverse.py', 2)
# make sure we can write and read
inv_fname = op.join(tempdir, 'test-inv.fif')
args = (10, 1. / 9., 'dSPM')
inv_prep = prepare_inverse_operator(inverse_operator, *args)
write_inverse_operator(inv_fname, inv_prep)
inv_read = read_inverse_operator(inv_fname)
_compare(inverse_operator, inv_read)
inv_read_prep = prepare_inverse_operator(inv_read, *args)
_compare(inv_prep, inv_read_prep)
inv_prep_prep = prepare_inverse_operator(inv_prep, *args)
_compare(inv_prep, inv_prep_prep)
开发者ID:claire-braboszcz,项目名称:mne-python,代码行数:30,代码来源:test_inverse.py
示例2: test_io_inverse_operator
def test_io_inverse_operator():
"""Test IO of inverse_operator."""
tempdir = _TempDir()
inverse_operator = read_inverse_operator(fname_inv)
x = repr(inverse_operator)
assert (x)
assert (isinstance(inverse_operator['noise_cov'], Covariance))
# just do one example for .gz, as it should generalize
_compare_io(inverse_operator, '.gz')
# test warnings on bad filenames
inv_badname = op.join(tempdir, 'test-bad-name.fif.gz')
with pytest.warns(RuntimeWarning, match='-inv.fif'):
write_inverse_operator(inv_badname, inverse_operator)
with pytest.warns(RuntimeWarning, match='-inv.fif'):
read_inverse_operator(inv_badname)
# make sure we can write and read
inv_fname = op.join(tempdir, 'test-inv.fif')
args = (10, 1. / 9., 'dSPM')
inv_prep = prepare_inverse_operator(inverse_operator, *args)
write_inverse_operator(inv_fname, inv_prep)
inv_read = read_inverse_operator(inv_fname)
_compare(inverse_operator, inv_read)
inv_read_prep = prepare_inverse_operator(inv_read, *args)
_compare(inv_prep, inv_read_prep)
inv_prep_prep = prepare_inverse_operator(inv_prep, *args)
_compare(inv_prep, inv_prep_prep)
开发者ID:teonbrooks,项目名称:mne-python,代码行数:28,代码来源:test_inverse.py
示例3: test_apply_inverse_sphere
def test_apply_inverse_sphere():
"""Test applying an inverse with a sphere model (rank-deficient)."""
evoked = _get_evoked()
evoked.pick_channels(evoked.ch_names[:306:8])
evoked.info['projs'] = []
cov = make_ad_hoc_cov(evoked.info)
sphere = make_sphere_model('auto', 'auto', evoked.info)
fwd = read_forward_solution(fname_fwd)
vertices = [fwd['src'][0]['vertno'][::5],
fwd['src'][1]['vertno'][::5]]
stc = SourceEstimate(np.zeros((sum(len(v) for v in vertices), 1)),
vertices, 0., 1.)
fwd = restrict_forward_to_stc(fwd, stc)
fwd = make_forward_solution(evoked.info, fwd['mri_head_t'], fwd['src'],
sphere, mindist=5.)
evoked = EvokedArray(fwd['sol']['data'].copy(), evoked.info)
assert fwd['sol']['nrow'] == 39
assert fwd['nsource'] == 101
assert fwd['sol']['ncol'] == 303
tempdir = _TempDir()
temp_fname = op.join(tempdir, 'temp-inv.fif')
inv = make_inverse_operator(evoked.info, fwd, cov, loose=1.)
# This forces everything to be float32
write_inverse_operator(temp_fname, inv)
inv = read_inverse_operator(temp_fname)
stc = apply_inverse(evoked, inv, method='eLORETA',
method_params=dict(eps=1e-2))
# assert zero localization bias
assert_array_equal(np.argmax(stc.data, axis=0),
np.repeat(np.arange(101), 3))
开发者ID:teonbrooks,项目名称:mne-python,代码行数:30,代码来源:test_inverse.py
示例4: test_io_inverse_operator
def test_io_inverse_operator():
"""Test IO of inverse_operator
"""
for inv in [inverse_operator, inverse_operator_vol]:
inv_init = copy.deepcopy(inv)
write_inverse_operator('test-inv.fif', inv)
this_inv = read_inverse_operator('test-inv.fif')
_compare(inv, inv_init)
_compare(inv, this_inv)
开发者ID:sudo-nim,项目名称:mne-python,代码行数:10,代码来源:test_inverse.py
示例5: test_io_inverse_operator
def test_io_inverse_operator():
"""Test IO of inverse_operator
"""
for inv in [inverse_operator, inverse_operator_vol]:
inv_init = copy.deepcopy(inv)
for out_file in ['test-inv.fif', 'test-inv.fif.gz']:
write_inverse_operator(out_file, inv)
this_inv = read_inverse_operator(out_file)
_compare(inv, inv_init)
_compare(inv, this_inv)
开发者ID:starzynski,项目名称:mne-python,代码行数:11,代码来源:test_inverse.py
示例6: _compare_io
def _compare_io(inv_op, out_file_ext='.fif'):
if out_file_ext == '.fif':
out_file = op.join(tempdir, 'test-inv.fif')
elif out_file_ext == '.gz':
out_file = op.join(tempdir, 'test-inv.fif.gz')
else:
raise ValueError('IO test could not complete')
# Test io operations
inv_init = copy.deepcopy(inv_op)
write_inverse_operator(out_file, inv_op)
read_inv_op = read_inverse_operator(out_file)
_compare(inv_init, read_inv_op)
_compare(inv_init, inv_op)
开发者ID:mshamalainen,项目名称:mne-python,代码行数:13,代码来源:test_inverse.py
示例7: test_io_inverse_operator
def test_io_inverse_operator():
"""Test IO of inverse_operator with GZip
"""
inverse_operator = read_inverse_operator(fname_inv)
# just do one example for .gz, as it should generalize
_compare_io(inverse_operator, '.gz')
# test warnings on bad filenames
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
inv_badname = op.join(tempdir, 'test-bad-name.fif.gz')
write_inverse_operator(inv_badname, inverse_operator)
read_inverse_operator(inv_badname)
assert_true(len(w) == 2)
开发者ID:rgoj,项目名称:mne-python,代码行数:14,代码来源:test_inverse.py
示例8: test_apply_inverse_operator
def test_apply_inverse_operator():
"""Test MNE inverse computation
With and without precomputed inverse operator.
"""
evoked = fiff.Evoked(fname_data, setno=0, baseline=(None, 0))
stc = apply_inverse(evoked, inverse_operator, lambda2, "MNE")
assert_true(stc.data.min() > 0)
assert_true(stc.data.max() < 10e-10)
assert_true(stc.data.mean() > 1e-11)
stc = apply_inverse(evoked, inverse_operator, lambda2, "sLORETA")
assert_true(stc.data.min() > 0)
assert_true(stc.data.max() < 9.0)
assert_true(stc.data.mean() > 0.1)
stc = apply_inverse(evoked, inverse_operator, lambda2, "dSPM")
assert_true(stc.data.min() > 0)
assert_true(stc.data.max() < 35)
assert_true(stc.data.mean() > 0.1)
# Test MNE inverse computation starting from forward operator
evoked = fiff.Evoked(fname_data, setno=0, baseline=(None, 0))
fwd_op = read_forward_solution(fname_fwd, surf_ori=True)
my_inv_op = make_inverse_operator(evoked.info, fwd_op, noise_cov,
loose=0.2, depth=0.8)
write_inverse_operator('test-inv.fif', my_inv_op)
read_my_inv_op = read_inverse_operator('test-inv.fif')
_compare(my_inv_op, read_my_inv_op)
my_stc = apply_inverse(evoked, my_inv_op, lambda2, "dSPM")
assert_true('dev_head_t' in my_inv_op['info'])
assert_true('mri_head_t' in my_inv_op)
assert_equal(stc.times, my_stc.times)
assert_array_almost_equal(stc.data, my_stc.data, 2)
开发者ID:starzynski,项目名称:mne-python,代码行数:39,代码来源:test_inverse.py
注:本文中的mne.minimum_norm.inverse.write_inverse_operator函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论