internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mne-tools/mne-python

Issue:
[VIZ] Rendering bug in plot_evoked_field()
#### Describe the bug
Rendering bug introduced by the migration to the renderer backend.

Current result:
![image](https://user-images.githubusercontent.com/18143289/53101126-6f5fee80-3529-11e9-991a-f40d0ed5dfe7.png)

Correct result:
![image](https://user-images.githubusercontent.com/18143289/53101083-5f480f00-3529-11e9-9f06-8d3fa48504c8.png)

#### Steps and/or code to reproduce
Follow the example  : *Visualize Evoked data*
`$ ipython --matplotlib --gui=qt tutorials/plot_visualize_evoked.py`


Discussion:

Resolving patch:
diff --git a/mne/viz/_3d.py b/mne/viz/_3d.py
--- a/mne/viz/_3d.py
+++ b/mne/viz/_3d.py
@@ -390,7 +390,7 @@ def plot_evoked_field(evoked, surf_maps, time=None, time_label='t = %0.0f ms',
         # Now show our field pattern
         with warnings.catch_warnings(record=True):  # traits
             renderer.surface(surface=surf, vmin=-vlim, vmax=vlim,
-                             colormap=colormap)
+                             scalars=data, colormap=colormap)
 
         # And the field lines on top
         with warnings.catch_warnings(record=True):  # traits
diff --git a/mne/viz/backends/_pysurfer_mayavi.py b/mne/viz/backends/_pysurfer_mayavi.py
--- a/mne/viz/backends/_pysurfer_mayavi.py
+++ b/mne/viz/backends/_pysurfer_mayavi.py
@@ -152,8 +152,8 @@ def contour(self, surface, scalars, contours, line_width=1.0, opacity=1.0,
             opacity=opacity, figure=self.fig)
         cont.module_manager.scalar_lut_manager.lut.table = colormap
 
-    def surface(self, surface, color=(0.7, 0.7, 0.7), opacity=1.0,
-                vmin=None, vmax=None, colormap=None,
+    def surface(self, surface, color=None, opacity=1.0,
+                vmin=None, vmax=None, colormap=None, scalars=None,
                 backface_culling=False):
         """Add a surface in the scene.
 
@@ -177,7 +177,7 @@ def surface(self, surface, color=(0.7, 0.7, 0.7), opacity=1.0,
             If True, enable backface culling on the surface.
         """
         # Make a solid surface
-        mesh = _create_mesh_surf(surface, self.fig)
+        mesh = _create_mesh_surf(surface, self.fig, scalars=scalars)
         surface = self.mlab.pipeline.surface(
             mesh, color=color, opacity=opacity, vmin=vmin, vmax=vmax,
             figure=self.fig)
diff --git a/tutorials/plot_visualize_evoked.py b/tutorials/plot_visualize_evoked.py
--- a/tutorials/plot_visualize_evoked.py
+++ b/tutorials/plot_visualize_evoked.py
@@ -73,7 +73,7 @@
 evoked_r_aud.plot_topomap(times=times, ch_type='mag', time_unit='s')
 
 ###############################################################################
-# Or we can automatically select the peaks.
+# Or we can select automatically the peaks.
 evoked_r_aud.plot_topomap(times='peaks', ch_type='mag', time_unit='s')
 
 ###############################################################################


Test patch:
Repository: mne-tools/mne-python

Issue:
raw.get_data() should accept int64
When loading a file to `RawArray`, the `get_data()` command does only accept `int32`, but should accept all `ints`, including `int64`, as this is the standard `dtype` for many numpy functions (e.g. `np.argmax`). It's a small change, I'll propose it.


Discussion:
can you provide a code snippet to replicate? are you on windows?

>


Resolving patch:
diff --git a/mne/io/pick.py b/mne/io/pick.py
--- a/mne/io/pick.py
+++ b/mne/io/pick.py
@@ -829,9 +829,10 @@ def _picks_to_idx(info, picks, none='data', exclude='bads', allow_empty=False,
         raise ValueError('picks must be 1D, got %sD' % (picks.ndim,))
     if picks.dtype.char in ('S', 'U'):
         picks = _picks_str_to_idx(info, picks, exclude, with_ref_meg)
-    if picks.dtype != np.int:
+    if picks.dtype.kind not in ['i', 'u']:
         raise TypeError('picks must be a list of int or list of str, got '
                         'a data type of %s' % (picks.dtype,))
+    picks = picks.astype(int)
 
     #
     # ensure we have (optionally non-empty) ndarray of valid int


Test patch:
Repository: mne-tools/mne-python

Issue:
BUG: plot_sparse_source_estimates broken
See last plot in [master](http://mne-tools.github.io/dev/auto_examples/inverse/plot_custom_inverse_solver.html) compared to [maint/0.17](http://mne-tools.github.io/stable/auto_examples/inverse/plot_custom_inverse_solver.html). @GuillaumeFavelier 


Discussion:

Resolving patch:
diff --git a/examples/inverse/plot_custom_inverse_solver.py b/examples/inverse/plot_custom_inverse_solver.py
--- a/examples/inverse/plot_custom_inverse_solver.py
+++ b/examples/inverse/plot_custom_inverse_solver.py
@@ -14,7 +14,7 @@
 
 The example makes use of 2 functions ``apply_solver`` and ``solver``
 so changes can be limited to the ``solver`` function (which only takes three
-parameters: the whitened data, the gain matrix, and the number of orientations)
+parameters: the whitened data, the gain matrix and the number of orientations)
 in order to try out another inverse algorithm.
 """
 
diff --git a/mne/viz/backends/_pysurfer_mayavi.py b/mne/viz/backends/_pysurfer_mayavi.py
--- a/mne/viz/backends/_pysurfer_mayavi.py
+++ b/mne/viz/backends/_pysurfer_mayavi.py
@@ -239,7 +239,7 @@ def quiver3d(self, x, y, z, u, v, w, color, scale, mode, resolution=8,
             The color of the quiver: (red, green, blue).
         scale: float
             The scale of the quiver.
-        mode: 'arrow' or 'cylinder'
+        mode: 'arrow', 'cone' or 'cylinder'
             The type of the quiver.
         resolution: float
             The resolution of the arrow.
@@ -264,6 +264,10 @@ def quiver3d(self, x, y, z, u, v, w, color, scale, mode, resolution=8,
                                scale_mode=scale_mode,
                                resolution=resolution, scalars=scalars,
                                opacity=opacity, figure=self.fig)
+        elif mode == 'cone':
+            self.mlab.quiver3d(x, y, z, u, v, w, color=color,
+                               mode=mode, scale_factor=scale,
+                               opacity=opacity, figure=self.fig)
         elif mode == 'cylinder':
             quiv = self.mlab.quiver3d(x, y, z, u, v, w, mode=mode,
                                       color=color, scale_factor=scale,


Test patch:
Repository: mne-tools/mne-python

Issue:
Do we need scikit-learn for Infomax ICA?
Currently, we [require `scikit-learn` for all ICA algorithms](https://github.com/mne-tools/mne-python/blob/cffcf4b1aeaf04655f6917718029c59ff412c917/mne/preprocessing/ica.py#L316). However, I don't think that Infomax requires `scikit-learn`, only FastICA uses the implementation in this package. Not sure how we handle Picard, but I think it requires `scikit-learn` either.



Discussion:
true: infomax and picard don't need sklearn (see
https://github.com/pierreablin/picard/blob/master/.travis.yml)

>


Resolving patch:
diff --git a/mne/preprocessing/ica.py b/mne/preprocessing/ica.py
--- a/mne/preprocessing/ica.py
+++ b/mne/preprocessing/ica.py
@@ -313,9 +313,9 @@ def __init__(self, n_components=None, max_pca_components=None,
                  "in 0.19. If you want to use Extended Infomax, specify "
                  "method='infomax' together with "
                  "fit_params=dict(extended=True).", DeprecationWarning)
-        if not check_version('sklearn', '0.15'):
-            raise RuntimeError('the scikit-learn package (version >= 0.15) '
-                               'is required for ICA')
+        if method == 'fastica' and not check_version('sklearn', '0.15'):
+            raise RuntimeError('The scikit-learn package (version >= 0.15) '
+                               'is required for FastICA.')
 
         self.noise_cov = noise_cov
 


Test patch:
diff --git a/mne/preprocessing/tests/test_ica.py b/mne/preprocessing/tests/test_ica.py
--- a/mne/preprocessing/tests/test_ica.py
+++ b/mne/preprocessing/tests/test_ica.py
@@ -122,10 +122,14 @@ def test_ica_full_data_recovery(method):
     pytest.raises(ValueError, ICA, method='pizza-decomposision')
 
 
-@requires_sklearn
 @pytest.mark.parametrize("method", ["fastica", "picard"])
 def test_ica_simple(method):
     """Test that ICA recovers the unmixing matrix in a simple case."""
+    if method == "fastica":
+        try:
+            import sklearn  # noqa: F401
+        except ImportError:
+            raise SkipTest("scikit-learn not installed")
     _skip_check_picard(method)
     n_components = 3
     n_samples = 1000
Repository: mne-tools/mne-python

Issue:
pip install mne should install numpy and scipy
Currently, the `mne` PyPI package doesn't have any dependencies, but I think it should really treat `numpy` and `scipy` as hard dependencies (and automatically install them if they are not present).


Discussion:
Now that wheels seem to be a very usable, stable thing, I agree we should add our hard dependencies in our requirements list. Even [sklearn does it nowadays](https://github.com/scikit-learn/scikit-learn/blob/master/setup.py#L246-L249).
I was gonna mention that even sklearn does it but you beat me to it :smile:. I'll make a PR.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -69,6 +69,7 @@ def package_tree(pkgroot):
                        'Programming Language :: Python :: 3',
                        ],
           platforms='any',
+          install_requires=['numpy>=1.11.3', 'scipy>=0.17.1'],
           packages=package_tree('mne'),
           package_data={'mne': [
               op.join('data', '*.sel'),


Test patch:
Repository: mne-tools/mne-python

Issue:
Channel names from .locs file truncated to 4 characters
I'm reading a locs montage file with an EDF file and I noticed that my channel names weren't matching.  I dug through the `read_montage()` function and found the following:

https://github.com/mne-tools/mne-python/blob/b74bb10d779dfd8144a4b6fd8fc5444f441f2141/mne/channels/montage.py#L316

Is it part of the specification of the locs format that channel names are restricted to 4 characters?  I have some examples here with longer names and I was wondering if this is valid.


Discussion:
@achilleas-k I don't think so at least not in EDF+ (IIRC)
It's very possible MNE is too conservative here. PR welcome

>


Resolving patch:
diff --git a/mne/channels/montage.py b/mne/channels/montage.py
--- a/mne/channels/montage.py
+++ b/mne/channels/montage.py
@@ -313,8 +313,7 @@ def read_montage(kind, ch_names=None, path=None, unit='m', transform=False):
         ch_names_ = data['name'].astype(str).tolist()
         pos = np.vstack((data['x'], data['y'], data['z'])).T
     elif ext in ('.loc', '.locs', '.eloc'):
-        ch_names_ = np.loadtxt(fname, dtype='S4',
-                               usecols=[3]).astype(str).tolist()
+        ch_names_ = np.genfromtxt(fname, dtype=str, usecols=3).tolist()
         topo = np.loadtxt(fname, dtype=float, usecols=[1, 2])
         sph = _topo_to_sph(topo)
         pos = _sph_to_cart(sph)


Test patch:
Repository: mne-tools/mne-python

Issue:
_smart_pad function from cuda is not using the second dimension of n_pad argument
#### Describe the bug

I don't think this affects too many things, but `_smart_pad` function is not using the second dimension of n_pad argument.

#### Steps and/or code to reproduce

```Python
import mne
import numpy as np

 mne.cuda._smart_pad(np.array([1,2,3]),[2,2])
 mne.cuda._smart_pad(np.array([1,2,3]),[2,10])
```

Both calls give the same results

####  `mne.sys_info()`

```
Platform:      Linux-4.15.0-46-generic-x86_64-with-debian-buster-sid
Python:        3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)  [GCC 7.3.0]
Executable:    /home/bruno/anaconda3/envs/mne/bin/python
CPU:           x86_64: 4 cores
Memory:        11.4 GB

mne:           0.17.1
numpy:         1.16.2 {blas=mkl_rt, lapack=mkl_rt}
scipy:         1.2.1
matplotlib:    3.0.3 {backend=Qt5Agg}

sklearn:       0.20.3
nibabel:       2.3.3
mayavi:        4.7.0.dev0 {qt_api=pyqt5, PyQt5=5.9.2}
cupy:          Not found
pandas:        0.24.2
dipy:          0.16.0
```


Discussion:

Resolving patch:
diff --git a/mne/cuda.py b/mne/cuda.py
--- a/mne/cuda.py
+++ b/mne/cuda.py
@@ -321,7 +321,7 @@ def _smart_pad(x, n_pad, pad='reflect_limited'):
     if pad == 'reflect_limited':
         # need to pad with zeros if len(x) <= npad
         l_z_pad = np.zeros(max(n_pad[0] - len(x) + 1, 0), dtype=x.dtype)
-        r_z_pad = np.zeros(max(n_pad[0] - len(x) + 1, 0), dtype=x.dtype)
+        r_z_pad = np.zeros(max(n_pad[1] - len(x) + 1, 0), dtype=x.dtype)
         return np.concatenate([l_z_pad, 2 * x[0] - x[n_pad[0]:0:-1], x,
                                2 * x[-1] - x[-2:-n_pad[1] - 2:-1], r_z_pad])
     else:


Test patch:
Repository: mne-tools/mne-python

Issue:
ENH: better automatic plot titles in plot_compare_evokeds
```py
plot_compare_evokeds(list_of_evokeds, picks='grad')
```
yields
`RuntimeWarning: More than 6 channels, truncating title ...`

Two suggested enhancements:

1. if `picks` is one of the standard types (`eeg`, `mag`, `grad`...) then the title should reflect the channel type, rather than trying to list all channel names
2. if specific channels are requested, the truncation should happen with an info message printed to the terminal, not a `RuntimeWarning` (admittedly subjective, but I think a warning seems too strong for a "we truncated your plot title" message)


Discussion:
I can take this on at the sprint; cc @jona-sassenhagen because of possible interaction with #4746 
Agreed!

I think it's fairly independent and I agree with your judgements though. But we will talk about all this at the sprint anyways.

Resolving patch:
diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py
--- a/mne/viz/evoked.py
+++ b/mne/viz/evoked.py
@@ -1875,6 +1875,8 @@ def plot_compare_evokeds(evokeds, picks=None, gfp=False, colors=None,
     _validate_type(vlines, (list, tuple), "vlines", "list or tuple")
 
     picks = [] if picks is None else picks
+    if title is None and picks in _DATA_CH_TYPES_SPLIT:
+        title = _handle_default('titles')[picks]
     picks = _picks_to_idx(info, picks, allow_empty=True)
     if len(picks) == 0:
         logger.info("No picks, plotting the GFP ...")
diff --git a/mne/viz/utils.py b/mne/viz/utils.py
--- a/mne/viz/utils.py
+++ b/mne/viz/utils.py
@@ -32,7 +32,8 @@
                        pick_info, _picks_by_type, pick_channels_cov)
 from ..rank import compute_rank
 from ..io.proj import setup_proj
-from ..utils import verbose, set_config, warn, _check_ch_locs, _check_option
+from ..utils import (verbose, set_config, warn, _check_ch_locs, _check_option,
+                     logger)
 
 from ..selection import (read_selection, _SELECTIONS, _EEG_SELECTIONS,
                          _divide_to_regions)
@@ -2557,7 +2558,7 @@ def _set_title_multiple_electrodes(title, combine, ch_names, max_chans=6,
             title = "{} of {} {}".format(
                 combine, len(ch_names), ch_type)
         elif len(ch_names) > max_chans and combine != "gfp":
-            warn("More than {} channels, truncating title ...".format(
+            logger.info("More than {} channels, truncating title ...".format(
                 max_chans))
             title += ", ...\n({} of {} {})".format(
                 combine, len(ch_names), ch_type,)


Test patch:
Repository: mne-tools/mne-python

Issue:
MINOR _plot_masked_image has a picks argument that appears to go unused
>_plot_masked_image has a picks argument that appears to go unused

Thanks @drammock


Discussion:

Resolving patch:
diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py
--- a/mne/viz/evoked.py
+++ b/mne/viz/evoked.py
@@ -579,7 +579,7 @@ def _plot_image(data, ax, this_type, picks, cmap, unit, units, scalings, times,
     _check_if_nan(data)
 
     im, t_end = _plot_masked_image(
-        ax, data, times, mask, picks=None, yvals=None, cmap=cmap[0],
+        ax, data, times, mask, yvals=None, cmap=cmap[0],
         vmin=vmin, vmax=vmax, mask_style=mask_style, mask_alpha=mask_alpha,
         mask_cmap=mask_cmap)
 
diff --git a/mne/viz/topo.py b/mne/viz/topo.py
--- a/mne/viz/topo.py
+++ b/mne/viz/topo.py
@@ -297,7 +297,7 @@ def _imshow_tfr(ax, ch_idx, tmin, tmax, vmin, vmax, onselect, ylim=None,
     times = np.linspace(tmin, tmax, num=tfr[ch_idx].shape[1])
 
     img, t_end = _plot_masked_image(
-        ax, tfr[ch_idx], times, mask, picks=None, yvals=freq, cmap=cmap,
+        ax, tfr[ch_idx], times, mask, yvals=freq, cmap=cmap,
         vmin=vmin, vmax=vmax, mask_style=mask_style, mask_alpha=mask_alpha,
         mask_cmap=mask_cmap, yscale=yscale)
 
diff --git a/mne/viz/utils.py b/mne/viz/utils.py
--- a/mne/viz/utils.py
+++ b/mne/viz/utils.py
@@ -2576,7 +2576,7 @@ def _check_time_unit(time_unit, times):
     return time_unit, times
 
 
-def _plot_masked_image(ax, data, times, mask=None, picks=None, yvals=None,
+def _plot_masked_image(ax, data, times, mask=None, yvals=None,
                        cmap="RdBu_r", vmin=None, vmax=None, ylim=None,
                        mask_style="both", mask_alpha=.25, mask_cmap="Greys",
                        yscale="linear"):


Test patch:
Repository: mne-tools/mne-python

Issue:
plot_compare_evoked opens 3 figures but only draws 1
when the user has not imported matplotlib and called `plt.ion()`, the 3 figures are created and opened, but only the first figure window is plotted into, and the execution is blocked until all 3 are closed (at which point presumably the plotting calls are made into the already-closed figures).  This reproduces it:

```
import os
import mne

sample_data_folder = mne.datasets.sample.data_path()
sample_data_ave_file = os.path.join(sample_data_folder, 'MEG', 'sample',
                                    'sample_audvis-ave.fif')
evokeds = mne.read_evokeds(sample_data_ave_file, baseline=[None, 0])
mne.viz.plot_compare_evokeds(evokeds)
```


Discussion:

Resolving patch:
diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py
--- a/mne/viz/evoked.py
+++ b/mne/viz/evoked.py
@@ -1918,20 +1918,20 @@ def plot_compare_evokeds(evokeds, picks=None, gfp=False, colors=None,
             axes = [axes]
         _validate_if_list_of_axes(axes, obligatory_len=len(ch_types))
     else:
-        axes = [plt.subplots(figsize=(8, 6))[1] for _ in range(len(ch_types))]
+        axes = (plt.subplots(figsize=(8, 6))[1] for _ in range(len(ch_types)))
 
     if len(ch_types) > 1:
         logger.info("Multiple channel types selected, returning one figure "
                     "per type.")
         figs = list()
-        for ii, t in enumerate(ch_types):
+        for t, ax in zip(ch_types, axes):
             picks_ = picks_by_types[t]
             title_ = "GFP, " + t if (title is None and gfp is True) else title
             figs.append(plot_compare_evokeds(
                 evokeds, picks=picks_, gfp=gfp, colors=colors,
                 linestyles=linestyles, styles=styles, vlines=vlines, ci=ci,
                 truncate_yaxis=truncate_yaxis, ylim=ylim, invert_y=invert_y,
-                axes=axes[ii], title=title_, show=show))
+                axes=ax, title=title_, show=show))
         return figs
 
     # From now on there is only 1 channel type


Test patch:
Repository: mne-tools/mne-python

Issue:
extra "misc" row in raw.plot(butterfly=True)
hey @stfnrpplngr, since you're working on butterfly mode, can you confirm this?

```py
import os
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
                                    'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file, preload=False, verbose=False)
raw.crop(10).load_data()
raw.pick_types(meg=False, eeg=True).plot(butterfly=True)
```
I'm seeing an extra row for "misc" channels even though I've done `pick_types`

cc #6210 


Discussion:
FWIW the epochs butterfly mode and raw butterfly mode use slightly different code paths, so this might not be trivial to fix in #6210 :(
OK, I'll self-assign then. @stfnrpplngr if you want to take it on before I get around to it, LMK.
Applying my changes in epochs.py to raw.py will probably solve the problem. I will do that after finishing the refactoring of epochs.py.

Resolving patch:
diff --git a/mne/viz/utils.py b/mne/viz/utils.py
--- a/mne/viz/utils.py
+++ b/mne/viz/utils.py
@@ -2147,15 +2147,20 @@ def _setup_butterfly(params):
             inds = params['inds']
             labels = [t for t in _DATA_CH_TYPES_SPLIT + ('eog', 'ecg')
                       if t in types] + ['misc']
-            ticks = np.arange(5, 5 * (len(labels) + 1), 5)
+            last_yval = 5 * (len(labels) + 1)
+            ticks = np.arange(5, last_yval, 5)
             offs = {l: t for (l, t) in zip(labels, ticks)}
-
             params['offsets'] = np.zeros(len(params['types']))
             for ind in inds:
                 params['offsets'][ind] = offs.get(params['types'][ind],
-                                                  5 * (len(labels)))
+                                                  last_yval - 5)
+            # in case there were no non-data channels, skip the final row
+            if (last_yval - 5) not in params['offsets']:
+                ticks = ticks[:-1]
+                labels = labels[:-1]
+                last_yval -= 5
             ax.set_yticks(ticks)
-            params['ax'].set_ylim(5 * (len(labels) + 1), 0)
+            params['ax'].set_ylim(last_yval, 0)
             ax.set_yticklabels(labels)
         else:
             if 'selections' not in params:


Test patch: