本文整理汇总了Python中mne.io.Raw.info['projs']方法的典型用法代码示例。如果您正苦于以下问题:Python Raw.info['projs']方法的具体用法?Python Raw.info['projs']怎么用?Python Raw.info['projs']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.io.Raw
的用法示例。
在下文中一共展示了Raw.info['projs']方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_eeg_reference
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['projs'] [as 别名]
def test_set_eeg_reference():
"""Test rereference eeg data"""
raw = Raw(fif_fname, preload=True)
raw.info['projs'] = []
# Test setting an average reference
assert_true(not _has_eeg_average_ref_proj(raw.info['projs']))
reref, ref_data = set_eeg_reference(raw)
assert_true(_has_eeg_average_ref_proj(reref.info['projs']))
assert_true(ref_data is None)
# Test setting an average reference when one was already present
with warnings.catch_warnings(record=True): # weight tables
reref, ref_data = set_eeg_reference(raw, copy=False)
assert_true(ref_data is None)
# Rereference raw data by creating a copy of original data
reref, ref_data = set_eeg_reference(raw, ['EEG 001', 'EEG 002'], copy=True)
assert_true(reref.info['custom_ref_applied'])
_test_reference(raw, reref, ref_data, ['EEG 001', 'EEG 002'])
# Test that data is modified in place when copy=False
reref, ref_data = set_eeg_reference(raw, ['EEG 001', 'EEG 002'],
copy=False)
assert_true(raw is reref)
示例2: test_find_ecg
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['projs'] [as 别名]
def test_find_ecg():
"""Test find ECG peaks"""
raw = Raw(raw_fname)
# once with mag-trick
# once with characteristic channel
for ch_name in ['MEG 1531', None]:
events, ch_ECG, average_pulse, ecg = find_ecg_events(
raw, event_id=999, ch_name=ch_name, return_ecg=True)
assert_equal(raw.n_times, ecg.shape[-1])
n_events = len(events)
_, times = raw[0, :]
assert_true(55 < average_pulse < 60)
picks = pick_types(
raw.info, meg='grad', eeg=False, stim=False,
eog=False, ecg=True, emg=False, ref_meg=False,
exclude='bads')
raw.load_data()
ecg_epochs = create_ecg_epochs(raw, picks=picks, keep_ecg=True)
assert_equal(len(ecg_epochs.events), n_events)
assert_true('ECG-SYN' not in raw.ch_names)
assert_true('ECG-SYN' in ecg_epochs.ch_names)
picks = pick_types(
ecg_epochs.info, meg=False, eeg=False, stim=False,
eog=False, ecg=True, emg=False, ref_meg=False,
exclude='bads')
assert_true(len(picks) == 1)
ecg_epochs = create_ecg_epochs(raw, ch_name='MEG 2641')
assert_true('MEG 2641' in ecg_epochs.ch_names)
# test with user provided ecg channel
raw.info['projs'] = list()
raw.set_channel_types({'MEG 2641': 'ecg'})
create_ecg_epochs(raw)
示例3: test_set_eeg_reference
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['projs'] [as 别名]
def test_set_eeg_reference():
"""Test rereference eeg data"""
raw = Raw(fif_fname, preload=True)
raw.info['projs'] = []
# Test setting an average reference
assert_true(not _has_eeg_average_ref_proj(raw.info['projs']))
reref, ref_data = set_eeg_reference(raw)
assert_true(_has_eeg_average_ref_proj(reref.info['projs']))
assert_true(ref_data is None)
# Rereference raw data by creating a copy of original data
reref, ref_data = set_eeg_reference(raw, ['EEG 001', 'EEG 002'], copy=True)
assert_true(reref.info['custom_ref_applied'])
_test_reference(raw, reref, ref_data, ['EEG 001', 'EEG 002'])
# Test that data is modified in place when copy=False
reref, ref_data = set_eeg_reference(raw, ['EEG 001', 'EEG 002'],
copy=False)
assert_true(raw is reref)
# Setting an average reference on a dataset that already contains a custom
# reference should fail
assert_raises(RuntimeError, set_eeg_reference, reref)
示例4: test_proj
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['projs'] [as 别名]
def test_proj():
"""Test SSP proj operations
"""
tempdir = _TempDir()
for proj in [True, False]:
raw = Raw(fif_fname, preload=False, proj=proj)
assert_true(all(p['active'] == proj 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:
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_equal(len(raw.info['projs']), n_proj - 1)
raw.add_proj(projs, remove_existing=False)
# Test that already existing projections are not added.
assert_equal(len(raw.info['projs']), n_proj)
raw.add_proj(projs[:-1], remove_existing=True)
assert_equal(len(raw.info['projs']), n_proj - 1)
# test apply_proj() with and without preload
for preload in [True, False]:
raw = Raw(fif_fname, preload=preload, proj=False)
data, times = raw[:, 0:2]
raw.apply_proj()
data_proj_1 = np.dot(raw._projector, data)
# load the file again without proj
raw = Raw(fif_fname, preload=preload, proj=False)
# write the file with proj. activated, make sure proj has been applied
raw.save(op.join(tempdir, 'raw.fif'), proj=True, overwrite=True)
raw2 = Raw(op.join(tempdir, 'raw.fif'), proj=False)
data_proj_2, _ = raw2[:, 0:2]
assert_allclose(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=True)
data_proj_2, _ = raw2[:, 0:2]
assert_allclose(data_proj_1, data_proj_2)
assert_true(all(p['active'] for p in raw2.info['projs']))
# test that apply_proj works
raw.apply_proj()
data_proj_2, _ = raw[:, 0:2]
assert_allclose(data_proj_1, data_proj_2)
assert_allclose(data_proj_2, np.dot(raw._projector, data_proj_2))
tempdir = _TempDir()
out_fname = op.join(tempdir, 'test_raw.fif')
raw = read_raw_fif(test_fif_fname, preload=True).crop(0, 0.002, copy=False)
raw.pick_types(meg=False, eeg=True)
raw.info['projs'] = [raw.info['projs'][-1]]
raw._data.fill(0)
raw._data[-1] = 1.
raw.save(out_fname)
raw = read_raw_fif(out_fname, proj=True, preload=False)
assert_allclose(raw[:, :][0][:1], raw[0, :][0])