本文整理汇总了Python中mne.channels.read_layout函数的典型用法代码示例。如果您正苦于以下问题:Python read_layout函数的具体用法?Python read_layout怎么用?Python read_layout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_layout函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_io_layout_lay
def test_io_layout_lay():
"""Test IO with .lay files"""
tempdir = _TempDir()
layout = read_layout("CTF151", scale=False)
layout.save(op.join(tempdir, "foobar.lay"))
layout_read = read_layout(op.join(tempdir, "foobar.lay"), path="./", scale=False)
assert_array_almost_equal(layout.pos, layout_read.pos, decimal=2)
assert_true(layout.names, layout_read.names)
示例2: test_io_layout_lay
def test_io_layout_lay():
"""Test IO with .lay files."""
tempdir = _TempDir()
layout = read_layout('CTF151', scale=False)
layout.save(op.join(tempdir, 'foobar.lay'))
layout_read = read_layout(op.join(tempdir, 'foobar.lay'), path='./',
scale=False)
assert_array_almost_equal(layout.pos, layout_read.pos, decimal=2)
assert layout.names == layout_read.names
示例3: test_io_layout_lout
def test_io_layout_lout():
"""Test IO with .lout files."""
tempdir = _TempDir()
layout = read_layout('Vectorview-all', scale=False)
layout.save(op.join(tempdir, 'foobar.lout'))
layout_read = read_layout(op.join(tempdir, 'foobar.lout'), path='./',
scale=False)
assert_array_almost_equal(layout.pos, layout_read.pos, decimal=2)
assert layout.names == layout_read.names
print(layout) # test repr
示例4: test_io_layout_lout
def test_io_layout_lout():
"""Test IO with .lout files"""
tempdir = _TempDir()
layout = read_layout("Vectorview-all", scale=False)
layout.save(op.join(tempdir, "foobar.lout"))
layout_read = read_layout(op.join(tempdir, "foobar.lout"), path="./", scale=False)
assert_array_almost_equal(layout.pos, layout_read.pos, decimal=2)
assert_true(layout.names, layout_read.names)
print(layout) # test repr
示例5: test_make_grid_layout
def test_make_grid_layout():
"""Test creation of grid layout"""
tempdir = _TempDir()
tmp_name = 'bar'
lout_name = 'test_ica'
lout_orig = read_layout(kind=lout_name, path=lout_path)
layout = make_grid_layout(test_info)
layout.save(op.join(tempdir, tmp_name + '.lout'))
lout_new = read_layout(kind=tmp_name, path=tempdir)
assert_array_equal(lout_new.kind, tmp_name)
assert_array_equal(lout_orig.pos, lout_new.pos)
assert_array_equal(lout_orig.names, lout_new.names)
# Test creating grid layout with specified number of columns
layout = make_grid_layout(test_info, n_col=2)
# Vertical positions should be equal
assert_true(layout.pos[0, 1] == layout.pos[1, 1])
# Horizontal positions should be unequal
assert_true(layout.pos[0, 0] != layout.pos[1, 0])
# Box sizes should be equal
assert_array_equal(layout.pos[0, 3:], layout.pos[1, 3:])
示例6: test_make_eeg_layout
def test_make_eeg_layout():
"""Test creation of EEG layout"""
tempdir = _TempDir()
tmp_name = "foo"
lout_name = "test_raw"
lout_orig = read_layout(kind=lout_name, path=lout_path)
info = Raw(fif_fname).info
info["bads"].append(info["ch_names"][360])
layout = make_eeg_layout(info, exclude=[])
assert_array_equal(len(layout.names), len([ch for ch in info["ch_names"] if ch.startswith("EE")]))
layout.save(op.join(tempdir, tmp_name + ".lout"))
lout_new = read_layout(kind=tmp_name, path=tempdir, scale=False)
assert_array_equal(lout_new.kind, tmp_name)
assert_allclose(layout.pos, lout_new.pos, atol=0.1)
assert_array_equal(lout_orig.names, lout_new.names)
# Test input validation
assert_raises(ValueError, make_eeg_layout, info, radius=-0.1)
assert_raises(ValueError, make_eeg_layout, info, radius=0.6)
assert_raises(ValueError, make_eeg_layout, info, width=-0.1)
assert_raises(ValueError, make_eeg_layout, info, width=1.1)
assert_raises(ValueError, make_eeg_layout, info, height=-0.1)
assert_raises(ValueError, make_eeg_layout, info, height=1.1)
示例7: test_make_eeg_layout
def test_make_eeg_layout():
"""Test creation of EEG layout."""
tempdir = _TempDir()
tmp_name = 'foo'
lout_name = 'test_raw'
lout_orig = read_layout(kind=lout_name, path=lout_path)
info = read_info(fif_fname)
info['bads'].append(info['ch_names'][360])
layout = make_eeg_layout(info, exclude=[])
assert_array_equal(len(layout.names), len([ch for ch in info['ch_names']
if ch.startswith('EE')]))
layout.save(op.join(tempdir, tmp_name + '.lout'))
lout_new = read_layout(kind=tmp_name, path=tempdir, scale=False)
assert_array_equal(lout_new.kind, tmp_name)
assert_allclose(layout.pos, lout_new.pos, atol=0.1)
assert_array_equal(lout_orig.names, lout_new.names)
# Test input validation
pytest.raises(ValueError, make_eeg_layout, info, radius=-0.1)
pytest.raises(ValueError, make_eeg_layout, info, radius=0.6)
pytest.raises(ValueError, make_eeg_layout, info, width=-0.1)
pytest.raises(ValueError, make_eeg_layout, info, width=1.1)
pytest.raises(ValueError, make_eeg_layout, info, height=-0.1)
pytest.raises(ValueError, make_eeg_layout, info, height=1.1)
示例8: read_layout
# Set our plotters to test mode
import matplotlib
matplotlib.use('Agg') # for testing don't use X server
warnings.simplefilter('always') # enable b/c these tests throw warnings
base_dir = op.join(op.dirname(__file__), '..', '..', 'io', 'tests', 'data')
evoked_fname = op.join(base_dir, 'test-ave.fif')
raw_fname = op.join(base_dir, 'test_raw.fif')
cov_fname = op.join(base_dir, 'test-cov.fif')
event_name = op.join(base_dir, 'test-eve.fif')
event_id, tmin, tmax = 1, -0.1, 1.0
n_chan = 15
layout = read_layout('Vectorview-all')
def _get_raw():
return io.Raw(raw_fname, preload=False)
def _get_events():
return read_events(event_name)
def _get_picks(raw):
return pick_types(raw.info, meg=True, eeg=False, stim=False,
ecg=False, eog=False, exclude='bads')
示例9: read_layout
# Set our plotters to test mode
import matplotlib
matplotlib.use("Agg") # for testing don't use X server
import matplotlib.pyplot as plt # noqa
warnings.simplefilter("always") # enable b/c these tests throw warnings
base_dir = op.join(op.dirname(__file__), "..", "..", "io", "tests", "data")
evoked_fname = op.join(base_dir, "test-ave.fif")
raw_fname = op.join(base_dir, "test_raw.fif")
event_name = op.join(base_dir, "test-eve.fif")
event_id, tmin, tmax = 1, -0.2, 0.2
layout = read_layout("Vectorview-all")
def _get_raw():
return io.Raw(raw_fname, preload=False)
def _get_events():
return read_events(event_name)
def _get_picks(raw):
return [0, 1, 2, 6, 7, 8, 12, 13, 14] # take a only few channels
def _get_epochs():
示例10: cross_val_score
scores = cross_val_score(clf, epochs_data_train, labels, cv=cv, n_jobs=1)
# Printing the results
class_balance = np.mean(labels == labels[0])
class_balance = max(class_balance, 1. - class_balance)
print("Classification accuracy: %f / Chance level: %f" % (np.mean(scores),
class_balance))
# plot CSP patterns estimated on full data for visualization
csp.fit_transform(epochs_data, labels)
evoked = epochs.average()
evoked.data = csp.patterns_.T
evoked.times = np.arange(evoked.data.shape[0])
layout = read_layout('EEG1005')
evoked.plot_topomap(times=[0, 1, 2, 61, 62, 63], ch_type='eeg', layout=layout,
scale_time=1, time_format='%i', scale=1,
unit='Patterns (AU)', size=1.5)
###############################################################################
# Look at performance over time
sfreq = raw.info['sfreq']
w_length = int(sfreq * 0.5) # running classifier: window length
w_step = int(sfreq * 0.1) # running classifier: window step size
w_start = np.arange(0, epochs_data.shape[2] - w_length, w_step)
scores_windows = []
for train_idx, test_idx in cv:
示例11: SPoC
X = meg_epochs.get_data()
y = emg_epochs.get_data().var(axis=2)[:, 0] # target is EMG power
# Classification pipeline with SPoC spatial filtering and Ridge Regression
spoc = SPoC(n_components=2, log=True, reg='oas', rank='full')
clf = make_pipeline(spoc, Ridge())
# Define a two fold cross-validation
cv = KFold(n_splits=2, shuffle=False)
# Run cross validaton
y_preds = cross_val_predict(clf, X, y, cv=cv)
# Plot the True EMG power and the EMG power predicted from MEG data
fig, ax = plt.subplots(1, 1, figsize=[10, 4])
times = raw.times[meg_epochs.events[:, 0] - raw.first_samp]
ax.plot(times, y_preds, color='b', label='Predicted EMG')
ax.plot(times, y, color='r', label='True EMG')
ax.set_xlabel('Time (s)')
ax.set_ylabel('EMG Power')
ax.set_title('SPoC MEG Predictions')
plt.legend()
mne.viz.tight_layout()
plt.show()
##############################################################################
# Plot the contributions to the detected components (i.e., the forward model)
spoc.fit(X, y)
layout = read_layout('CTF151.lay')
spoc.plot_patterns(meg_epochs.info, layout=layout)
示例12: Pipeline
clf = Pipeline([("CSP", csp), ("SVC", svc)])
scores = cross_val_score(clf, epochs_data_train, labels, cv=cv, n_jobs=1)
# Printing the results
class_balance = np.mean(labels == labels[0])
class_balance = max(class_balance, 1.0 - class_balance)
print("Classification accuracy: %f / Chance level: %f" % (np.mean(scores), class_balance))
# plot CSP patterns estimated on full data for visualization
csp.fit_transform(epochs_data, labels)
evoked = epochs.average()
evoked.data = csp.patterns_.T
evoked.times = np.arange(evoked.data.shape[0])
layout = read_layout("EEG1005")
evoked.plot_topomap(
times=[0, 1, 2, 61, 62, 63],
ch_type="eeg",
layout=layout,
scale_time=1,
time_format="%i",
scale=1,
unit="Patterns (AU)",
size=1.5,
)
###############################################################################
# Look at performance over time
sfreq = raw.info["sfreq"]