本文整理汇总了Python中mne.realtime.RtEpochs.stop方法的典型用法代码示例。如果您正苦于以下问题:Python RtEpochs.stop方法的具体用法?Python RtEpochs.stop怎么用?Python RtEpochs.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.realtime.RtEpochs
的用法示例。
在下文中一共展示了RtEpochs.stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fieldtrip_rtepochs
# 需要导入模块: from mne.realtime import RtEpochs [as 别名]
# 或者: from mne.realtime.RtEpochs import stop [as 别名]
def test_fieldtrip_rtepochs(free_tcp_port, tmpdir):
"""Test FieldTrip RtEpochs."""
raw_tmax = 7
raw = read_raw_fif(raw_fname, preload=True)
raw.crop(tmin=0, tmax=raw_tmax)
events_offline = find_events(raw, stim_channel='STI 014')
event_id = list(np.unique(events_offline[:, 2]))
tmin, tmax = -0.2, 0.5
epochs_offline = Epochs(raw, events_offline, event_id=event_id,
tmin=tmin, tmax=tmax)
epochs_offline.drop_bad()
isi_max = (np.max(np.diff(epochs_offline.events[:, 0])) /
raw.info['sfreq']) + 1.0
kill_signal = _start_buffer_thread(free_tcp_port)
try:
data_rt = None
events_ids_rt = None
with pytest.warns(RuntimeWarning, match='Trying to guess it'):
with FieldTripClient(host='localhost', port=free_tcp_port,
tmax=raw_tmax, wait_max=2) as rt_client:
# get measurement info guessed by MNE-Python
raw_info = rt_client.get_measurement_info()
assert ([ch['ch_name'] for ch in raw_info['chs']] ==
[ch['ch_name'] for ch in raw.info['chs']])
# create the real-time epochs object
epochs_rt = RtEpochs(rt_client, event_id, tmin, tmax,
stim_channel='STI 014', isi_max=isi_max)
epochs_rt.start()
time.sleep(0.5)
for ev_num, ev in enumerate(epochs_rt.iter_evoked()):
if ev_num == 0:
data_rt = ev.data[None, :, :]
events_ids_rt = int(
ev.comment) # comment attribute contains event_id
else:
data_rt = np.concatenate(
(data_rt, ev.data[None, :, :]), axis=0)
events_ids_rt = np.append(events_ids_rt,
int(ev.comment))
_call_base_epochs_public_api(epochs_rt, tmpdir)
epochs_rt.stop(stop_receive_thread=True)
assert_array_equal(events_ids_rt, epochs_rt.events[:, 2])
assert_array_equal(data_rt, epochs_rt.get_data())
assert len(epochs_rt) == len(epochs_offline)
assert_array_equal(events_ids_rt, epochs_offline.events[:, 2])
assert_allclose(epochs_rt.get_data(), epochs_offline.get_data(),
rtol=1.e-5, atol=1.e-8) # defaults of np.isclose
finally:
kill_signal.put(False) # stop the buffer
示例2: RtEpochs
# 需要导入模块: from mne.realtime import RtEpochs [as 别名]
# 或者: from mne.realtime.RtEpochs import stop [as 别名]
# create the real-time epochs object and start acquisition
rt_epochs = RtEpochs(rt_client, event_id, tmin, tmax,
stim_channel='STI 014', picks=picks,
reject=dict(grad=4000e-13, eog=150e-6),
decim=1, isi_max=2.0, proj=None)
rt_epochs.start()
for ii, ev in enumerate(rt_epochs.iter_evoked()):
print("Just got epoch %d" % (ii + 1))
ev.pick_types(meg=True, eog=False)
if ii == 0:
evoked = ev
else:
evoked = mne.combine_evoked([evoked, ev], weights='nave')
ax[0].cla()
ax[1].cla() # clear axis
plot_events(rt_epochs.events[-5:], sfreq=ev.info['sfreq'],
first_samp=-rt_client.tmin_samp, axes=ax[0])
# plot on second subplot
evoked.plot(axes=ax[1], selectable=False, time_unit='s')
ax[1].set_title('Evoked response for gradiometer channels'
'(event_id = %d)' % event_id)
plt.pause(0.05 / speedup)
plt.draw()
rt_epochs.stop()