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

Issue:
Crop-Method-Documentation inconsistent across Raw/Epochs/Evokeds
#### Describe the problem
The documentation of the method "crop" for Raw/Epochs/Evokeds is inconsistent:
For all Types, crop modifies the object in-place **and** returns the modified instance.

**Raw:** In-Place-Modification is described in "Returns"
**Epochs:** In-Place-Modification is described in "Notes"
**Evokeds:** In-Place-Modification is **not** described


#### Describe your solution
Correction of the documentation

#### Additional context
If not too complicated, an "inplace"-argument would be helpful to avoid the additional "copy"-method



Discussion:
do you think you can give it a try to send the pull request with the fixes?

>

Yes, I'll try it on the weekend
> If not too complicated, an "inplace"-argument would be helpful to avoid the additional "copy"-method

I'd like that too but I don't think it's going to happen :) So please only try fixing the docstrings for now.
Thanks!
Ok

Resolving patch:
diff --git a/mne/epochs.py b/mne/epochs.py
--- a/mne/epochs.py
+++ b/mne/epochs.py
@@ -1505,14 +1505,11 @@ def crop(self, tmin=None, tmax=None, include_tmax=True):
         Returns
         -------
         epochs : instance of Epochs
-            The cropped epochs.
+            The cropped epochs object, modified in-place.
 
         Notes
         -----
-        Unlike Python slices, MNE time intervals include both their end points;
-        crop(tmin, tmax) returns the interval tmin <= t <= tmax.
-
-        Note that the object is modified in place.
+        %(notes_tmax_included_by_default)s
         """
         # XXX this could be made to work on non-preloaded data...
         _check_preload(self, 'Modifying data of epochs')
diff --git a/mne/evoked.py b/mne/evoked.py
--- a/mne/evoked.py
+++ b/mne/evoked.py
@@ -220,12 +220,11 @@ def crop(self, tmin=None, tmax=None, include_tmax=True):
         Returns
         -------
         evoked : instance of Evoked
-            The cropped Evoked object.
+            The cropped Evoked object, modified in-place.
 
         Notes
         -----
-        Unlike Python slices, MNE time intervals include both their end points;
-        crop(tmin, tmax) returns the interval tmin <= t <= tmax.
+        %(notes_tmax_included_by_default)s
         """
         mask = _time_mask(self.times, tmin, tmax, sfreq=self.info['sfreq'],
                           include_tmax=include_tmax)
diff --git a/mne/utils/docs.py b/mne/utils/docs.py
--- a/mne/utils/docs.py
+++ b/mne/utils/docs.py
@@ -57,6 +57,12 @@
 
     .. versionadded:: 0.19
 """
+docdict['notes_tmax_included_by_default'] = """
+Unlike Python slices, MNE time intervals by default include **both**
+their end points; ``crop(tmin, tmax)`` returns the interval
+``tmin <= t <= tmax``. Pass ``include_tmax=False`` to specify the half-open
+interval ``tmin <= t < tmax`` instead.
+"""
 docdict['raw_tmin'] = """
 tmin : float
     Start time of the raw data to use in seconds (must be >= 0).


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

Issue:
BUG: PyVista backend doesn't properly show axes in plot_alignment
```
import mne
fname = mne.datasets.sample.data_path() + '/MEG/sample/sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(fname)
with mne.viz.use_3d_backend('pyvista'):
    mne.viz.plot_alignment(raw.info, show_axes=True, eeg=False, surfaces=[])
```
Produces:

![Screenshot from 2020-08-11 11-28-25](https://user-images.githubusercontent.com/2365790/89916733-f8f3f800-dbc5-11ea-9b72-d5ece4e58fa2.png)

The axes arrows are wrong, it should look like they do for the `mayavi` backend:

![Screenshot from 2020-08-11 11-28-37](https://user-images.githubusercontent.com/2365790/89916782-08734100-dbc6-11ea-9a3d-72bc06e4eef1.png)

@GuillaumeFavelier can you look?



Discussion:
I'll take care of it :+1:

Resolving patch:
diff --git a/mne/viz/backends/_pyvista.py b/mne/viz/backends/_pyvista.py
--- a/mne/viz/backends/_pyvista.py
+++ b/mne/viz/backends/_pyvista.py
@@ -429,11 +429,16 @@ def quiver3d(self, x, y, z, u, v, w, color, scale, mode, resolution=8,
             if mode == '2darrow':
                 return _arrow_glyph(grid, factor)
             elif mode == 'arrow' or mode == '3darrow':
+                mesh = _glyph(
+                    grid,
+                    orient='vec',
+                    scalars=scale,
+                    factor=factor
+                )
+                mesh = pyvista.wrap(mesh)
                 _add_mesh(
                     self.plotter,
-                    mesh=grid.glyph(orient='vec',
-                                    scale=scale,
-                                    factor=factor),
+                    mesh=mesh,
                     color=color,
                     opacity=opacity,
                     backface_culling=backface_culling


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

Issue:
Possible bug in _pick_data_or_ica
While setting `meg=True` in calls to `mne.pick_types` in calls that didn't explicitly specify this argument (#7823), I noticed that the internal function `_pick_data_or_ica` probably doesn't do the right thing.

Previously, the function picked:

```python
picks = pick_types(info, exclude=exclude, misc=True)
```

Since `meg=True` by default, I changed this to:

```python
picks = pick_types(info, meg=True, exclude=exclude, misc=True)
```

But this function is supposed to pick ICA channels (I think), and these should be of type `'misc'` (another assumption I'm not sure of). But if this is true, `meg` should be set to `False`.


Discussion:
This looks like it should be `meg=False`. @cbrnr can you try making this change and see if it breaks any existing test?
Will do!

Resolving patch:
diff --git a/mne/io/pick.py b/mne/io/pick.py
--- a/mne/io/pick.py
+++ b/mne/io/pick.py
@@ -960,8 +960,7 @@ def _pick_aux_channels(info, exclude='bads'):
 def _pick_data_or_ica(info, exclude=()):
     """Pick only data or ICA channels."""
     if any(ch_name.startswith('ICA') for ch_name in info['ch_names']):
-        # FIXME: is meg=True really correct here?
-        picks = pick_types(info, exclude=exclude, misc=True, meg=True)
+        picks = pick_types(info, exclude=exclude, misc=True)
     else:
         picks = _pick_data_channels(info, exclude=exclude, with_ref_meg=True)
     return picks


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

Issue:
DOC: add to glossary: whitening
#### Suggested term
whitening


#### Suggested definition
a linear operation that transforms data with a known covariance structure into "whitened data" which has a covariance structure that is the identity matrix (i.e., it creates virtual channels that are uncorrelated and have unit variance).



Discussion:
Sounds good, PR welcome
@drammock it's probably worth incorporating some logic here: https://github.com/scipy/scipy/issues/12446

Resolving patch:
diff --git a/mne/preprocessing/ica.py b/mne/preprocessing/ica.py
--- a/mne/preprocessing/ica.py
+++ b/mne/preprocessing/ica.py
@@ -438,7 +438,7 @@ def fit(self, inst, picks=None, start=None, stop=None, decim=None,
 
         Parameters
         ----------
-        inst : instance of Raw, Epochs or Evoked
+        inst : instance of Raw or Epochs
             Raw measurements to be decomposed.
         %(picks_good_data_noref)s
             This selection remains throughout the initialized ICA solution.
diff --git a/tutorials/evoked/plot_whitened.py b/tutorials/evoked/plot_whitened.py
--- a/tutorials/evoked/plot_whitened.py
+++ b/tutorials/evoked/plot_whitened.py
@@ -2,7 +2,8 @@
 Plotting whitened data
 ======================
 
-This tutorial demonstrates how to plot whitened evoked data.
+This tutorial demonstrates how to plot :term:`whitened <whitening>` evoked
+data.
 
 Data are whitened for many processes, including dipole fitting, source
 localization and some decoding algorithms. Viewing whitened data thus gives


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

Issue:
wrong reference to src in _prepare_label_extraction

#### Describe the bug
Using _prepare_label_extraction with stc=None produces error 

~/MEG/MNE-Python-Devel/mne-python/mne/source_estimate.py in _prepare_label_extraction(stc, labels, src, mode, allow_empty, use_sparse)
   2955                                  % (n_missing, len(v), hemi))
   2956     else:
-> 2957         vertno = src['vertno']
   2958 
   2959     nvert = [len(vn) for vn in vertno]

~/MEG/MNE-Python-Devel/mne-python/mne/source_space.py in __getitem__(self, *args, **kwargs)
    253     def __getitem__(self, *args, **kwargs):
    254         """Get an item."""
--> 255         out = super().__getitem__(*args, **kwargs)
    256         if isinstance(out, list):
    257             out = SourceSpaces(out)

TypeError: list indices must be integers or slices, not str

Solution:
Line 2957 should be

vertno = [s['vertno'] for s in src]




Discussion:

Resolving patch:
diff --git a/mne/source_estimate.py b/mne/source_estimate.py
--- a/mne/source_estimate.py
+++ b/mne/source_estimate.py
@@ -2954,7 +2954,7 @@ def _prepare_label_extraction(stc, labels, src, mode, allow_empty, use_sparse):
                                  'from the source space, likely mismatch'
                                  % (n_missing, len(v), hemi))
     else:
-        vertno = src['vertno']
+        vertno = [s['vertno'] for s in src]
 
     nvert = [len(vn) for vn in vertno]
 


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

Issue:
ENH: Improve our sourcerank score
See some entries missing in

https://libraries.io/pypi/mne/sourcerank

compared to 

https://libraries.io/pypi/nibabel/sourcerank

For 0.21 we should fix the easy missing ones. Something trivial for someone to do as a Sunday hack...


Discussion:
How does one even fix such things?  When I'm logged in, I don't see any "add" or "edit" links...  MNE-Python master doesn't even seem to be on the site? but some random fork of MNE is: https://libraries.io/github/Sinaxist/mne-python
I poked around and "submitted a suggestion" to link it to `mne-tools/mne-python`
Closing as I guess this is "good enough" for now
I think I figured out why this is happening: our [PyPI json](https://pypi.org/pypi/mne/json) is missing the key `['project_urls']['Source']`.  Here is [an example](https://pypi.org/pypi/doit/json) of a project that has the key defined.  I figured this out from [this issue](https://github.com/librariesio/libraries.io/issues/2121), and I think the solution is to add [something like this](https://github.com/pydoit/doit/blob/d1a1b7b3abc7641d977d3b78b580d97aea4e27ea/setup.py#L56-L59) to our `setup.py`.  @larsoner WDYT?
Yes please add it @drammock . You can probably check by doing `python setup.py sdist bdist_wheel` then looking at the `dist/` directory, the JSON should be in there somewhere. Once it works we can merge to `master` and backport.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright (C) 2011-2019 Alexandre Gramfort
+# Copyright (C) 2011-2020 Alexandre Gramfort
 # <alexandre.gramfort@inria.fr>
 
 import os
@@ -72,6 +72,12 @@ def package_tree(pkgroot):
                        'Operating System :: MacOS',
                        'Programming Language :: Python :: 3',
                        ],
+          keywords='neuroscience neuroimaging MEG EEG ECoG fNIRS brain',
+          project_urls={
+              'Documentation': 'https://mne.tools/',
+              'Source': 'https://github.com/mne-tools/mne-python/',
+              'Tracker': 'https://github.com/mne-tools/mne-python/issues/',
+          },
           platforms='any',
           python_requires='>=3.6',
           install_requires=['numpy>=1.11.3', 'scipy>=0.17.1'],


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

Issue:
No Annotations descriptions displayed in introductory tutorial figure
The Annotations in the `plot_20_events_from_raw` tutorial don't have a description (or vertical line) in the raw plot in[ `master`](https://mne.tools/dev/auto_tutorials/intro/plot_20_events_from_raw.html#converting-between-events-arrays-and-annotations-objects), but displayed correctly in [0.21](https://mne.tools/dev/auto_tutorials/intro/plot_20_events_from_raw.html#converting-between-events-arrays-and-annotations-objects)

`master`:

![](https://mne.tools/dev/_images/sphx_glr_plot_20_events_from_raw_002.png)


0.21:

![](https://mne.tools/stable/_images/sphx_glr_plot_20_events_from_raw_002.png)


cc @drammock 



Discussion:

Resolving patch:
diff --git a/mne/viz/_figure.py b/mne/viz/_figure.py
--- a/mne/viz/_figure.py
+++ b/mne/viz/_figure.py
@@ -1114,7 +1114,8 @@ def _update_annotation_segments(self):
         if len(raw.annotations):
             for idx, annot in enumerate(raw.annotations):
                 annot_start = _sync_onset(raw, annot['onset'])
-                annot_end = annot_start + annot['duration']
+                annot_end = annot_start + max(annot['duration'],
+                                              1 / self.mne.info['sfreq'])
                 segments.append((annot_start, annot_end))
         self.mne.annotation_segments = np.array(segments)
 
diff --git a/tutorials/intro/plot_20_events_from_raw.py b/tutorials/intro/plot_20_events_from_raw.py
--- a/tutorials/intro/plot_20_events_from_raw.py
+++ b/tutorials/intro/plot_20_events_from_raw.py
@@ -17,8 +17,8 @@
 example of reading experimental events from a :term:`"STIM" channel <stim
 channel>`; here we'll discuss :term:`events` and :term:`annotations` more
 broadly, give more detailed information about reading from STIM channels, and
-give an example of reading events that are in a marker file or included in the
-data file as an embedded array. The tutorials :ref:`tut-event-arrays` and
+give an example of reading events that are in a marker file or included in
+the data file as an embedded array. The tutorials :ref:`tut-event-arrays` and
 :ref:`tut-annotate-raw` discuss how to plot, combine, load, save, and
 export :term:`events` and :class:`~mne.Annotations` (respectively), and the
 latter tutorial also covers interactive annotation of :class:`~mne.io.Raw`


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

Issue:
MRG: Better split file handling in Report.parse_folder()
Better split file handling in Reports: don't "report" on any splits but the first.

cc @agramfort, wdyt?


Discussion:
@agramfort can you check if this fixes your issue?
thx @hoechenberger 
This broke CircleCI:

https://app.circleci.com/pipelines/github/mne-tools/mne-python/4556/workflows/229c2f13-d8c1-460e-b964-682d94c01ea9/jobs/23290

Can you look @hoechenberger ?

Resolving patch:
diff --git a/mne/report.py b/mne/report.py
--- a/mne/report.py
+++ b/mne/report.py
@@ -1464,10 +1464,6 @@ class construction.
         for fname in fnames:
             if _endswith(fname, ('raw', 'sss', 'meg')):
                 inst = read_raw_fif(fname, allow_maxshield=True, preload=False)
-            elif _endswith(fname, ('epo',)):
-                inst = read_epochs(fname, preload=False)
-            elif _endswith(fname, ('ave',)):
-                inst = read_evokeds(fname, condition=0, allow_maxshield=True)
             else:
                 continue
 


Test patch:
diff --git a/mne/tests/test_report.py b/mne/tests/test_report.py
--- a/mne/tests/test_report.py
+++ b/mne/tests/test_report.py
@@ -496,6 +496,7 @@ def test_scraper(tmpdir):
     assert op.isfile(img_fname.replace('png', 'svg'))
 
 
+@testing.requires_testing_data
 @pytest.mark.parametrize('split_naming', ('neuromag', 'bids',))
 def test_split_files(tmpdir, split_naming):
     """Test that in the case of split files, we only parse the first."""
Repository: mne-tools/mne-python

Issue:
Support Python 3.9
Python 3.9 has been released. We need to ensure MNE works with it.

https://docs.python.org/3/whatsnew/3.9.html


Discussion:

Resolving patch:
diff --git a/mne/utils/config.py b/mne/utils/config.py
--- a/mne/utils/config.py
+++ b/mne/utils/config.py
@@ -562,7 +562,7 @@ def sys_info(fid=None, show_paths=False):
             elif mod_name in ('mayavi', 'vtk'):
                 has_3d = True
             if mod_name == 'vtk':
-                version = mod.VTK_VERSION
+                version = getattr(mod, 'VTK_VERSION', 'VTK_VERSION missing')
             elif mod_name == 'PyQt5':
                 version = _check_pyqt5_version()
             else:
diff --git a/mne/viz/backends/_pyvista.py b/mne/viz/backends/_pyvista.py
--- a/mne/viz/backends/_pyvista.py
+++ b/mne/viz/backends/_pyvista.py
@@ -37,7 +37,7 @@
         from pyvista import BackgroundPlotter
     from pyvista.utilities import try_callback
     from pyvista.plotting.plotting import _ALL_PLOTTERS
-VTK9 = LooseVersion(vtk.VTK_VERSION) >= LooseVersion('9.0')
+VTK9 = LooseVersion(getattr(vtk, 'VTK_VERSION', '9.0')) >= LooseVersion('9.0')
 
 
 _FIGURES = dict()


Test patch:
diff --git a/mne/preprocessing/tests/test_xdawn.py b/mne/preprocessing/tests/test_xdawn.py
--- a/mne/preprocessing/tests/test_xdawn.py
+++ b/mne/preprocessing/tests/test_xdawn.py
@@ -15,7 +15,7 @@
                  create_info, EpochsArray)
 from mne.decoding import Vectorizer
 from mne.io import read_raw_fif
-from mne.utils import requires_sklearn, check_version
+from mne.utils import requires_sklearn
 from mne.preprocessing.xdawn import Xdawn, _XdawnTransformer
 
 base_dir = op.join(op.dirname(__file__), '..', '..', 'io', 'tests', 'data')
@@ -193,12 +193,10 @@ def test_xdawn_regularization():
     xd.fit(epochs)
     xd = Xdawn(correct_overlap=False, reg='diagonal_fixed')
     xd.fit(epochs)
-    bad_eig = check_version('numpy', '1.16.5')  # some problem with newer NumPy
-    if bad_eig:
-        pytest.skip('Unknown MKL+Windows error fails for eig check')
-    xd = Xdawn(correct_overlap=False, reg=None)
-    with pytest.raises(ValueError, match='Could not compute eigenvalues'):
-        xd.fit(epochs)
+    # XXX in principle this should maybe raise an error due to deficiency?
+    # xd = Xdawn(correct_overlap=False, reg=None)
+    # with pytest.raises(ValueError, match='Could not compute eigenvalues'):
+    #     xd.fit(epochs)
 
 
 @requires_sklearn
Repository: mne-tools/mne-python

Issue:
viz.plot_sensors() only partially honors axes parameter
#### Describe the bug
I wanted to add sensor alignment plots via `Raw.plot_sensors()` to some subplots of a larger figure. While the sensors **are** getting plotted, I observe some very annoying side effects that imho qualify as bugs.

#### Steps to reproduce
```python
import matplotlib.pyplot as plt
import mne
from mne.datasets import sample

data_path = sample.data_path()
fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(fname)

fig, ax = plt.subplots(2, 2)

ax[0, 0].plot(range(10))
ax[0, 0].set_title('Title A')

ax[1, 0].plot(range(10))
ax[1, 0].set_title('Title B')

raw.plot_sensors(ch_type='mag', axes=ax[0, 1])
raw.plot_sensors(ch_type='grad', axes=ax[1, 1])
```

#### Expected results
All subplots should appear in their designated axes.

#### Actual results
![Figure_1](https://user-images.githubusercontent.com/2046265/83256519-d94a5780-a1b2-11ea-9cd2-06f8027d6d8a.png)

- First sensor plot doesn't have a title
- Second sensor plot's title appears as `suptitle` while it should be an axes title
- The entire figure appears to be truncated at the top, left, and bottom


#### Additional information
The behavior reminds me somewhat of #7595, which has been fixed by @drammock in #7706.

I'm using Matplotlibs Qt backend on macOS.


Discussion:
There also seems to be an issue with the "click on sensors" callback, which is linked across BOTH sensor subplots…


![](https://im4.ezgif.com/tmp/ezgif-4-c12087ae43c6.gif)

I would qualify this as a bug

>


Resolving patch:
diff --git a/mne/viz/utils.py b/mne/viz/utils.py
--- a/mne/viz/utils.py
+++ b/mne/viz/utils.py
@@ -964,6 +964,9 @@ def plot_sensors(info, kind='topomap', ch_type=None, title=None,
 
 def _onpick_sensor(event, fig, ax, pos, ch_names, show_names):
     """Pick a channel in plot_sensors."""
+    if event.mouseevent.inaxes != ax:
+        return
+
     if event.mouseevent.key == 'control' and fig.lasso is not None:
         for ind in event.ind:
             fig.lasso.select_one(ind)
@@ -1064,7 +1067,7 @@ def _plot_sensors(pos, info, picks, colors, bads, ch_names, title, show_names,
                          ch_names=ch_names, show_names=show_names)
         fig.canvas.mpl_connect('pick_event', picker)
 
-    fig.suptitle(title)
+    ax.set(title=title)
     closed = partial(_close_event, fig=fig)
     fig.canvas.mpl_connect('close_event', closed)
     plt_show(show, block=block)


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

Issue:
BUG: Big Sur compat
More of an FYI than anything else -- PyQt5 appears not to work on Big Sur. I've tried 5.12 and 5.15.1, and both basically hang as soon as you make a mayavi, PyVista, or matplotlib Qt5Agg window.

So those thinking about upgrading, don't do so if you want to be able to use Python. For matplotlib at least we can use the MacOSX backend in the meantime, but 3D plotting is now (hopefully temporarily) totally broken for people who have upgraded. :(

Or maybe I'm the only one with this issue. If someone else upgrades, feel free to try it out and let me know!


Discussion:
Closing because there isn't really anything for us to do. But we can keep any discussion about this here as things progress
Thanks for the heads up. I think this time I will upgrade as late as possible (this is the first time I haven't upgraded on day 1, and just like the new CPUs the macOS update doesn't really hype me).
`os.environ['QT_MAC_WANTS_LAYER'] = '1'` ([stackoverflow](https://stackoverflow.com/a/64856281/166700)) at least gets the GUIs to open, will do some more testing. 

Resolving patch:
diff --git a/mne/gui/_backend.py b/mne/gui/_backend.py
--- a/mne/gui/_backend.py
+++ b/mne/gui/_backend.py
@@ -4,6 +4,7 @@
 # License: BSD (3-clause)
 
 import os
+import sys
 
 from ..utils import warn, _check_pyqt5_version
 
@@ -35,6 +36,9 @@ def _check_backend():
     backend = _get_pyface_backend()
     if backend == 'qt4':
         _check_pyqt5_version()
+        # QT 5 macOS 11 compatibility:
+        if sys.platform == 'darwin' and 'QT_MAC_WANTS_LAYER' not in os.environ:
+            os.environ['QT_MAC_WANTS_LAYER'] = '1'
     else:
         msg = ("Using the currently selected Pyface backend %s is not "
                "recommended, and it might not work properly. We recommend "


Test patch: