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')
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 evoked.plot(exclude='bads') evoked.plot(exclude=evoked.info['bads'], spatial_colors=True, gfp=True) # 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') 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'], evoked) # test averaged topomap 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')
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]) # plot_compare_evokeds: test condition contrast, CI, color assignment plot_compare_evokeds(evoked.copy().pick_types(meg='mag')) evoked.rename_channels({'MEG 2142': "MEG 1642"}) assert len(plot_compare_evokeds(evoked)) == 2 colors = dict(red='r', blue='b') linestyles = dict(red='--', blue='-') red, blue = evoked.copy(), evoked.copy() red.data *= 1.1 blue.data *= 0.9 plot_compare_evokeds([red, blue], picks=3) # list of evokeds plot_compare_evokeds([[red, evoked], [blue, evoked]], picks=3) # list of lists # test picking & plotting grads contrast = dict() contrast["red/stim"] = list((evoked.copy(), red)) contrast["blue/stim"] = list((evoked.copy(), blue)) # test a bunch of params at once plot_compare_evokeds(contrast, colors=colors, linestyles=linestyles, picks=[0, 2], vlines=[.01, -.04], invert_y=True, truncate_yaxis=False, ylim=dict(mag=(-10, 10)), styles={"red/stim": {"linewidth": 1}}) assert_raises(ValueError, plot_compare_evokeds, contrast, picks='str') # bad picks: not int assert_raises(ValueError, plot_compare_evokeds, evoked, picks=3, colors=dict(fake=1)) # 'fake' not in conds assert_raises(ValueError, plot_compare_evokeds, evoked, picks=3, styles=dict(fake=1)) # 'fake' not in conds assert_raises(ValueError, plot_compare_evokeds, [[1, 2], [3, 4]], picks=3) # evoked must contain Evokeds assert_raises(ValueError, plot_compare_evokeds, evoked, picks=3, styles=dict(err=1)) # bad styles dict assert_raises(ValueError, plot_compare_evokeds, evoked, picks=3, gfp=True) # no single-channel GFP assert_raises(TypeError, plot_compare_evokeds, evoked, picks=3, ci='fake') # ci must be float or None contrast["red/stim"] = red contrast["blue/stim"] = blue plot_compare_evokeds(contrast, picks=[0], colors=['r', 'b'], ylim=dict(mag=(1, 10))) # 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')