Repository: mne-tools/mne-python

Issue:
ENH: Disable gaussian smoothing in mne.viz.plot_topo_image_epochs
Hello,

I'd like to disable the gaussian smoothing when plotting image epochs, so I can clearly identify which trials have artifacts in them. I thought that the user could set `sigma=None`, in which case the smoothing step is skipped. Would anyone else be interested in this option?

Alan



Discussion:
what if you set sigma=0. ? does it do the job?

This is with sigma=0, but I was hoping for something more pixellated so I can see where the edges are.

![screenshot from 2015-07-20 14 51 00](https://cloud.githubusercontent.com/assets/1099867/8788385/d79e0f12-2eee-11e5-95cc-617790c26c10.png)

What does it look like with nearest-neighbor interpolation (instead of bilinear) on the `imshow` with different sigmas? It would make sense to me to have NN interp on by default, since the sigmas should take care of the smoothing for you.

Here's the same image with nearest

![screenshot from 2015-07-20 15 12 47](https://cloud.githubusercontent.com/assets/1099867/8788802/d2150e58-2ef1-11e5-8120-4f3656382d83.png)

looks good no?

That is what I would expect from `sigma=0.` and nearest-neighbor interpolation. The smearing on the temporal axis is due to the overlapping of the windows used.

What does it look like for the default sigma value? Is it very different from how it is with bilinear interp on?

Ok, here it is with `interpolation='nearest'` with the default sigma value.

![screenshot from 2015-07-20 15 30 41](https://cloud.githubusercontent.com/assets/1099867/8789086/4f986094-2ef4-11e5-8120-a575822855cd.png)

so the smoothing is happening in the temporal domain, not across trials?

It should happen across trials. We have a bug???

It is smoothing across trials, I just tried out a few different sigmas. But if I wanted to look at the trials without blurring, I need to change both sigma and the interpolation argument.

try sigma=2, it should make it smooth vertically

Maybe we should change the default to something like that. I think in any case we should set the interpolation to nearest. It is a bit silly to have two forms of interpolation going on like that.

+1 for smoothing vertically and use nearest.

volunteer?

@leggitta you find that it's broken you buy it? :)

Sounds fair. The vertical smoothing seems to be working fine. The below plot is with sigma=2 and interpolation='nearest'.

Should I make interpolation='nearest' for all functions that use imshow?

![screenshot from 2015-07-21 09 47 39](https://cloud.githubusercontent.com/assets/1099867/8806851/8b2307b0-2f8d-11e5-8f45-84184a56b30c.png)


Resolving patch:
diff --git a/mne/viz/epochs.py b/mne/viz/epochs.py
--- a/mne/viz/epochs.py
+++ b/mne/viz/epochs.py
@@ -27,7 +27,7 @@
 from ..defaults import _handle_default
 
 
-def plot_image_epochs(epochs, picks=None, sigma=0.3, vmin=None,
+def plot_image_epochs(epochs, picks=None, sigma=0., vmin=None,
                       vmax=None, colorbar=True, order=None, show=True,
                       units=None, scalings=None, cmap='RdBu_r'):
     """Plot Event Related Potential / Fields image
@@ -41,7 +41,7 @@ def plot_image_epochs(epochs, picks=None, sigma=0.3, vmin=None,
         data channels are plotted.
     sigma : float
         The standard deviation of the Gaussian smoothing to apply along
-        the epoch axis to apply in the image.
+        the epoch axis to apply in the image. If 0., no smoothing is applied.
     vmin : float
         The min value in the image. The unit is uV for EEG channels,
         fT for magnetometers and fT/cm for gradiometers
@@ -110,13 +110,15 @@ def plot_image_epochs(epochs, picks=None, sigma=0.3, vmin=None,
         if this_order is not None:
             this_data = this_data[this_order]
 
-        this_data = ndimage.gaussian_filter1d(this_data, sigma=sigma, axis=0)
+        if sigma > 0.:
+            this_data = ndimage.gaussian_filter1d(this_data, sigma=sigma,
+                                                  axis=0)
 
         ax1 = plt.subplot2grid((3, 10), (0, 0), colspan=9, rowspan=2)
         im = plt.imshow(this_data,
                         extent=[1e3 * epochs.times[0], 1e3 * epochs.times[-1],
                                 0, len(data)],
-                        aspect='auto', origin='lower',
+                        aspect='auto', origin='lower', interpolation='nearest',
                         vmin=vmin, vmax=vmax, cmap=cmap)
         ax2 = plt.subplot2grid((3, 10), (2, 0), colspan=9, rowspan=1)
         if colorbar:
@@ -128,6 +130,7 @@ def plot_image_epochs(epochs, picks=None, sigma=0.3, vmin=None,
         ax1.axvline(0, color='m', linewidth=3, linestyle='--')
         ax2.plot(1e3 * evoked.times, scalings[ch_type] * evoked.data[i])
         ax2.set_xlabel('Time (ms)')
+        ax2.set_xlim([1e3 * evoked.times[0], 1e3 * evoked.times[-1]])
         ax2.set_ylabel(units[ch_type])
         ax2.set_ylim([vmin, vmax])
         ax2.axvline(0, color='m', linewidth=3, linestyle='--')
diff --git a/mne/viz/topo.py b/mne/viz/topo.py
--- a/mne/viz/topo.py
+++ b/mne/viz/topo.py
@@ -448,11 +448,12 @@ def _erfimage_imshow(ax, ch_idx, tmin, tmax, vmin, vmax, ylim=None,
     if order is not None:
         this_data = this_data[order]
 
-    this_data = ndimage.gaussian_filter1d(this_data, sigma=sigma, axis=0)
+    if sigma > 0.:
+        this_data = ndimage.gaussian_filter1d(this_data, sigma=sigma, axis=0)
 
     ax.imshow(this_data, extent=[tmin, tmax, 0, len(data)], aspect='auto',
               origin='lower', vmin=vmin, vmax=vmax, picker=True,
-              cmap=cmap)
+              cmap=cmap, interpolation='nearest')
 
     if x_label is not None:
         plt.xlabel(x_label)
@@ -462,7 +463,7 @@ def _erfimage_imshow(ax, ch_idx, tmin, tmax, vmin, vmax, ylim=None,
         plt.colorbar()
 
 
-def plot_topo_image_epochs(epochs, layout=None, sigma=0.3, vmin=None,
+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',
@@ -477,7 +478,7 @@ def plot_topo_image_epochs(epochs, layout=None, sigma=0.3, vmin=None,
         System specific sensor positions.
     sigma : float
         The standard deviation of the Gaussian smoothing to apply along
-        the epoch axis to apply in the image.
+        the epoch axis to apply in the image. If 0., no smoothing is applied.
     vmin : float
         The min value in the image. The unit is uV for EEG channels,
         fT for magnetometers and fT/cm for gradiometers.


Test patch: