本文整理汇总了Python中mne.viz.utils._fake_click函数的典型用法代码示例。如果您正苦于以下问题:Python _fake_click函数的具体用法?Python _fake_click怎么用?Python _fake_click使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_fake_click函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_plot_evoked
def test_plot_evoked():
"""Test plotting of evoked
"""
import matplotlib.pyplot as plt
evoked = _get_epochs().average()
with warnings.catch_warnings(record=True):
fig = evoked.plot(proj=True, hline=[1], exclude=[], window_title='foo')
# Test a click
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax,
[line.get_xdata()[0], line.get_ydata()[0]], 'data')
_fake_click(fig, ax,
[ax.get_xlim()[0], ax.get_ylim()[1]], 'data')
# plot with bad channels excluded & spatial_colors & zorder
evoked.plot(exclude='bads')
evoked.plot(exclude=evoked.info['bads'], spatial_colors=True, gfp=True,
zorder='std')
# test selective updating of dict keys is working.
evoked.plot(hline=[1], units=dict(mag='femto foo'))
evoked_delayed_ssp = _get_epochs_delayed_ssp().average()
evoked_delayed_ssp.plot(proj='interactive')
evoked_delayed_ssp.apply_proj()
assert_raises(RuntimeError, evoked_delayed_ssp.plot,
proj='interactive')
evoked_delayed_ssp.info['projs'] = []
assert_raises(RuntimeError, evoked_delayed_ssp.plot,
proj='interactive')
assert_raises(RuntimeError, evoked_delayed_ssp.plot,
proj='interactive', axes='foo')
plt.close('all')
# test GFP only
evoked.plot(gfp='only')
assert_raises(ValueError, evoked.plot, gfp='foo')
evoked.plot_image(proj=True)
# plot with bad channels excluded
evoked.plot_image(exclude='bads', cmap='interactive')
evoked.plot_image(exclude=evoked.info['bads']) # does the same thing
plt.close('all')
evoked.plot_topo() # should auto-find layout
_butterfly_onselect(0, 200, ['mag', 'grad'], evoked)
plt.close('all')
cov = read_cov(cov_fname)
cov['method'] = 'empirical'
evoked.plot_white(cov)
evoked.plot_white([cov, cov])
# Hack to test plotting of maxfiltered data
evoked_sss = evoked.copy()
evoked_sss.info['proc_history'] = [dict(max_info=None)]
evoked_sss.plot_white(cov)
evoked_sss.plot_white(cov_fname)
plt.close('all')
evoked.plot_sensors() # Test plot_sensors
plt.close('all')
开发者ID:EmanuelaLiaci,项目名称:mne-python,代码行数:60,代码来源:test_evoked.py
示例2: test_stc_mpl
def test_stc_mpl():
"""Test plotting source estimates with matplotlib."""
sample_src = read_source_spaces(src_fname)
vertices = [s['vertno'] for s in sample_src]
n_time = 5
n_verts = sum(len(v) for v in vertices)
stc_data = np.ones((n_verts * n_time))
stc_data.shape = (n_verts, n_time)
stc = SourceEstimate(stc_data, vertices, 1, 1, 'sample')
with pytest.warns(RuntimeWarning, match='not included'):
stc.plot(subjects_dir=subjects_dir, time_unit='s', views='ven',
hemi='rh', smoothing_steps=2, subject='sample',
backend='matplotlib', spacing='oct1', initial_time=0.001,
colormap='Reds')
fig = stc.plot(subjects_dir=subjects_dir, time_unit='ms', views='dor',
hemi='lh', smoothing_steps=2, subject='sample',
backend='matplotlib', spacing='ico2', time_viewer=True,
colormap='mne')
time_viewer = fig.time_viewer
_fake_click(time_viewer, time_viewer.axes[0], (0.5, 0.5)) # change t
time_viewer.canvas.key_press_event('ctrl+right')
time_viewer.canvas.key_press_event('left')
pytest.raises(ValueError, stc.plot, subjects_dir=subjects_dir,
hemi='both', subject='sample', backend='matplotlib')
pytest.raises(ValueError, stc.plot, subjects_dir=subjects_dir,
time_unit='ss', subject='sample', backend='matplotlib')
plt.close('all')
开发者ID:kambysese,项目名称:mne-python,代码行数:28,代码来源:test_3d.py
示例3: test_plot_volume_source_estimates
def test_plot_volume_source_estimates():
"""Test interactive plotting of volume source estimates."""
forward = read_forward_solution(fwd_fname)
sample_src = forward['src']
vertices = [s['vertno'] for s in sample_src]
n_verts = sum(len(v) for v in vertices)
n_time = 2
data = np.random.RandomState(0).rand(n_verts, n_time)
vol_stc = VolSourceEstimate(data, vertices, 1, 1)
for mode in ['glass_brain', 'stat_map']:
with pytest.warns(None): # sometimes get scalars/index warning
fig = vol_stc.plot(sample_src, subject='sample',
subjects_dir=subjects_dir,
mode=mode)
# [ax_time, ax_y, ax_x, ax_z]
for ax_idx in [0, 2, 3, 4]:
_fake_click(fig, fig.axes[ax_idx], (0.3, 0.5))
fig.canvas.key_press_event('left')
fig.canvas.key_press_event('shift+right')
with pytest.raises(ValueError, match='must be one of'):
vol_stc.plot(sample_src, 'sample', subjects_dir, mode='abcd')
vertices.append([])
surface_stc = SourceEstimate(data, vertices, 1, 1)
with pytest.raises(ValueError, match='Only Vol'):
plot_volume_source_estimates(surface_stc, sample_src, 'sample',
subjects_dir)
with pytest.raises(ValueError, match='Negative colormap limits'):
vol_stc.plot(sample_src, 'sample', subjects_dir,
clim=dict(lims=[-1, 2, 3], kind='value'))
开发者ID:kambysese,项目名称:mne-python,代码行数:32,代码来源:test_3d.py
示例4: test_plot_sensors
def test_plot_sensors():
"""Test plotting of sensor array."""
import matplotlib.pyplot as plt
raw = _get_raw()
fig = raw.plot_sensors('3d')
_fake_click(fig, fig.gca(), (-0.08, 0.67))
raw.plot_sensors('topomap')
plt.close('all')
开发者ID:Pablo-Arias,项目名称:mne-python,代码行数:8,代码来源:test_raw.py
示例5: test_plot_tfr_topo
def test_plot_tfr_topo():
"""Test plotting of TFR data."""
import matplotlib.pyplot as plt
epochs = _get_epochs()
n_freqs = 3
nave = 1
data = np.random.RandomState(0).randn(len(epochs.ch_names),
n_freqs, len(epochs.times))
tfr = AverageTFR(epochs.info, data, epochs.times, np.arange(n_freqs), nave)
plt.close('all')
fig = tfr.plot_topo(baseline=(None, 0), mode='ratio',
title='Average power', vmin=0., vmax=14.)
# test opening tfr by clicking
num_figures_before = len(plt.get_fignums())
# could use np.reshape(fig.axes[-1].images[0].get_extent(), (2, 2)).mean(1)
with pytest.warns(None): # on old mpl there is a warning
_fake_click(fig, fig.axes[0], (0.08, 0.65))
assert num_figures_before + 1 == len(plt.get_fignums())
plt.close('all')
tfr.plot([4], baseline=(None, 0), mode='ratio', show=False, title='foo')
pytest.raises(ValueError, tfr.plot, [4], yscale='lin', show=False)
# nonuniform freqs
freqs = np.logspace(*np.log10([3, 10]), num=3)
tfr = AverageTFR(epochs.info, data, epochs.times, freqs, nave)
fig = tfr.plot([4], baseline=(None, 0), mode='mean', vmax=14., show=False)
assert fig.axes[0].get_yaxis().get_scale() == 'log'
# one timesample
tfr = AverageTFR(epochs.info, data[:, :, [0]], epochs.times[[1]],
freqs, nave)
with pytest.warns(None): # matplotlib equal left/right
tfr.plot([4], baseline=None, vmax=14., show=False, yscale='linear')
# one frequency bin, log scale required: as it doesn't make sense
# to plot log scale for one value, we test whether yscale is set to linear
vmin, vmax = 0., 2.
fig, ax = plt.subplots()
tmin, tmax = epochs.times[0], epochs.times[-1]
with pytest.warns(RuntimeWarning, match='not masking'):
_imshow_tfr(ax, 3, tmin, tmax, vmin, vmax, None, tfr=data[:, [0], :],
freq=freqs[[-1]], x_label=None, y_label=None,
colorbar=False, cmap=('RdBu_r', True), yscale='log')
fig = plt.gcf()
assert fig.axes[0].get_yaxis().get_scale() == 'linear'
# ValueError when freq[0] == 0 and yscale == 'log'
these_freqs = freqs[:3].copy()
these_freqs[0] = 0
with pytest.warns(RuntimeWarning, match='not masking'):
pytest.raises(ValueError, _imshow_tfr, ax, 3, tmin, tmax, vmin, vmax,
None, tfr=data[:, :3, :], freq=these_freqs, x_label=None,
y_label=None, colorbar=False, cmap=('RdBu_r', True),
yscale='log')
开发者ID:SherazKhan,项目名称:mne-python,代码行数:57,代码来源:test_topo.py
示例6: test_plot_sensors
def test_plot_sensors():
"""Test plotting of sensor array."""
import matplotlib.pyplot as plt
raw = _get_raw()
fig = raw.plot_sensors('3d')
_fake_click(fig, fig.gca(), (-0.08, 0.67))
raw.plot_sensors('topomap')
assert_raises(TypeError, plot_sensors, raw) # needs to be info
plt.close('all')
开发者ID:YashAgarwal,项目名称:mne-python,代码行数:9,代码来源:test_raw.py
示例7: test_plot_topo_image_epochs
def test_plot_topo_image_epochs():
"""Test plotting of epochs image topography."""
import matplotlib.pyplot as plt
title = 'ERF images - MNE sample data'
epochs = _get_epochs()
cmap = mne_analyze_colormap(format='matplotlib')
fig = plot_topo_image_epochs(epochs, sigma=0.5, vmin=-200, vmax=200,
colorbar=True, title=title, cmap=cmap)
_fake_click(fig, fig.axes[2], (0.08, 0.64))
plt.close('all')
开发者ID:deep-introspection,项目名称:mne-python,代码行数:10,代码来源:test_topo.py
示例8: test_plot_topomap_interactive
def test_plot_topomap_interactive():
"""Test interactive topomap projection plotting."""
import matplotlib.pyplot as plt
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
evoked = read_evokeds(evoked_fname, baseline=(None, 0))[0]
evoked.pick_types(meg='mag')
evoked.info['projs'] = []
assert not evoked.proj
evoked.add_proj(compute_proj_evoked(evoked, n_mag=1))
plt.close('all')
fig = Figure()
canvas = FigureCanvas(fig)
ax = fig.gca()
kwargs = dict(vmin=-240, vmax=240, times=[0.1], colorbar=False, axes=ax,
res=8, time_unit='s')
evoked.copy().plot_topomap(proj=False, **kwargs)
canvas.draw()
image_noproj = np.frombuffer(canvas.tostring_rgb(), dtype='uint8')
assert len(plt.get_fignums()) == 1
ax.clear()
evoked.copy().plot_topomap(proj=True, **kwargs)
canvas.draw()
image_proj = np.frombuffer(canvas.tostring_rgb(), dtype='uint8')
assert not np.array_equal(image_noproj, image_proj)
assert len(plt.get_fignums()) == 1
ax.clear()
evoked.copy().plot_topomap(proj='interactive', **kwargs)
canvas.draw()
image_interactive = np.frombuffer(canvas.tostring_rgb(), dtype='uint8')
assert_array_equal(image_noproj, image_interactive)
assert not np.array_equal(image_proj, image_interactive)
assert len(plt.get_fignums()) == 2
proj_fig = plt.figure(plt.get_fignums()[-1])
_fake_click(proj_fig, proj_fig.axes[0], [0.5, 0.5], xform='data')
canvas.draw()
image_interactive_click = np.frombuffer(
canvas.tostring_rgb(), dtype='uint8')
assert_array_equal(image_proj, image_interactive_click)
assert not np.array_equal(image_noproj, image_interactive_click)
_fake_click(proj_fig, proj_fig.axes[0], [0.5, 0.5], xform='data')
canvas.draw()
image_interactive_click = np.frombuffer(
canvas.tostring_rgb(), dtype='uint8')
assert_array_equal(image_noproj, image_interactive_click)
assert not np.array_equal(image_proj, image_interactive_click)
开发者ID:SherazKhan,项目名称:mne-python,代码行数:52,代码来源:test_topomap.py
示例9: test_plot_evoked
def test_plot_evoked():
"""Test evoked.plot."""
import matplotlib.pyplot as plt
evoked = _get_epochs().average()
fig = evoked.plot(proj=True, hline=[1], exclude=[], window_title='foo',
time_unit='s')
# Test a click
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax,
[line.get_xdata()[0], line.get_ydata()[0]], 'data')
_fake_click(fig, ax,
[ax.get_xlim()[0], ax.get_ylim()[1]], 'data')
# plot with bad channels excluded & spatial_colors & zorder
evoked.plot(exclude='bads', time_unit='s')
# test selective updating of dict keys is working.
evoked.plot(hline=[1], units=dict(mag='femto foo'), time_unit='s')
evoked_delayed_ssp = _get_epochs_delayed_ssp().average()
evoked_delayed_ssp.plot(proj='interactive', time_unit='s')
evoked_delayed_ssp.apply_proj()
pytest.raises(RuntimeError, evoked_delayed_ssp.plot,
proj='interactive', time_unit='s')
evoked_delayed_ssp.info['projs'] = []
pytest.raises(RuntimeError, evoked_delayed_ssp.plot,
proj='interactive', time_unit='s')
pytest.raises(RuntimeError, evoked_delayed_ssp.plot,
proj='interactive', axes='foo', time_unit='s')
plt.close('all')
# test GFP only
evoked.plot(gfp='only', time_unit='s')
pytest.raises(ValueError, evoked.plot, gfp='foo', time_unit='s')
# plot with bad channels excluded, spatial_colors, zorder & pos. layout
evoked.rename_channels({'MEG 0133': 'MEG 0000'})
evoked.plot(exclude=evoked.info['bads'], spatial_colors=True, gfp=True,
zorder='std', time_unit='s')
evoked.plot(exclude=[], spatial_colors=True, zorder='unsorted',
time_unit='s')
pytest.raises(TypeError, evoked.plot, zorder='asdf', time_unit='s')
plt.close('all')
evoked.plot_sensors() # Test plot_sensors
plt.close('all')
evoked.pick_channels(evoked.ch_names[:4])
with catch_logging() as log_file:
evoked.plot(verbose=True, time_unit='s')
assert 'Need more than one' in log_file.getvalue()
开发者ID:jhouck,项目名称:mne-python,代码行数:50,代码来源:test_evoked.py
示例10: test_plot_sensors
def test_plot_sensors():
"""Test plotting of sensor array."""
import matplotlib.pyplot as plt
raw = _get_raw()
fig = raw.plot_sensors('3d')
_fake_click(fig, fig.gca(), (-0.08, 0.67))
raw.plot_sensors('topomap')
ax = plt.subplot(111)
raw.plot_sensors(ch_groups='position', axes=ax)
raw.plot_sensors(ch_groups='selection')
raw.plot_sensors(ch_groups=[[0, 1, 2], [3, 4]])
assert_raises(ValueError, raw.plot_sensors, ch_groups='asd')
assert_raises(TypeError, plot_sensors, raw) # needs to be info
plt.close('all')
开发者ID:mmagnuski,项目名称:mne-python,代码行数:14,代码来源:test_raw.py
示例11: test_plot_instance_components
def test_plot_instance_components():
"""Test plotting of components as instances of raw and epochs."""
import matplotlib.pyplot as plt
raw = _get_raw()
picks = _get_picks(raw)
ica = ICA(noise_cov=read_cov(cov_fname), n_components=2,
max_pca_components=3, n_pca_components=3)
with pytest.warns(RuntimeWarning, match='projection'):
ica.fit(raw, picks=picks)
fig = ica.plot_sources(raw, exclude=[0], title='Components')
for key in ['down', 'up', 'right', 'left', 'o', '-', '+', '=', 'pageup',
'pagedown', 'home', 'end', 'f11', 'b']:
fig.canvas.key_press_event(key)
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax, [line.get_xdata()[0], line.get_ydata()[0]],
'data')
_fake_click(fig, ax, [-0.1, 0.9]) # click on y-label
fig.canvas.key_press_event('escape')
plt.close('all')
epochs = _get_epochs()
fig = ica.plot_sources(epochs, exclude=[0], title='Components')
for key in ['down', 'up', 'right', 'left', 'o', '-', '+', '=', 'pageup',
'pagedown', 'home', 'end', 'f11', 'b']:
fig.canvas.key_press_event(key)
# Test a click
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax, [line.get_xdata()[0], line.get_ydata()[0]], 'data')
_fake_click(fig, ax, [-0.1, 0.9]) # click on y-label
fig.canvas.key_press_event('escape')
plt.close('all')
开发者ID:SherazKhan,项目名称:mne-python,代码行数:32,代码来源:test_ica.py
示例12: test_plot_topo_image_epochs
def test_plot_topo_image_epochs():
"""Test plotting of epochs image topography."""
title = 'ERF images - MNE sample data'
epochs = _get_epochs()
epochs.load_data()
cmap = mne_analyze_colormap(format='matplotlib')
data_min = epochs._data.min()
plt.close('all')
fig = plot_topo_image_epochs(epochs, sigma=0.5, vmin=-200, vmax=200,
colorbar=True, title=title, cmap=cmap)
assert epochs._data.min() == data_min
num_figures_before = len(plt.get_fignums())
_fake_click(fig, fig.axes[0], (0.08, 0.64))
assert num_figures_before + 1 == len(plt.get_fignums())
plt.close('all')
开发者ID:kdoelling1919,项目名称:mne-python,代码行数:15,代码来源:test_topo.py
示例13: test_plot_evoked
def test_plot_evoked():
"""Test plotting of evoked
"""
import matplotlib.pyplot as plt
evoked = _get_epochs().average()
with warnings.catch_warnings(record=True):
fig = evoked.plot(proj=True, hline=[1], exclude=[])
# Test a click
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax,
[line.get_xdata()[0], line.get_ydata()[0]], 'data')
_fake_click(fig, ax,
[ax.get_xlim()[0], ax.get_ylim()[1]], 'data')
# plot with bad channels excluded
evoked.plot(exclude='bads')
evoked.plot(exclude=evoked.info['bads']) # does the same thing
# test selective updating of dict keys is working.
evoked.plot(hline=[1], units=dict(mag='femto foo'))
evoked_delayed_ssp = _get_epochs_delayed_ssp().average()
evoked_delayed_ssp.plot(proj='interactive')
evoked_delayed_ssp.apply_proj()
assert_raises(RuntimeError, evoked_delayed_ssp.plot,
proj='interactive')
evoked_delayed_ssp.info['projs'] = []
assert_raises(RuntimeError, evoked_delayed_ssp.plot,
proj='interactive')
assert_raises(RuntimeError, evoked_delayed_ssp.plot,
proj='interactive', axes='foo')
evoked.plot_image(proj=True)
# plot with bad channels excluded
evoked.plot_image(exclude='bads')
evoked.plot_image(exclude=evoked.info['bads']) # does the same thing
plt.close('all')
cov = read_cov(cov_fname)
cov['method'] = 'empirical'
evoked.plot_white(cov)
evoked.plot_white([cov, cov])
# Hack to test plotting of maxfiltered data
evoked_sss = evoked.copy()
evoked_sss.info['proc_history'] = [dict(max_info=None)]
evoked_sss.plot_white(cov)
开发者ID:Lem97,项目名称:mne-python,代码行数:46,代码来源:test_evoked.py
示例14: test_plot_ica_sources
def test_plot_ica_sources():
"""Test plotting of ICA panel
"""
import matplotlib.pyplot as plt
raw = io.read_raw_fif(raw_fname,
preload=False).crop(0, 1, copy=False).load_data()
picks = _get_picks(raw)
epochs = _get_epochs()
raw.pick_channels([raw.ch_names[k] for k in picks])
ica_picks = pick_types(raw.info, meg=True, eeg=False, stim=False,
ecg=False, eog=False, exclude='bads')
ica = ICA(n_components=2, max_pca_components=3, n_pca_components=3)
ica.fit(raw, picks=ica_picks)
ica.exclude = [1]
fig = ica.plot_sources(raw)
fig.canvas.key_press_event('escape')
# Sadly close_event isn't called on Agg backend and the test always passes.
assert_array_equal(ica.exclude, [1])
raw.info['bads'] = ['MEG 0113']
assert_raises(RuntimeError, ica.plot_sources, inst=raw)
ica.plot_sources(epochs)
epochs.info['bads'] = ['MEG 0113']
assert_raises(RuntimeError, ica.plot_sources, inst=epochs)
epochs.info['bads'] = []
with warnings.catch_warnings(record=True): # no labeled objects mpl
ica.plot_sources(epochs.average())
evoked = epochs.average()
fig = ica.plot_sources(evoked)
# Test a click
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax,
[line.get_xdata()[0], line.get_ydata()[0]], 'data')
_fake_click(fig, ax,
[ax.get_xlim()[0], ax.get_ylim()[1]], 'data')
# plot with bad channels excluded
ica.plot_sources(evoked, exclude=[0])
ica.exclude = [0]
ica.plot_sources(evoked) # does the same thing
ica.labels_ = dict(eog=[0])
ica.labels_['eog/0/crazy-channel'] = [0]
ica.plot_sources(evoked) # now with labels
assert_raises(ValueError, ica.plot_sources, 'meeow')
plt.close('all')
开发者ID:JuliaSprenger,项目名称:mne-python,代码行数:45,代码来源:test_ica.py
示例15: test_clickable_image
def test_clickable_image():
"""Test the ClickableImage class."""
# Gen data and create clickable image
im = np.random.randn(100, 100)
clk = ClickableImage(im)
clicks = [(12, 8), (46, 48), (10, 24)]
# Generate clicks
for click in clicks:
_fake_click(clk.fig, clk.ax, click, xform='data')
assert_allclose(np.array(clicks), np.array(clk.coords))
assert_true(len(clicks) == len(clk.coords))
# Exporting to layout
lt = clk.to_layout()
assert_true(lt.pos.shape[0] == len(clicks))
assert_allclose(lt.pos[1, 0] / lt.pos[2, 0],
clicks[1][0] / float(clicks[2][0]))
开发者ID:ImmanuelSamuel,项目名称:mne-python,代码行数:18,代码来源:test_utils.py
示例16: test_plot_epochs
def test_plot_epochs():
"""Test epoch plotting"""
import matplotlib.pyplot as plt
epochs = _get_epochs()
epochs.plot(scalings=None, title='Epochs', trellis=False)
plt.close('all')
fig = epochs[0].plot(picks=[0, 2, 3], scalings=None, trellis=False)
fig.canvas.key_press_event('escape')
plt.close('all')
fig = epochs.plot(trellis=False)
fig.canvas.key_press_event('left')
fig.canvas.key_press_event('right')
fig.canvas.key_press_event('up')
fig.canvas.key_press_event('down')
fig.canvas.key_press_event('pageup')
fig.canvas.key_press_event('pagedown')
fig.canvas.key_press_event('-')
fig.canvas.key_press_event('+')
fig.canvas.key_press_event('=')
fig.canvas.key_press_event('b')
fig.canvas.key_press_event('f11')
fig.canvas.key_press_event('home')
fig.canvas.key_press_event('end')
fig.canvas.resize_event()
fig.canvas.close_event() # closing and epoch dropping
plt.close('all')
with warnings.catch_warnings(record=True):
fig = epochs.plot(trellis=False)
# test mouse clicks
x = fig.get_axes()[0].get_xlim()[1] / 2
y = fig.get_axes()[0].get_ylim()[0] / 2
data_ax = fig.get_axes()[0]
n_epochs = len(epochs)
_fake_click(fig, data_ax, [x, y], xform='data') # mark a bad epoch
_fake_click(fig, data_ax, [x, y], xform='data') # unmark a bad epoch
_fake_click(fig, data_ax, [0.5, 0.999]) # click elsewhere in 1st axes
_fake_click(fig, fig.get_axes()[2], [0.5, 0.5]) # change epochs
_fake_click(fig, fig.get_axes()[3], [0.5, 0.5]) # change channels
fig.canvas.close_event() # closing and epoch dropping
assert(n_epochs - 1 == len(epochs))
plt.close('all')
assert_raises(RuntimeError, epochs.plot, picks=[], trellis=False)
plt.close('all')
开发者ID:YoheiOseki,项目名称:mne-python,代码行数:44,代码来源:test_epochs.py
示例17: test_plot_instance_components
def test_plot_instance_components():
"""Test plotting of components as instances of raw and epochs."""
import matplotlib.pyplot as plt
raw = _get_raw()
picks = _get_picks(raw)
ica = ICA(noise_cov=read_cov(cov_fname), n_components=2,
max_pca_components=3, n_pca_components=3)
with warnings.catch_warnings(record=True): # bad proj
ica.fit(raw, picks=picks)
fig = ica.plot_sources(raw, exclude=[0], title='Components')
fig.canvas.key_press_event('down')
fig.canvas.key_press_event('up')
fig.canvas.key_press_event('right')
fig.canvas.key_press_event('left')
fig.canvas.key_press_event('o')
fig.canvas.key_press_event('-')
fig.canvas.key_press_event('+')
fig.canvas.key_press_event('=')
fig.canvas.key_press_event('pageup')
fig.canvas.key_press_event('pagedown')
fig.canvas.key_press_event('home')
fig.canvas.key_press_event('end')
fig.canvas.key_press_event('f11')
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax, [line.get_xdata()[0], line.get_ydata()[0]], 'data')
_fake_click(fig, ax, [-0.1, 0.9]) # click on y-label
fig.canvas.key_press_event('escape')
plt.close('all')
epochs = _get_epochs()
fig = ica.plot_sources(epochs, exclude=[0], title='Components')
fig.canvas.key_press_event('down')
fig.canvas.key_press_event('up')
fig.canvas.key_press_event('right')
fig.canvas.key_press_event('left')
fig.canvas.key_press_event('o')
fig.canvas.key_press_event('-')
fig.canvas.key_press_event('+')
fig.canvas.key_press_event('=')
fig.canvas.key_press_event('pageup')
fig.canvas.key_press_event('pagedown')
fig.canvas.key_press_event('home')
fig.canvas.key_press_event('end')
fig.canvas.key_press_event('f11')
# Test a click
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax, [line.get_xdata()[0], line.get_ydata()[0]], 'data')
_fake_click(fig, ax, [-0.1, 0.9]) # click on y-label
fig.canvas.key_press_event('escape')
plt.close('all')
开发者ID:jmontoyam,项目名称:mne-python,代码行数:51,代码来源:test_ica.py
示例18: test_plot_ica_components
def test_plot_ica_components():
"""Test plotting of ICA solutions."""
import matplotlib.pyplot as plt
res = 8
fast_test = {"res": res, "contours": 0, "sensors": False}
raw = _get_raw()
ica = ICA(noise_cov=read_cov(cov_fname), n_components=2,
max_pca_components=3, n_pca_components=3)
ica_picks = _get_picks(raw)
with warnings.catch_warnings(record=True):
ica.fit(raw, picks=ica_picks)
warnings.simplefilter('always', UserWarning)
with warnings.catch_warnings(record=True):
for components in [0, [0], [0, 1], [0, 1] * 2, None]:
ica.plot_components(components, image_interp='bilinear',
colorbar=True, **fast_test)
# test interactive mode (passing 'inst' arg)
plt.close('all')
ica.plot_components([0, 1], image_interp='bilinear', inst=raw, res=16)
fig = plt.gcf()
ax = [a for a in fig.get_children() if isinstance(a, plt.Axes)]
lbl = ax[1].get_label()
_fake_click(fig, ax[1], (0., 0.), xform='data')
c_fig = plt.gcf()
ax = [a for a in c_fig.get_children() if isinstance(a, plt.Axes)]
labels = [a.get_label() for a in ax]
for l in ['topomap', 'image', 'erp', 'spectrum', 'variance']:
assert_true(l in labels)
topomap_ax = ax[labels.index('topomap')]
title = topomap_ax.get_title()
assert_true(lbl == title)
ica.info = None
assert_raises(ValueError, ica.plot_components, 1)
assert_raises(RuntimeError, ica.plot_components, 1, ch_type='mag')
plt.close('all')
开发者ID:HSMin,项目名称:mne-python,代码行数:41,代码来源:test_ica.py
示例19: test_plot_instance_components
def test_plot_instance_components():
"""Test plotting of components as instances of raw and epochs."""
import matplotlib.pyplot as plt
raw = _get_raw()
picks = _get_picks(raw)
ica = ICA(noise_cov=read_cov(cov_fname), n_components=2, max_pca_components=3, n_pca_components=3)
with warnings.catch_warnings(record=True): # bad proj
ica.fit(raw, picks=picks)
fig = ica.plot_sources(raw, exclude=[0], title="Components")
fig.canvas.key_press_event("down")
fig.canvas.key_press_event("up")
fig.canvas.key_press_event("right")
fig.canvas.key_press_event("left")
fig.canvas.key_press_event("o")
fig.canvas.key_press_event("-")
fig.canvas.key_press_event("+")
fig.canvas.key_press_event("=")
fig.canvas.key_press_event("pageup")
fig.canvas.key_press_event("pagedown")
fig.canvas.key_press_event("home")
fig.canvas.key_press_event("end")
fig.canvas.key_press_event("f11")
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax, [line.get_xdata()[0], line.get_ydata()[0]], "data")
_fake_click(fig, ax, [-0.1, 0.9]) # click on y-label
fig.canvas.key_press_event("escape")
plt.close("all")
epochs = _get_epochs()
fig = ica.plot_sources(epochs, exclude=[0], title="Components")
fig.canvas.key_press_event("down")
fig.canvas.key_press_event("up")
fig.canvas.key_press_event("right")
fig.canvas.key_press_event("left")
fig.canvas.key_press_event("o")
fig.canvas.key_press_event("-")
fig.canvas.key_press_event("+")
fig.canvas.key_press_event("=")
fig.canvas.key_press_event("pageup")
fig.canvas.key_press_event("pagedown")
fig.canvas.key_press_event("home")
fig.canvas.key_press_event("end")
fig.canvas.key_press_event("f11")
# Test a click
ax = fig.get_axes()[0]
line = ax.lines[0]
_fake_click(fig, ax, [line.get_xdata()[0], line.get_ydata()[0]], "data")
_fake_click(fig, ax, [-0.1, 0.9]) # click on y-label
fig.canvas.key_press_event("escape")
plt.close("all")
开发者ID:nwilming,项目名称:mne-python,代码行数:51,代码来源:test_ica.py
示例20: test_plot_ica_components
def test_plot_ica_components():
"""Test plotting of ICA solutions."""
import matplotlib.pyplot as plt
raw = _get_raw()
ica = ICA(noise_cov=read_cov(cov_fname), n_components=2, max_pca_components=3, n_pca_components=3)
ica_picks = _get_picks(raw)
with warnings.catch_warnings(record=True):
ica.fit(raw, picks=ica_picks)
warnings.simplefilter("always", UserWarning)
with warnings.catch_warnings(record=True):
for components in [0, [0], [0, 1], [0, 1] * 2, None]:
ica.plot_components(components, image_interp="bilinear", res=16, colorbar=True)
# test interactive mode (passing 'inst' arg)
plt.close("all")
ica.plot_components([0, 1], image_interp="bilinear", res=16, inst=raw)
fig = plt.gcf()
ax = [a for a in fig.get_children() if isinstance(a, plt.Axes)]
lbl = ax[1].get_label()
_fake_click(fig, ax[1], (0.0, 0.0), xform="data")
c_fig = plt.gcf()
ax = [a for a in c_fig.get_children() if isinstance(a, plt.Axes)]
labels = [a.get_label() for a in ax]
for l in ["topomap", "image", "erp", "spectrum", "variance"]:
assert_true(l in labels)
topomap_ax = ax[labels.index("topomap")]
title = topomap_ax.get_title()
assert_true(lbl == title)
ica.info = None
assert_raises(ValueError, ica.plot_components, 1)
assert_raises(RuntimeError, ica.plot_components, 1, ch_type="mag")
plt.close("all")
开发者ID:nwilming,项目名称:mne-python,代码行数:38,代码来源:test_ica.py
注:本文中的mne.viz.utils._fake_click函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论