本文整理匯總了Python中mne.read_events方法的典型用法代碼示例。如果您正苦於以下問題:Python mne.read_events方法的具體用法?Python mne.read_events怎麽用?Python mne.read_events使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mne
的用法示例。
在下文中一共展示了mne.read_events方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_write_does_not_alter_events_inplace
# 需要導入模塊: import mne [as 別名]
# 或者: from mne import read_events [as 別名]
def test_write_does_not_alter_events_inplace():
"""Test that writing does not modify the passed events array."""
data_path = testing.data_path()
raw_fname = op.join(data_path, 'MEG', 'sample',
'sample_audvis_trunc_raw.fif')
events_fname = op.join(data_path, 'MEG', 'sample',
'sample_audvis_trunc_raw-eve.fif')
raw = mne.io.read_raw_fif(raw_fname)
events = mne.read_events(events_fname)
events_orig = events.copy()
bids_root = _TempDir()
write_raw_bids(raw=raw, bids_basename=bids_basename, bids_root=bids_root,
events_data=events, overwrite=True)
assert np.array_equal(events, events_orig)
示例2: test_raw_to_mask_pipeline
# 需要導入模塊: import mne [as 別名]
# 或者: from mne import read_events [as 別名]
def test_raw_to_mask_pipeline():
# Smoke test for the pipeline MNE.Raw -> raw_to_mask -> Comodulogram
path = mne.datasets.sample.data_path()
raw_fname = path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
event_fname = path + ('/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif')
raw = mne.io.read_raw_fif(raw_fname, preload=True)
events = mne.read_events(event_fname)
low_sig, high_sig, mask = raw_to_mask(raw, ixs=(8, 10), events=events,
tmin=-1., tmax=5.)
estimator = Comodulogram(
fs=raw.info['sfreq'], low_fq_range=np.linspace(1, 5, 5),
low_fq_width=2., method='tort', progress_bar=False)
estimator.fit(low_sig, high_sig, mask)
estimator.plot(tight_layout=False)
plt.close('all')
示例3: _calc_epoches
# 需要導入模塊: import mne [as 別名]
# 或者: from mne import read_events [as 別名]
def _calc_epoches(params):
subject, events_id, tmin, tmax = params
out_file = op.join(LOCAL_ROOT_DIR, 'epo', '{}_ecr_nTSSS_conflict-epo.fif'.format(subject))
if not op.isfile(out_file):
events = mne.read_events(op.join(REMOTE_ROOT_DIR, 'events', '{}_ecr_nTSSS_conflict-eve.fif'.format(subject)))
raw = mne.io.Raw(op.join(REMOTE_ROOT_DIR, 'raw', '{}_ecr_nTSSS_raw.fif'.format(subject)), preload=False)
picks = mne.pick_types(raw.info, meg=True)
epochs = find_epoches(raw, picks, events, events_id, tmin=tmin, tmax=tmax)
epochs.save(out_file)
else:
epochs = mne.read_epochs(out_file)
return epochs
示例4: _read_events
# 需要導入模塊: import mne [as 別名]
# 或者: from mne import read_events [as 別名]
def _read_events(events_data, event_id, raw, ext, verbose=None):
"""Read in events data.
Parameters
----------
events_data : str | array | None
The events file. If a string, a path to the events file. If an array,
the MNE events array (shape n_events, 3). If None, events will be
inferred from the stim channel using `find_events`.
event_id : dict
The event id dict used to create a 'trial_type' column in events.tsv,
mapping a description key to an integer valued event code.
raw : instance of Raw
The data as MNE-Python Raw object.
ext : str
The extension of the original data file.
verbose : bool | str | int | None
If not None, override default verbose level (see :func:`mne.verbose`).
Returns
-------
events : array, shape = (n_events, 3)
The first column contains the event time in samples and the third
column contains the event id. The second column is ignored for now but
typically contains the value of the trigger channel either immediately
before the event or immediately after.
"""
if isinstance(events_data, str):
events = read_events(events_data, verbose=verbose).astype(int)
elif isinstance(events_data, np.ndarray):
if events_data.ndim != 2:
raise ValueError('Events must have two dimensions, '
'found %s' % events_data.ndim)
if events_data.shape[1] != 3:
raise ValueError('Events must have second dimension of length 3, '
'found %s' % events_data.shape[1])
events = events_data
elif 'stim' in raw:
events = find_events(raw, min_duration=0.001, initial_event=True,
verbose=verbose)
elif ext in ['.vhdr', '.set'] and check_version('mne', '0.18'):
events, event_id = events_from_annotations(raw, event_id,
verbose=verbose)
else:
warn('No events found or provided. Please make sure to'
' set channel type using raw.set_channel_types'
' or provide events_data.')
events = None
return events, event_id