Skip to content

Commit

Permalink
adding background image to other topoplots
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Jun 30, 2016
1 parent 1a641d7 commit 94e07d4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
11 changes: 7 additions & 4 deletions mne/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,8 @@ def plot_psd_topomap(self, bands=None, vmin=None, vmax=None, proj=False,
def plot_topo_image(self, layout=None, sigma=0., vmin=None, vmax=None,
colorbar=True, order=None, cmap='RdBu_r',
layout_scale=.95, title=None, scalings=None,
border='none', fig_facecolor='k', font_color='w',
show=True):
border='none', fig_facecolor='k', fig_background=None,
font_color='w', show=True):
"""Plot Event Related Potential / Fields image on topographies
Parameters
Expand Down Expand Up @@ -1039,6 +1039,9 @@ def plot_topo_image(self, layout=None, sigma=0., vmin=None, vmax=None,
matplotlib borders style to be used for each sensor plot.
fig_facecolor : str | obj
The figure face color. Defaults to black.
fig_background : None | numpy ndarray
A background image for the figure. This must work with a call to
plt.imshow. Defaults to None.
font_color : str | obj
The color of tick labels in the colorbar. Defaults to white.
show : bool
Expand All @@ -1053,8 +1056,8 @@ def plot_topo_image(self, layout=None, sigma=0., vmin=None, vmax=None,
self, layout=layout, sigma=sigma, vmin=vmin, vmax=vmax,
colorbar=colorbar, order=order, cmap=cmap,
layout_scale=layout_scale, title=title, scalings=scalings,
border=border, fig_facecolor=fig_facecolor, font_color=font_color,
show=show)
border=border, fig_facecolor=fig_facecolor,
fig_background=fig_background, font_color=font_color, show=show)

@verbose
def drop_bad(self, reject='existing', flat='existing', verbose=None):
Expand Down
10 changes: 9 additions & 1 deletion mne/time_frequency/tfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,8 @@ def plot_topo(self, picks=None, baseline=None, mode='mean', tmin=None,
tmax=None, fmin=None, fmax=None, vmin=None, vmax=None,
layout=None, cmap='RdBu_r', title=None, dB=False,
colorbar=True, layout_scale=0.945, show=True,
border='none', fig_facecolor='k', font_color='w'):
border='none', fig_facecolor='k', fig_background=None,
font_color='w'):
"""Plot TFRs in a topography with images
Parameters
Expand Down Expand Up @@ -865,6 +866,9 @@ def plot_topo(self, picks=None, baseline=None, mode='mean', tmin=None,
matplotlib borders style to be used for each sensor plot.
fig_facecolor : str | obj
The figure face color. Defaults to black.
fig_background : None | numpy ndarray
A background image for the figure. This must work with a call to
plt.imshow. Defaults to None.
font_color: str | obj
The color of tick labels in the colorbar. Defaults to white.
Expand All @@ -874,6 +878,7 @@ def plot_topo(self, picks=None, baseline=None, mode='mean', tmin=None,
The figure containing the topography.
"""
from ..viz.topo import _imshow_tfr, _plot_topo, _imshow_tfr_unified
from ..viz import add_background_image
times = self.times.copy()
freqs = self.freqs
data = self.data
Expand Down Expand Up @@ -904,6 +909,9 @@ def plot_topo(self, picks=None, baseline=None, mode='mean', tmin=None,
x_label='Time (ms)', y_label='Frequency (Hz)',
fig_facecolor=fig_facecolor, font_color=font_color,
unified=True, img=True)

if fig_background is not None:
add_background_image(fig, fig_background)
plt_show(show)
return fig

Expand Down
9 changes: 7 additions & 2 deletions mne/viz/topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ def _plot_update_evoked_topo_proj(params, bools):
def plot_topo_image_epochs(epochs, layout=None, sigma=0., vmin=None,
vmax=None, colorbar=True, order=None, cmap='RdBu_r',
layout_scale=.95, title=None, scalings=None,
border='none', fig_facecolor='k', font_color='w',
show=True):
border='none', fig_facecolor='k',
fig_background=None, font_color='w', show=True):
"""Plot Event Related Potential / Fields image on topographies
Parameters
Expand Down Expand Up @@ -685,6 +685,9 @@ def plot_topo_image_epochs(epochs, layout=None, sigma=0., vmin=None,
matplotlib borders style to be used for each sensor plot.
fig_facecolor : str | obj
The figure face color. Defaults to black.
fig_background : None | numpy ndarray
A background image for the figure. This must work with a call to
plt.imshow. Defaults to None.
font_color : str | obj
The color of tick labels in the colorbar. Defaults to white.
show : bool
Expand Down Expand Up @@ -721,5 +724,7 @@ def plot_topo_image_epochs(epochs, layout=None, sigma=0., vmin=None,
fig_facecolor=fig_facecolor, font_color=font_color,
border=border, x_label='Time (s)', y_label='Epoch',
unified=True, img=True)
if fig_background is not None:
add_background_image(fig, fig_background)
plt_show(show)
return fig

0 comments on commit 94e07d4

Please sign in to comment.