def test_plot_trellis(): """ Test plotting epochs using Trellis plot""" import matplotlib.pyplot as plt epochs = _get_epochs() epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str="%s") plt.close("all") epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str="%s") plt.close("all") # now let's add a bad channel epochs.info["bads"] = [epochs.ch_names[0]] # include a bad one epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str="%s") plt.close("all") fig = epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str="%s") plt.close("all") fig = epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str="%s") # fake a click event = namedtuple("Event", "inaxes") func = _get_presser(fig) func(event(inaxes=fig.axes[0])) # now do a click in the nav nav_fig = func.keywords["params"]["navigation"] func = _get_presser(nav_fig) func(event(inaxes=nav_fig.axes[1])) plt.close("all")
def test_plot_epochs(): """ Test plotting epochs """ import matplotlib.pyplot as plt epochs = _get_epochs() epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str='%s') plt.close('all') epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str='%s') plt.close('all') # test clicking: should increase coverage on # 3200-3226, 3235, 3237, 3239-3242, 3245-3255, 3260-3280 fig = plt.gcf() fig.canvas.button_press_event(10, 10, 'left') # now let's add a bad channel epochs.info['bads'] = [epochs.ch_names[0]] # include a bad one epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str='%s') fig = epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str='%s') # fake a click event = namedtuple('Event', 'inaxes') func = _get_presser(fig) func(event(inaxes=fig.axes[0])) # now do a click in the nav nav_fig = func.keywords['params']['navigation'] func = _get_presser(nav_fig) func(event(inaxes=nav_fig.axes[1])) plt.close('all')
def test_plot_topo(): """Test plotting of ERP topography """ # Show topography evoked = _get_epochs().average() plot_topo(evoked, layout) warnings.simplefilter('always', UserWarning) picked_evoked = pick_channels_evoked(evoked, evoked.ch_names[:3]) # test scaling with warnings.catch_warnings(record=True): for ylim in [dict(mag=[-600, 600]), None]: plot_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: assert_raises(ValueError, plot_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked(evoked_delayed_ssp, ch_names) fig = plot_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', 'inaxes') func(event(inaxes=fig.axes[0]))
def test_plot_topo(): """Test plotting of ERP topography """ import matplotlib.pyplot as plt # Show topography evoked = _get_epochs().average() # should auto-find layout plot_evoked_topo([evoked, evoked], merge_grads=True) # Test jointplot evoked.plot_joint() evoked.plot_joint(title='test', ts_args=dict(spatial_colors=True), topomap_args=dict(colorbar=True, times=[0.])) warnings.simplefilter('always', UserWarning) picked_evoked = evoked.copy().pick_channels(evoked.ch_names[:3]) picked_evoked_eeg = evoked.copy().pick_types(meg=False, eeg=True) picked_evoked_eeg.pick_channels(picked_evoked_eeg.ch_names[:3]) # test scaling with warnings.catch_warnings(record=True): for ylim in [dict(mag=[-600, 600]), None]: plot_evoked_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: assert_raises(ValueError, plot_evoked_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked( evoked_delayed_ssp, ch_names) fig = plot_evoked_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', ['inaxes', 'xdata', 'ydata']) func( event(inaxes=fig.axes[0], xdata=fig.axes[0]._mne_axs[0].pos[0], ydata=fig.axes[0]._mne_axs[0].pos[1])) func(event(inaxes=fig.axes[0], xdata=0, ydata=0)) params = dict(evokeds=[picked_evoked_delayed_ssp], times=picked_evoked_delayed_ssp.times, fig=fig, projs=picked_evoked_delayed_ssp.info['projs']) bools = [True] * len(params['projs']) _plot_update_evoked_topo_proj(params, bools) # should auto-generate layout plot_evoked_topo(picked_evoked_eeg.copy(), fig_background=np.zeros((4, 3, 3)), proj=True) picked_evoked.plot_topo(merge_grads=True) # Test RMS plot of grad pairs plt.close('all') for ax, idx in iter_topography(evoked.info): ax.plot(evoked.data[idx], color='red') plt.close('all')
def test_plot_topo(): """Test plotting of ERP topography """ # Show topography evoked = _get_epochs().average() plot_topo(evoked, layout) warnings.simplefilter('always', UserWarning) picked_evoked = pick_channels_evoked(evoked, evoked.ch_names[:3]) # test scaling with warnings.catch_warnings(record=True): for ylim in [dict(mag=[-600, 600]), None]: plot_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: assert_raises(ValueError, plot_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked( evoked_delayed_ssp, ch_names) fig = plot_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', 'inaxes') func(event(inaxes=fig.axes[0]))
def test_plot_topo(): """Test plotting of ERP topography.""" # Show topography evoked = _get_epochs().average() # should auto-find layout plot_evoked_topo([evoked, evoked], merge_grads=True, background_color='w') picked_evoked = evoked.copy().pick_channels(evoked.ch_names[:3]) picked_evoked_eeg = evoked.copy().pick_types(meg=False, eeg=True) picked_evoked_eeg.pick_channels(picked_evoked_eeg.ch_names[:3]) # test scaling for ylim in [dict(mag=[-600, 600]), None]: plot_evoked_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: pytest.raises(ValueError, plot_evoked_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked(evoked_delayed_ssp, ch_names) fig = plot_evoked_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', ['inaxes', 'xdata', 'ydata']) func(event(inaxes=fig.axes[0], xdata=fig.axes[0]._mne_axs[0].pos[0], ydata=fig.axes[0]._mne_axs[0].pos[1])) func(event(inaxes=fig.axes[0], xdata=0, ydata=0)) params = dict(evokeds=[picked_evoked_delayed_ssp], times=picked_evoked_delayed_ssp.times, fig=fig, projs=picked_evoked_delayed_ssp.info['projs']) bools = [True] * len(params['projs']) with pytest.warns(RuntimeWarning, match='projection'): _plot_update_evoked_topo_proj(params, bools) # should auto-generate layout plot_evoked_topo(picked_evoked_eeg.copy(), fig_background=np.zeros((4, 3, 3)), proj=True, background_color='k') # Test RMS plot of grad pairs picked_evoked.plot_topo(merge_grads=True, background_color='w') plt.close('all') for ax, idx in iter_topography(evoked.info): ax.plot(evoked.data[idx], color='red') # test status bar message assert (evoked.ch_names[idx] in ax.format_coord(.5, .5)) plt.close('all') cov = read_cov(cov_fname) cov['projs'] = [] evoked.pick_types(meg=True).plot_topo(noise_cov=cov) plt.close('all') # test plot_topo evoked.plot_topo() # should auto-find layout _line_plot_onselect(0, 200, ['mag', 'grad'], evoked.info, evoked.data, evoked.times) plt.close('all')
def test_plot_topo(): """Test plotting of ERP topography.""" import matplotlib.pyplot as plt # Show topography evoked = _get_epochs().average() # should auto-find layout plot_evoked_topo([evoked, evoked], merge_grads=True, background_color='w') # Test jointplot evoked.plot_joint() def return_inds(d): # to test function kwarg to zorder arg of evoked.plot return list(range(d.shape[0])) evoked.plot_joint(title='test', topomap_args=dict(contours=0, res=8), ts_args=dict(spatial_colors=True, zorder=return_inds)) assert_raises(ValueError, evoked.plot_joint, ts_args=dict(axes=True)) warnings.simplefilter('always', UserWarning) picked_evoked = evoked.copy().pick_channels(evoked.ch_names[:3]) picked_evoked_eeg = evoked.copy().pick_types(meg=False, eeg=True) picked_evoked_eeg.pick_channels(picked_evoked_eeg.ch_names[:3]) # test scaling with warnings.catch_warnings(record=True): for ylim in [dict(mag=[-600, 600]), None]: plot_evoked_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: assert_raises(ValueError, plot_evoked_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked(evoked_delayed_ssp, ch_names) fig = plot_evoked_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', ['inaxes', 'xdata', 'ydata']) func(event(inaxes=fig.axes[0], xdata=fig.axes[0]._mne_axs[0].pos[0], ydata=fig.axes[0]._mne_axs[0].pos[1])) func(event(inaxes=fig.axes[0], xdata=0, ydata=0)) params = dict(evokeds=[picked_evoked_delayed_ssp], times=picked_evoked_delayed_ssp.times, fig=fig, projs=picked_evoked_delayed_ssp.info['projs']) bools = [True] * len(params['projs']) _plot_update_evoked_topo_proj(params, bools) # should auto-generate layout plot_evoked_topo(picked_evoked_eeg.copy(), fig_background=np.zeros((4, 3, 3)), proj=True, background_color='k') # Test RMS plot of grad pairs picked_evoked.plot_topo(merge_grads=True, background_color='w') plt.close('all') for ax, idx in iter_topography(evoked.info): ax.plot(evoked.data[idx], color='red') # test status bar message assert_true(evoked.ch_names[idx] in ax.format_coord(.5, .5)) plt.close('all')
def test_plot_epochs(): """ Test plotting epochs """ epochs = _get_epochs() epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str='%s') epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str='%s') # test clicking: should increase coverage on # 3200-3226, 3235, 3237, 3239-3242, 3245-3255, 3260-3280 fig = plt.gcf() fig.canvas.button_press_event(10, 10, 'left') # now let's add a bad channel epochs.info['bads'] = [epochs.ch_names[0]] # include a bad one epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str='%s') fig = epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str='%s') # fake a click event = namedtuple('Event', 'inaxes') func = _get_presser(fig) func(event(inaxes=fig.axes[0])) # now do a click in the nav nav_fig = func.keywords['params']['navigation'] func = _get_presser(nav_fig) func(event(inaxes=nav_fig.axes[1])) plt.close('all')
def test_plot_epochs(): """ Test plotting epochs """ epochs = _get_epochs() epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str="%s") epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str="%s") # test clicking: should increase coverage on # 3200-3226, 3235, 3237, 3239-3242, 3245-3255, 3260-3280 fig = plt.gcf() fig.canvas.button_press_event(10, 10, "left") # now let's add a bad channel epochs.info["bads"] = [epochs.ch_names[0]] # include a bad one epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str="%s") fig = epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str="%s") # fake a click event = namedtuple("Event", "inaxes") func = _get_presser(fig) func(event(inaxes=fig.axes[0])) # now do a click in the nav nav_fig = func.keywords["params"]["navigation"] func = _get_presser(nav_fig) func(event(inaxes=nav_fig.axes[1])) plt.close("all")
def test_plot_trellis(): """ Test plotting epochs using Trellis plot""" import matplotlib.pyplot as plt epochs = _get_epochs() epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str='%s') plt.close('all') epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str='%s') plt.close('all') # now let's add a bad channel epochs.info['bads'] = [epochs.ch_names[0]] # include a bad one epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str='%s') plt.close('all') fig = epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str='%s') plt.close('all') fig = epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str='%s') # fake a click event = namedtuple('Event', 'inaxes') func = _get_presser(fig) func(event(inaxes=fig.axes[0])) # now do a click in the nav nav_fig = func.keywords['params']['navigation'] func = _get_presser(nav_fig) func(event(inaxes=nav_fig.axes[1])) plt.close('all')
def test_plot_topo(): """Test plotting of ERP topography """ import matplotlib.pyplot as plt # Show topography evoked = _get_epochs().average() plot_evoked_topo(evoked) # should auto-find layout # Test jointplot evoked.plot_joint() evoked.plot_joint(title='test', ts_args=dict(spatial_colors=True), topomap_args=dict(colorbar=True, times=[0.])) warnings.simplefilter('always', UserWarning) picked_evoked = evoked.pick_channels(evoked.ch_names[:3], copy=True) picked_evoked_eeg = evoked.pick_types(meg=False, eeg=True, copy=True) picked_evoked_eeg.pick_channels(picked_evoked_eeg.ch_names[:3]) # test scaling with warnings.catch_warnings(record=True): for ylim in [dict(mag=[-600, 600]), None]: plot_evoked_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: assert_raises(ValueError, plot_evoked_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked(evoked_delayed_ssp, ch_names) fig = plot_evoked_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', ['inaxes', 'xdata', 'ydata']) func(event(inaxes=fig.axes[0], xdata=fig.axes[0]._mne_axs[0].pos[0], ydata=fig.axes[0]._mne_axs[0].pos[1])) func(event(inaxes=fig.axes[0], xdata=0, ydata=0)) params = dict(evokeds=[picked_evoked_delayed_ssp], times=picked_evoked_delayed_ssp.times, fig=fig, projs=picked_evoked_delayed_ssp.info['projs']) bools = [True] * len(params['projs']) _plot_update_evoked_topo_proj(params, bools) # should auto-generate layout plot_evoked_topo(picked_evoked_eeg.copy(), fig_background=np.zeros((4, 3, 3)), proj=True) picked_evoked.plot_topo(merge_grads=True) # Test RMS plot of grad pairs plt.close('all')
def test_plot_topo(): """Test plotting of ERP topography """ import matplotlib.pyplot as plt # Show topography evoked = _get_epochs().average() plot_evoked_topo(evoked) # should auto-find layout warnings.simplefilter('always', UserWarning) picked_evoked = evoked.pick_channels(evoked.ch_names[:3], copy=True) picked_evoked_eeg = evoked.pick_types(meg=False, eeg=True, copy=True) picked_evoked_eeg.pick_channels(picked_evoked_eeg.ch_names[:3]) # test scaling with warnings.catch_warnings(record=True): for ylim in [dict(mag=[-600, 600]), None]: plot_evoked_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: assert_raises(ValueError, plot_evoked_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked( evoked_delayed_ssp, ch_names) fig = plot_evoked_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', 'inaxes') func(event(inaxes=fig.axes[0])) params = dict(evokeds=[picked_evoked_delayed_ssp], times=picked_evoked_delayed_ssp.times, fig=fig, projs=picked_evoked_delayed_ssp.info['projs']) bools = [True] * len(params['projs']) _plot_update_evoked_topo(params, bools) # should auto-generate layout plot_evoked_topo(picked_evoked_eeg.copy(), fig_background=np.zeros((4, 3, 3)), proj=True) plt.close('all')
def test_plot_topo(): """Test plotting of ERP topography.""" # Show topography evoked = _get_epochs().average() # should auto-find layout plot_evoked_topo([evoked, evoked], merge_grads=True, background_color='w') picked_evoked = evoked.copy().pick_channels(evoked.ch_names[:3]) picked_evoked_eeg = evoked.copy().pick_types(meg=False, eeg=True) picked_evoked_eeg.pick_channels(picked_evoked_eeg.ch_names[:3]) # test scaling for ylim in [dict(mag=[-600, 600]), None]: plot_evoked_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: pytest.raises(ValueError, plot_evoked_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked(evoked_delayed_ssp, ch_names) fig = plot_evoked_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', ['inaxes', 'xdata', 'ydata']) func( event(inaxes=fig.axes[0], xdata=fig.axes[0]._mne_axs[0].pos[0], ydata=fig.axes[0]._mne_axs[0].pos[1])) func(event(inaxes=fig.axes[0], xdata=0, ydata=0)) params = dict(evokeds=[picked_evoked_delayed_ssp], times=picked_evoked_delayed_ssp.times, fig=fig, projs=picked_evoked_delayed_ssp.info['projs']) bools = [True] * len(params['projs']) with pytest.warns(RuntimeWarning, match='projection'): _plot_update_evoked_topo_proj(params, bools) # should auto-generate layout plot_evoked_topo(picked_evoked_eeg.copy(), fig_background=np.zeros((4, 3, 3)), proj=True, background_color='k') # Test RMS plot of grad pairs picked_evoked.plot_topo(merge_grads=True, background_color='w') plt.close('all') for ax, idx in iter_topography(evoked.info, legend=True): ax.plot(evoked.data[idx], color='red') # test status bar message if idx != -1: assert (evoked.ch_names[idx] in ax.format_coord(.5, .5)) assert idx == -1 plt.close('all') cov = read_cov(cov_fname) cov['projs'] = [] evoked.pick_types(meg=True).plot_topo(noise_cov=cov) plt.close('all') # test plot_topo evoked.plot_topo() # should auto-find layout _line_plot_onselect(0, 200, ['mag', 'grad'], evoked.info, evoked.data, evoked.times) plt.close('all') for ax, idx in iter_topography(evoked.info): # brief test with false ax.plot([0, 1, 2]) break plt.close('all')
def test_plot_topo(): """Test plotting of ERP topography.""" import matplotlib.pyplot as plt # Show topography evoked = _get_epochs().average() # should auto-find layout plot_evoked_topo([evoked, evoked], merge_grads=True, background_color='w') # Test jointplot evoked.plot_joint(ts_args=dict(time_unit='s'), topomap_args=dict(time_unit='s')) def return_inds(d): # to test function kwarg to zorder arg of evoked.plot return list(range(d.shape[0])) evoked.plot_joint(title='test', topomap_args=dict(contours=0, res=8, time_unit='ms'), ts_args=dict(spatial_colors=True, zorder=return_inds, time_unit='s')) pytest.raises(ValueError, evoked.plot_joint, ts_args=dict(axes=True, time_unit='s')) axes = plt.subplots(nrows=3)[-1].flatten().tolist() evoked.plot_joint(times=[0], picks=[6, 7, 8], ts_args=dict(axes=axes[0]), topomap_args={ "axes": axes[1:], "time_unit": "s" }) plt.close() pytest.raises(ValueError, evoked.plot_joint, picks=[6, 7, 8], ts_args=dict(axes=axes[0]), topomap_args=dict(axes=axes[2:])) warnings.simplefilter('always', UserWarning) picked_evoked = evoked.copy().pick_channels(evoked.ch_names[:3]) picked_evoked_eeg = evoked.copy().pick_types(meg=False, eeg=True) picked_evoked_eeg.pick_channels(picked_evoked_eeg.ch_names[:3]) # test scaling with warnings.catch_warnings(record=True): for ylim in [dict(mag=[-600, 600]), None]: plot_evoked_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: pytest.raises(ValueError, plot_evoked_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked( evoked_delayed_ssp, ch_names) fig = plot_evoked_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', ['inaxes', 'xdata', 'ydata']) func( event(inaxes=fig.axes[0], xdata=fig.axes[0]._mne_axs[0].pos[0], ydata=fig.axes[0]._mne_axs[0].pos[1])) func(event(inaxes=fig.axes[0], xdata=0, ydata=0)) params = dict(evokeds=[picked_evoked_delayed_ssp], times=picked_evoked_delayed_ssp.times, fig=fig, projs=picked_evoked_delayed_ssp.info['projs']) bools = [True] * len(params['projs']) _plot_update_evoked_topo_proj(params, bools) # should auto-generate layout plot_evoked_topo(picked_evoked_eeg.copy(), fig_background=np.zeros((4, 3, 3)), proj=True, background_color='k') # Test RMS plot of grad pairs picked_evoked.plot_topo(merge_grads=True, background_color='w') plt.close('all') for ax, idx in iter_topography(evoked.info): ax.plot(evoked.data[idx], color='red') # test status bar message assert (evoked.ch_names[idx] in ax.format_coord(.5, .5)) plt.close('all') cov = read_cov(cov_fname) cov['projs'] = [] evoked.pick_types(meg=True).plot_topo(noise_cov=cov) plt.close('all')
def test_plot_topo(): """Test plotting of ERP topography.""" # Show topography evoked = _get_epochs().average() # should auto-find layout plot_evoked_topo([evoked, evoked], merge_grads=True, background_color='w') # Test jointplot evoked.plot_joint(ts_args=dict(time_unit='s'), topomap_args=dict(time_unit='s')) def return_inds(d): # to test function kwarg to zorder arg of evoked.plot return list(range(d.shape[0])) evoked.plot_joint(title='test', topomap_args=dict(contours=0, res=8, time_unit='ms'), ts_args=dict(spatial_colors=True, zorder=return_inds, time_unit='s')) pytest.raises(ValueError, evoked.plot_joint, ts_args=dict(axes=True, time_unit='s')) axes = plt.subplots(nrows=3)[-1].flatten().tolist() evoked.plot_joint(times=[0], picks=[6, 7, 8], ts_args=dict(axes=axes[0]), topomap_args={"axes": axes[1:], "time_unit": "s"}) plt.close() pytest.raises(ValueError, evoked.plot_joint, picks=[6, 7, 8], ts_args=dict(axes=axes[0]), topomap_args=dict(axes=axes[2:])) picked_evoked = evoked.copy().pick_channels(evoked.ch_names[:3]) picked_evoked_eeg = evoked.copy().pick_types(meg=False, eeg=True) picked_evoked_eeg.pick_channels(picked_evoked_eeg.ch_names[:3]) # test scaling for ylim in [dict(mag=[-600, 600]), None]: plot_evoked_topo([picked_evoked] * 2, layout, ylim=ylim) for evo in [evoked, [evoked, picked_evoked]]: pytest.raises(ValueError, plot_evoked_topo, evo, layout, color=['y', 'b']) evoked_delayed_ssp = _get_epochs_delayed_ssp().average() ch_names = evoked_delayed_ssp.ch_names[:3] # make it faster picked_evoked_delayed_ssp = pick_channels_evoked(evoked_delayed_ssp, ch_names) fig = plot_evoked_topo(picked_evoked_delayed_ssp, layout, proj='interactive') func = _get_presser(fig) event = namedtuple('Event', ['inaxes', 'xdata', 'ydata']) func(event(inaxes=fig.axes[0], xdata=fig.axes[0]._mne_axs[0].pos[0], ydata=fig.axes[0]._mne_axs[0].pos[1])) func(event(inaxes=fig.axes[0], xdata=0, ydata=0)) params = dict(evokeds=[picked_evoked_delayed_ssp], times=picked_evoked_delayed_ssp.times, fig=fig, projs=picked_evoked_delayed_ssp.info['projs']) bools = [True] * len(params['projs']) with pytest.warns(RuntimeWarning, match='projection'): _plot_update_evoked_topo_proj(params, bools) # should auto-generate layout plot_evoked_topo(picked_evoked_eeg.copy(), fig_background=np.zeros((4, 3, 3)), proj=True, background_color='k') # Test RMS plot of grad pairs picked_evoked.plot_topo(merge_grads=True, background_color='w') plt.close('all') for ax, idx in iter_topography(evoked.info): ax.plot(evoked.data[idx], color='red') # test status bar message assert (evoked.ch_names[idx] in ax.format_coord(.5, .5)) plt.close('all') cov = read_cov(cov_fname) cov['projs'] = [] evoked.pick_types(meg=True).plot_topo(noise_cov=cov) plt.close('all') # test plot_topo evoked.plot_topo() # should auto-find layout _line_plot_onselect(0, 200, ['mag', 'grad'], evoked.info, evoked.data, evoked.times) plt.close('all')