• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python layouts.read_layout函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mne.layouts.read_layout函数的典型用法代码示例。如果您正苦于以下问题:Python read_layout函数的具体用法?Python read_layout怎么用?Python read_layout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read_layout函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_make_eeg_layout

def test_make_eeg_layout():
    """ Test creation of EEG layout """
    tmp_name = 'foo'
    lout_name = 'test_raw'
    lout_orig = read_layout(kind=lout_name, path=lout_path)
    info = Raw(fif_fname).info
    layout = make_eeg_layout(info)
    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)

    bad_info = info.copy()
    bad_info['dig'] = None
    assert_raises(RuntimeError, make_eeg_layout, bad_info)
    bad_info['dig'] = []
    assert_raises(RuntimeError, make_eeg_layout, bad_info)
开发者ID:dengemann,项目名称:mne-python,代码行数:26,代码来源:test_layout.py


示例2: test_io_layout

def test_io_layout():
    """Test IO with .lout files"""
    layout = read_layout('Vectorview-all', scale=False)
    layout.save('foobar.lout')
    layout_read = read_layout('foobar.lout', path='./', scale=False)
    assert_array_almost_equal(layout.pos, layout_read.pos, decimal=2)
    assert_true(layout.names, layout_read.names)
开发者ID:starzynski,项目名称:mne-python,代码行数:7,代码来源:test_layout.py


示例3: test_io_layout_lay

def test_io_layout_lay():
    """Test IO with .lay files"""
    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)
开发者ID:lengyelgabor,项目名称:mne-python,代码行数:8,代码来源:test_layout.py


示例4: test_io_layout_lout

def test_io_layout_lout():
    """Test IO with .lout files"""
    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
开发者ID:lengyelgabor,项目名称:mne-python,代码行数:10,代码来源:test_layout.py


示例5: test_make_grid_layout

def test_make_grid_layout():
    """ Test creation of grid layout """
    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)
开发者ID:lengyelgabor,项目名称:mne-python,代码行数:11,代码来源:test_layout.py


示例6: test_make_eeg_layout

def test_make_eeg_layout():
    """ Test creation of EEG layout """
    tmp_name = 'foo'
    lout_name = 'test_raw'
    lout_orig = read_layout(kind=lout_name, path=lout_path)
    layout = make_eeg_layout(Raw(fif_fname).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)
开发者ID:lengyelgabor,项目名称:mne-python,代码行数:11,代码来源:test_layout.py


示例7: test_plot_topo

def test_plot_topo():
    """Test plotting of ERP topography
    """

    layout = read_layout('Vectorview-all')

    # Show topography
    plot_topo(evoked, layout)
开发者ID:starzynski,项目名称:mne-python,代码行数:8,代码来源:test_viz.py


示例8: test_make_grid_layout

def test_make_grid_layout():
    """ Test creation of grid layout """
    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:])
开发者ID:dengemann,项目名称:mne-python,代码行数:20,代码来源:test_layout.py


示例9: read_layout

if not lacks_mayavi:
    mlab.options.backend = 'test'

data_dir = sample.data_path(download=False)
subjects_dir = op.join(data_dir, 'subjects')
ecg_fname = op.join(data_dir, 'MEG', 'sample', 'sample_audvis_ecg_proj.fif')

base_dir = op.join(op.dirname(__file__), '..', 'io', 'tests', 'data')
evoked_fname = op.join(base_dir, 'test-ave.fif')
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.2, 0.5
n_chan = 15
layout = read_layout('Vectorview-all')


def _fake_click(fig, ax, point, xform='ax'):
    """Helper to fake a click at a relative point within axes"""
    if xform == 'ax':
        x, y = ax.transAxes.transform_point(point)
    elif xform == 'data':
        x, y = ax.transData.transform_point(point)
    else:
        raise ValueError('unknown transform')
    try:
        fig.canvas.button_press_event(x, y, 1, False, None)
    except:  # for old MPL
        fig.canvas.button_press_event(x, y, 1, False)
开发者ID:anywave,项目名称:aw-export-fif,代码行数:30,代码来源:test_viz.py


示例10: permutation_t_test

T0, p_values, H0 = permutation_t_test(data, n_permutations, n_jobs=2)

significant_sensors = picks[p_values <= 0.05]
significant_sensors_names = [raw.info['ch_names'][k]
                             for k in significant_sensors]

print "Number of significant sensors : %d" % len(significant_sensors)
print "Sensors names : %s" % significant_sensors_names

###############################################################################
# View location of significantly active sensors
import matplotlib.pyplot as plt

# load sensor layout
from mne.layouts import read_layout
layout = read_layout('Vectorview-grad')

# Extract mask and indices of active sensors in layout
idx_of_sensors = [layout.names.index(name)
                  for name in significant_sensors_names
                  if name in layout.names]
mask_significant_sensors = np.zeros(len(layout.pos), dtype=np.bool)
mask_significant_sensors[idx_of_sensors] = True
mask_non_significant_sensors = mask_significant_sensors == False

# plot it
plt.figure(figsize=(5, 3.5), facecolor='k')
plt.axis('off')
plt.scatter(layout.pos[mask_significant_sensors, 0],
            layout.pos[mask_significant_sensors, 1], s=50, c='r')
plt.scatter(layout.pos[mask_non_significant_sensors, 0],
开发者ID:jaidevd,项目名称:mne-python,代码行数:31,代码来源:plot_sensor_permutation_test.py


示例11: Raw

raw = Raw(raw_fname)
events = mne.read_events(event_fname)

#   Set up pick list: MEG + STI 014 - bad channels (modify to your needs)
include = []  # or stim channels ['STI 014']
# bad channels in raw.info['bads'] will be automatically excluded

#   Set up amplitude-peak rejection values for MEG channels
reject = dict(grad=4000e-13, mag=4e-12)

# pick MEG channels
picks = pick_types(raw.info, meg=True, eeg=False, stim=False, eog=True,
                   include=include, exclude='bads')

# Create epochs including different events
epochs = mne.Epochs(raw, events, dict(audio_l=1, visual_r=3), tmin, tmax,
                    picks=picks, baseline=(None, 0), reject=reject)

# Generate list of evoked objects from conditions names
evokeds = [epochs[name].average() for name in 'audio_l', 'visual_r']

###############################################################################
# Show topography for two different conditions

layout = read_layout('Vectorview-all.lout')

pl.close('all')
title = 'MNE sample data - left auditory and visual'
plot_topo(evokeds, layout, color=['y', 'g'], title=title)
pl.show()
开发者ID:OliverWS,项目名称:mne-python,代码行数:30,代码来源:plot_topo_compare_conditions.py


示例12: range

        mean = values.mean(0)
        values[np.diag_indices(values.shape[0])] = mean
        
    # set a common range for colors:
    if vmin is None: vmin = values.min()
    if vmax is None: vmax = values.max()

    for i in range(values.shape[0]):
        topography(values[i], x*zoom_factor + x[i], y*zoom_factor + y[i], nx=nx, ny=nx, plotsensors=False, vmin=vmin, vmax=vmax, colorbar=False)
        if plotsensors:
            plt.plot(x[i]*zoom_factor + x[i], y[i]*zoom_factor + y[i], 'k.', markersize=8)
            
    if colorbar: plt.colorbar()


if __name__ == '__main__':
    from mne.layouts import read_layout
    layout = read_layout('Vectorview-mag.lout')
    x = layout.pos[:,0]
    y = layout.pos[:,1]
    # generate some values:
    # value = np.sin((layout.pos[:,:2]**2).sum(1)*10)
    value = np.random.rand(x.size)
    plt.figure()
    topography(value, x, y)

    plt.figure()
    values = np.random.rand(x.size, x.size)
    hypertopography(values, x, y)
    plt.show()
开发者ID:emanuele,项目名称:topography,代码行数:30,代码来源:topography.py


示例13: 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"]
开发者ID:dengemann,项目名称:mne-python,代码行数:31,代码来源:plot_decoding_csp_eeg.py


示例14: permutation_t_test

T0, p_values, H0 = permutation_t_test(data, n_permutations, n_jobs=2)

significant_sensors = picks[p_values <= 0.05]
significant_sensors_names = [raw.info["ch_names"][k] for k in significant_sensors]

print "Number of significant sensors : %d" % len(significant_sensors)
print "Sensors names : %s" % significant_sensors_names

###############################################################################
# View location of significantly active sensors
import pylab as pl

# load sensor layout
from mne.layouts import read_layout

layout = read_layout("Vectorview-grad")

# Extract mask and indices of active sensors in layout
idx_of_sensors = [layout.names.index(name) for name in significant_sensors_names if name in layout.names]
mask_significant_sensors = np.zeros(len(layout.pos), dtype=np.bool)
mask_significant_sensors[idx_of_sensors] = True
mask_non_significant_sensors = mask_significant_sensors == False

# plot it
pl.figure(facecolor="k")
pl.axis("off")
pl.axis("tight")
pl.scatter(layout.pos[mask_significant_sensors, 0], layout.pos[mask_significant_sensors, 1], s=50, c="r")
pl.scatter(layout.pos[mask_non_significant_sensors, 0], layout.pos[mask_non_significant_sensors, 1], c="w")
title = "MNE sample data (Left auditory between 40 and 60 ms)"
pl.figtext(0.03, 0.93, title, color="w", fontsize=18)
开发者ID:mshamalainen,项目名称:mne-python,代码行数:31,代码来源:plot_sensor_permutation_test.py


示例15: 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:
开发者ID:ImmanuelSamuel,项目名称:mne-python,代码行数:31,代码来源:plot_decoding_csp_eeg.py



注:本文中的mne.layouts.read_layout函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python minimum_norm.apply_inverse函数代码示例发布时间:2022-05-27
下一篇:
Python label.Label类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap