本文整理汇总了Python中mne.fiff.Raw.del_proj方法的典型用法代码示例。如果您正苦于以下问题:Python Raw.del_proj方法的具体用法?Python Raw.del_proj怎么用?Python Raw.del_proj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.fiff.Raw
的用法示例。
在下文中一共展示了Raw.del_proj方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_proj
# 需要导入模块: from mne.fiff import Raw [as 别名]
# 或者: from mne.fiff.Raw import del_proj [as 别名]
def test_proj():
"""Test SSP proj operations
"""
for proj_active in [True, False]:
raw = Raw(fif_fname, preload=False, proj_active=proj_active)
assert_true(all(p['active'] == proj_active for p in raw.info['projs']))
data, times = raw[0:2, :]
data1, times1 = raw[0:2]
assert_array_equal(data, data1)
assert_array_equal(times, times1)
# test adding / deleting proj
if proj_active:
assert_raises(ValueError, raw.add_proj, [],
{'remove_existing': True})
assert_raises(ValueError, raw.del_proj, 0)
else:
projs = deepcopy(raw.info['projs'])
n_proj = len(raw.info['projs'])
raw.del_proj(0)
assert_true(len(raw.info['projs']) == n_proj - 1)
raw.add_proj(projs, remove_existing=False)
assert_true(len(raw.info['projs']) == 2 * n_proj - 1)
raw.add_proj(projs, remove_existing=True)
assert_true(len(raw.info['projs']) == n_proj)
# test apply_proj() with and without preload
for preload in [True, False]:
raw = Raw(fif_fname, preload=preload, proj_active=False)
data, times = raw[:, 0:2]
raw.apply_projector()
data_proj_1 = np.dot(raw._projector, data)
# load the file again without proj
raw = Raw(fif_fname, preload=preload, proj_active=False)
# write the file with proj. activated, make sure proj has been applied
raw.save(op.join(tempdir, 'raw.fif'), proj_active=True)
raw2 = Raw(op.join(tempdir, 'raw.fif'), proj_active=False)
data_proj_2, _ = raw2[:, 0:2]
assert_array_almost_equal(data_proj_1, data_proj_2)
assert_true(all(p['active'] for p in raw2.info['projs']))
# read orig file with proj. active
raw2 = Raw(fif_fname, preload=preload, proj_active=True)
data_proj_2, _ = raw2[:, 0:2]
assert_array_almost_equal(data_proj_1, data_proj_2)
assert_true(all(p['active'] for p in raw2.info['projs']))
# test that apply_projector works
raw.apply_projector()
data_proj_2, _ = raw[:, 0:2]
assert_array_almost_equal(data_proj_1, data_proj_2)
assert_array_almost_equal(data_proj_2,
np.dot(raw._projector, data_proj_2))