本文整理汇总了Python中mne.Epochs.events[sel[1]]方法的典型用法代码示例。如果您正苦于以下问题:Python Epochs.events[sel[1]]方法的具体用法?Python Epochs.events[sel[1]]怎么用?Python Epochs.events[sel[1]]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.Epochs
的用法示例。
在下文中一共展示了Epochs.events[sel[1]]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_xdawn_regularization
# 需要导入模块: from mne import Epochs [as 别名]
# 或者: from mne.Epochs import events[sel[1]] [as 别名]
def test_xdawn_regularization():
"""Test Xdawn with regularization."""
# Get data
raw, events, picks = _get_data()
epochs = Epochs(raw, events, event_id, tmin, tmax, picks=picks,
preload=True, baseline=None, verbose=False)
# Test with overlapping events.
# modify events to simulate one overlap
events = epochs.events
sel = np.where(events[:, 2] == 2)[0][:2]
modified_event = events[sel[0]]
modified_event[0] += 1
epochs.events[sel[1]] = modified_event
# Fit and check that overlap was found and applied
xd = Xdawn(n_components=2, correct_overlap='auto', reg='oas')
xd.fit(epochs)
assert_equal(xd.correct_overlap_, True)
evoked = epochs['cond2'].average()
assert_true(np.sum(np.abs(evoked.data - xd.evokeds_['cond2'].data)))
# With covariance regularization
for reg in [.1, 0.1, 'ledoit_wolf', 'oas']:
xd = Xdawn(n_components=2, correct_overlap=False,
signal_cov=np.eye(len(picks)), reg=reg)
xd.fit(epochs)
# With bad shrinkage
xd = Xdawn(n_components=2, correct_overlap=False,
signal_cov=np.eye(len(picks)), reg=2)
assert_raises(ValueError, xd.fit, epochs)
示例2: test_xdawn_regularization
# 需要导入模块: from mne import Epochs [as 别名]
# 或者: from mne.Epochs import events[sel[1]] [as 别名]
def test_xdawn_regularization():
"""Test Xdawn with regularization."""
# Get data, this time MEG so we can test proper reg/ch type support
raw = read_raw_fif(raw_fname, verbose=False, preload=True)
events = read_events(event_name)
picks = pick_types(raw.info, meg=True, eeg=False, stim=False,
ecg=False, eog=False,
exclude='bads')[::8]
raw.pick_channels([raw.ch_names[pick] for pick in picks])
del picks
raw.info.normalize_proj()
epochs = Epochs(raw, events, event_id, tmin, tmax,
preload=True, baseline=None, verbose=False)
# Test with overlapping events.
# modify events to simulate one overlap
events = epochs.events
sel = np.where(events[:, 2] == 2)[0][:2]
modified_event = events[sel[0]]
modified_event[0] += 1
epochs.events[sel[1]] = modified_event
# Fit and check that overlap was found and applied
xd = Xdawn(n_components=2, correct_overlap='auto', reg='oas')
xd.fit(epochs)
assert xd.correct_overlap_
evoked = epochs['cond2'].average()
assert np.sum(np.abs(evoked.data - xd.evokeds_['cond2'].data))
# With covariance regularization
for reg in [.1, 0.1, 'ledoit_wolf', 'oas']:
xd = Xdawn(n_components=2, correct_overlap=False,
signal_cov=np.eye(len(epochs.ch_names)), reg=reg)
xd.fit(epochs)
# With bad shrinkage
xd = Xdawn(n_components=2, correct_overlap=False,
signal_cov=np.eye(len(epochs.ch_names)), reg=2)
with pytest.raises(ValueError, match='shrinkage must be'):
xd.fit(epochs)
# With rank-deficient input
raw = maxwell_filter(raw, int_order=4, ext_order=2)
xd = Xdawn(correct_overlap=False, reg=None)
# this is a bit wacky because `epochs` has projectors on from the old raw
# but it works as a rank-deficient test case
with pytest.raises(ValueError, match='Could not compute eigenvalues'):
xd.fit(epochs)
xd = Xdawn(correct_overlap=False, reg=0.5)
xd.fit(epochs)
xd = Xdawn(correct_overlap=False, reg='diagonal_fixed')
xd.fit(epochs)