本文整理汇总了Python中mne.Epochs.del_proj方法的典型用法代码示例。如果您正苦于以下问题:Python Epochs.del_proj方法的具体用法?Python Epochs.del_proj怎么用?Python Epochs.del_proj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.Epochs
的用法示例。
在下文中一共展示了Epochs.del_proj方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_epochs_proj_mixin
# 需要导入模块: from mne import Epochs [as 别名]
# 或者: from mne.Epochs import del_proj [as 别名]
def test_epochs_proj_mixin():
"""Test SSP proj methods from ProjMixin class
"""
for proj in [True, False]:
epochs = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks,
baseline=(None, 0), proj=proj)
assert_true(all(p['active'] == proj for p in epochs.info['projs']))
# test adding / deleting proj
if proj:
epochs.get_data()
assert_true(all(p['active'] == proj for p in epochs.info['projs']))
assert_raises(ValueError, epochs.add_proj, epochs.info['projs'][0],
{'remove_existing': True})
assert_raises(ValueError, epochs.add_proj, 'spam')
assert_raises(ValueError, epochs.del_proj, 0)
else:
projs = deepcopy(epochs.info['projs'])
n_proj = len(epochs.info['projs'])
epochs.del_proj(0)
assert_true(len(epochs.info['projs']) == n_proj - 1)
epochs.add_proj(projs, remove_existing=False)
assert_true(len(epochs.info['projs']) == 2 * n_proj - 1)
epochs.add_proj(projs, remove_existing=True)
assert_true(len(epochs.info['projs']) == n_proj)
for preload in [True, False]:
print 'preload is %s' % preload
epochs = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks,
baseline=(None, 0), proj=False, preload=preload,
add_eeg_ref=True, verbose=True)
epochs2 = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks,
baseline=(None, 0), proj=True, preload=preload,
add_eeg_ref=True)
assert_allclose(epochs.copy().apply_proj().get_data()[0],
epochs2.get_data()[0])
# make sure the preprocssing works on copies by calling
# get_data twice
assert_array_equal(epochs2.get_data(), epochs2.get_data())
data = epochs.get_data().copy()
data2 = np.array([e for e in epochs])
assert_array_equal(data, data2)
epochs.apply_proj()
assert_array_equal(epochs._projector, epochs2._projector)
assert_allclose(epochs._data, epochs2.get_data())
epochs = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks,
baseline=None, proj=False, add_eeg_ref=True)
data = epochs.get_data().copy()
epochs.apply_proj()
assert_allclose(np.dot(epochs._projector, data[0]), epochs._data[0])
示例2: test_epochs_proj_mixin
# 需要导入模块: from mne import Epochs [as 别名]
# 或者: from mne.Epochs import del_proj [as 别名]
def test_epochs_proj_mixin():
"""Test SSP proj methods from ProjMixin class
"""
for proj in [True, False]:
epochs = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks, baseline=(None, 0), proj=proj)
assert_true(all(p["active"] == proj for p in epochs.info["projs"]))
# test adding / deleting proj
if proj:
epochs.get_data()
assert_true(all(p["active"] == proj for p in epochs.info["projs"]))
assert_raises(ValueError, epochs.add_proj, epochs.info["projs"][0], {"remove_existing": True})
assert_raises(ValueError, epochs.add_proj, "spam")
assert_raises(ValueError, epochs.del_proj, 0)
else:
projs = deepcopy(epochs.info["projs"])
n_proj = len(epochs.info["projs"])
epochs.del_proj(0)
assert_true(len(epochs.info["projs"]) == n_proj - 1)
epochs.add_proj(projs, remove_existing=False)
assert_true(len(epochs.info["projs"]) == 2 * n_proj - 1)
epochs.add_proj(projs, remove_existing=True)
assert_true(len(epochs.info["projs"]) == n_proj)
# catch no-gos.
# wrong proj argument
assert_raises(
ValueError, Epochs, raw, events[:4], event_id, tmin, tmax, picks=picks, baseline=(None, 0), proj="crazy"
)
# delayed without reject params
assert_raises(
RuntimeError,
Epochs,
raw,
events[:4],
event_id,
tmin,
tmax,
picks=picks,
baseline=(None, 0),
proj="delayed",
reject=None,
)
for preload in [True, False]:
epochs = Epochs(
raw,
events[:4],
event_id,
tmin,
tmax,
picks=picks,
baseline=(None, 0),
proj="delayed",
preload=preload,
add_eeg_ref=True,
verbose=True,
reject=reject,
)
epochs2 = Epochs(
raw,
events[:4],
event_id,
tmin,
tmax,
picks=picks,
baseline=(None, 0),
proj=True,
preload=preload,
add_eeg_ref=True,
reject=reject,
)
assert_allclose(epochs.copy().apply_proj().get_data()[0], epochs2.get_data()[0])
# make sure data output is constant across repeated calls
# e.g. drop bads
assert_array_equal(epochs.get_data(), epochs.get_data())
assert_array_equal(epochs2.get_data(), epochs2.get_data())
# test epochs.next calls
data = epochs.get_data().copy()
data2 = np.array([e for e in epochs])
assert_array_equal(data, data2)
# cross application from processing stream 1 to 2
epochs.apply_proj()
assert_array_equal(epochs._projector, epochs2._projector)
assert_allclose(epochs._data, epochs2.get_data())
# test mixin against manual application
epochs = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks, baseline=None, proj=False, add_eeg_ref=True)
data = epochs.get_data().copy()
epochs.apply_proj()
assert_allclose(np.dot(epochs._projector, data[0]), epochs._data[0])