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

Issue:
highpass filter from edf may be incorrect
io/edf.py line 103 reads

```
                info['highpass'] = float(np.min(highpass))
                warnings.warn('Channels contain different highpass filters. '
                              'Highest filter setting will be stored.')
```

which returns the lowest, not the highest filter setting. A few lines down it is correctly handled for the lowpass filter. 



Discussion:

Resolving patch:
diff --git a/mne/io/edf/edf.py b/mne/io/edf/edf.py
--- a/mne/io/edf/edf.py
+++ b/mne/io/edf/edf.py
@@ -439,7 +439,7 @@ def _get_edf_info(fname, stim_channel, annot, annotmap, eog, misc, preload):
         else:
             info['highpass'] = float(highpass[0])
     else:
-        info['highpass'] = float(np.min(highpass))
+        info['highpass'] = float(np.max(highpass))
         warn('Channels contain different highpass filters. Highest filter '
              'setting will be stored.')
 


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

Issue:
Epochs.next() docs don't match behavior
[Docstring says here](https://github.com/mne-tools/mne-python/blob/master/mne/epochs.py#L1423-L1424) that `Epochs.next()` returns an instance of `mne.epochs.Epochs`, but in fact it returns a `numpy.ndarray` (or a tuple of `ndarray, event_id` if `return_event_id=True`).  Personally I think the docs reflect how it _should_ work, but it's obviously easier to just change the docs to reflect what it _actually_ does.



Discussion:
indeed ... can you open a PR to fix the docstring?

Will do (tomorrow, it's rather late in utc-8).
On Apr 5, 2016 10:31 PM, "Alexandre Gramfort" notifications@github.com
wrote:

> indeed ... can you open a PR to fix the docstring?
> 
> —
> You are receiving this because you authored the thread.
> Reply to this email directly or view it on GitHub
> https://github.com/mne-tools/mne-python/issues/3099#issuecomment-206125756


Resolving patch:
diff --git a/mne/epochs.py b/mne/epochs.py
--- a/mne/epochs.py
+++ b/mne/epochs.py
@@ -583,7 +583,10 @@ def _detrend_offset_decim(self, epoch, verbose=None):
         return epoch
 
     def iter_evoked(self):
-        """Iterate over Evoked objects with nave=1
+        """Iterate over epochs as a sequence of Evoked objects
+
+        The Evoked objects yielded will each contain a single epoch (i.e., no
+        averaging is performed).
         """
         self._current = 0
 
@@ -1411,17 +1414,17 @@ def __iter__(self):
             yield x
 
     def next(self, return_event_id=False):
-        """To make iteration over epochs easy.
+        """Iterate over epoch data.
 
         Parameters
         ----------
         return_event_id : bool
-            If True, return both an epoch and and event_id.
+            If True, return both the epoch data and an event_id.
 
         Returns
         -------
-        epoch : instance of Epochs
-            The epoch.
+        epoch : array of shape (n_channels, n_times)
+            The epoch data.
         event_id : int
             The event id. Only returned if ``return_event_id`` is ``True``.
         """


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

Issue:
pick_types allows non-bool args for e.g. EEG
I saw somebody doing this today:

`raw.pick_types(meg=False, eeg='grads')`

Which works (picking EEG channels).
Maybe a bit confusing, but not necessarily a bug ... Should we fix or keep?



Discussion:
People could also do `pick_types(eeg=0)` which would evaluate the same way as False, and `pick_types(eeg=1)` which would eval as `True`, which I'm okay with. I guess we could strictly type check to be safe, though.

well I guess it's hard to catch all possible bugs but for such a common
function might we can make an effort to type check

I can make a PR with something like

```
params = eeg, stim, ...
for param in params:
    if not isinstance(param, bool):
        raise ValueError(param + " must be of type ``bool``!")
```

yes but say also what is the type provided.

We have `ref_meg='auto'` as a default. I'm still unclear about what it means.


Resolving patch:
diff --git a/mne/decoding/transformer.py b/mne/decoding/transformer.py
--- a/mne/decoding/transformer.py
+++ b/mne/decoding/transformer.py
@@ -71,8 +71,8 @@ def fit(self, epochs_data, y):
                                        exclude='bads')
         picks_list['grad'] = pick_types(self.info, meg='grad', ref_meg=False,
                                         exclude='bads')
-        picks_list['eeg'] = pick_types(self.info, eeg='grad', ref_meg=False,
-                                       exclude='bads')
+        picks_list['eeg'] = pick_types(self.info, eeg=True, ref_meg=False,
+                                       meg=False, exclude='bads')
 
         self.picks_list_ = picks_list
 
diff --git a/mne/io/pick.py b/mne/io/pick.py
--- a/mne/io/pick.py
+++ b/mne/io/pick.py
@@ -264,6 +264,13 @@ def pick_types(info, meg=True, eeg=False, stim=False, eog=False, ecg=False,
         ref_meg = ('comps' in info and info['comps'] is not None and
                    len(info['comps']) > 0)
 
+    for param in (eeg, stim, eog, ecg, emg, misc, resp, chpi, exci,
+                  ias, syst, seeg, dipole, gof, bio):
+        if not isinstance(param, bool):
+            w = ('Parameters for all channel types (with the exception '
+                 'of "meg" and "ref_meg") must be of type bool, not {}.')
+            raise ValueError(w.format(type(param)))
+
     for k in range(nchan):
         kind = info['chs'][k]['kind']
         # XXX eventually we should de-duplicate this with channel_type!


Test patch:
diff --git a/mne/io/tests/test_pick.py b/mne/io/tests/test_pick.py
--- a/mne/io/tests/test_pick.py
+++ b/mne/io/tests/test_pick.py
@@ -226,6 +226,9 @@ def test_picks_by_channels():
     assert_equal(len(pick_list), len(pick_list2))
     assert_equal(pick_list2[0][0], 'mag')
 
+    # pick_types type check
+    assert_raises(ValueError, raw.pick_types, eeg='string')
+
 
 def test_clean_info_bads():
     """Test cleaning info['bads'] when bad_channels are excluded """
Repository: mne-tools/mne-python

Issue:
Memory consumption in plot_brainstorm_phantom_elekta
Circle is failing because it's using so much memory.



Discussion:

Resolving patch:
diff --git a/tutorials/plot_brainstorm_phantom_elekta.py b/tutorials/plot_brainstorm_phantom_elekta.py
--- a/tutorials/plot_brainstorm_phantom_elekta.py
+++ b/tutorials/plot_brainstorm_phantom_elekta.py
@@ -38,7 +38,7 @@
 data_path = bst_phantom_elekta.data_path()
 
 raw_fname = op.join(data_path, 'kojak_all_200nAm_pp_no_chpi_no_ms_raw.fif')
-raw = read_raw_fif(raw_fname, preload=True)
+raw = read_raw_fif(raw_fname)
 
 ###############################################################################
 # Data channel array consisted of 204 MEG planor gradiometers,
@@ -51,39 +51,41 @@
 
 ###############################################################################
 # The data have strong line frequency (60 Hz and harmonics) and cHPI coil
-# noise (five peaks around 300 Hz):
+# noise (five peaks around 300 Hz). Here we plot only out to 60 seconds
+# to save memory:
 
-raw.plot_psd()
+raw.plot_psd(tmax=60.)
 
 ###############################################################################
-# We know our phantom produces sinusoidal bursts below 25 Hz, so let's filter.
-
-raw.filter(None, 40., h_trans_bandwidth=10., filter_length='1s')
-raw.plot_psd()
-
-###############################################################################
-# The data are still a bit noisy, so let's use Maxwell filtering to clean it.
+# Let's use Maxwell filtering to clean the data a bit.
 # Ideally we would have the fine calibration and cross-talk information
 # for the site of interest, but we don't, so we just do:
 
 raw.fix_mag_coil_types()
 raw = mne.preprocessing.maxwell_filter(raw, origin=(0., 0., 0.))
+
+###############################################################################
+# We know our phantom produces sinusoidal bursts below 25 Hz, so let's filter.
+
+raw.filter(None, 40., h_trans_bandwidth=10., filter_length='1s')
 raw.plot(events=events)
 
 ###############################################################################
 # Now we epoch our data, average it, and look at the first dipole response.
-# The first peak appears around 3 ms.
+# The first peak appears around 3 ms. Because we low-passed at 40 Hz,
+# we can also decimate our data to save memory.
 
-tmin, tmax = -0.2, 0.2
+tmin, tmax = -0.1, 0.1
 event_id = list(range(1, 33))
-epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, -0.01))
+epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, -0.01),
+                    decim=5)
 epochs['1'].average().plot()
 
 ###############################################################################
 # Let's do some dipole fits. The phantom is properly modeled by a single-shell
 # sphere with origin (0., 0., 0.). We compute covariance, then do the fits.
 
-t_peak = 0.061  # 3 MS at largest peak
+t_peak = 60e-3  # ~60 MS at largest peak
 sphere = mne.make_sphere_model(r0=(0., 0., 0.), head_radius=None)
 cov = mne.compute_covariance(epochs, tmax=0)
 data = []


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

Issue:
Sklearn warnings for RandomizedPCA
In running the `plot_artifacts_correction_ica.py` tutorial with latest `sklearn`:

```
DeprecationWarning: Class RandomizedPCA is deprecated; RandomizedPCA will
be removed in 0.20. Use PCA(svd_solver='randomized') instead. The new implementation
DOES NOT store whiten components_. Apply transform to get them.
```

Any volunteer to fix it?



Discussion:
maybe for @kaichogami ?

Yes I will work on it.


Resolving patch:
diff --git a/mne/preprocessing/ica.py b/mne/preprocessing/ica.py
--- a/mne/preprocessing/ica.py
+++ b/mne/preprocessing/ica.py
@@ -498,13 +498,19 @@ def _pre_whiten(self, data, info, picks):
 
     def _fit(self, data, max_pca_components, fit_type):
         """Aux function """
-        from sklearn.decomposition import RandomizedPCA
 
         random_state = check_random_state(self.random_state)
 
-        # XXX fix copy==True later. Bug in sklearn, see PR #2273
-        pca = RandomizedPCA(n_components=max_pca_components, whiten=True,
-                            copy=True, random_state=random_state)
+        if not check_version('sklearn', '0.18'):
+            from sklearn.decomposition import RandomizedPCA
+            # XXX fix copy==True later. Bug in sklearn, see PR #2273
+            pca = RandomizedPCA(n_components=max_pca_components, whiten=True,
+                                copy=True, random_state=random_state)
+
+        else:
+            from sklearn.decomposition import PCA
+            pca = PCA(n_components=max_pca_components, copy=True, whiten=True,
+                      svd_solver='randomized', random_state=random_state)
 
         if isinstance(self.n_components, float):
             # compute full feature variance before doing PCA
@@ -539,9 +545,12 @@ def _fit(self, data, max_pca_components, fit_type):
         # the things to store for PCA
         self.pca_mean_ = pca.mean_
         self.pca_components_ = pca.components_
-        # unwhiten pca components and put scaling in unmixintg matrix later.
         self.pca_explained_variance_ = exp_var = pca.explained_variance_
-        self.pca_components_ *= np.sqrt(exp_var[:, None])
+        if not check_version('sklearn', '0.18'):
+            # unwhiten pca components and put scaling in unmixing matrix later.
+            # RandomizedPCA applies the whitening to the components
+            # but not the new PCA class.
+            self.pca_components_ *= np.sqrt(exp_var[:, None])
         del pca
         # update number of components
         self.n_components_ = sel.stop


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

Issue:
ica.plot_overlay - red and black lines are now mixed
[`plot_overlay` mixes red and black lines](http://www.martinos.org/mne/dev/_images/sphx_glr_plot_artifacts_correction_ica_010.png) because `mne.viz.evoked._plot_evoked` uses `z_order` param now and the default 'unsorted' value gives different z-order to each line. When two evokeds are plotted successively (before ICA - red; after ICA - black) this causes the lines to mix.
Potential solutions:
- `_plot_evoked` could expose another z_order option ('no', 'none', same', 'flat'?) that does not set line z-order
- `_plot_evoked` 'unsorted' z_order could lead to not changing z-order at all
- `ica.plot_overlay` could use the option to pass a callable to z_order where the callable would just return `np.ones(n_channels)`

I think the first and second solutions are more general and thus better. 



Discussion:
In https://github.com/mne-tools/mne-python/blob/master/mne/viz/evoked.py#L348

`zorder=z+1 if spatial_colors else 1`

?

@jona-sassenhagen even better :)

PR welcome


Resolving patch:
diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py
--- a/mne/viz/evoked.py
+++ b/mne/viz/evoked.py
@@ -344,9 +344,10 @@ def _plot_evoked(evoked, picks, exclude, unit, show,
 
                     # plot channels
                     for ch_idx, z in enumerate(z_ord):
-                        line_list.append(ax.plot(times, D[ch_idx], picker=3.,
-                                                 zorder=1 + z,
-                                                 color=colors[ch_idx])[0])
+                        line_list.append(
+                            ax.plot(times, D[ch_idx], picker=3.,
+                                    zorder=z + 1 if spatial_colors else 1,
+                                    color=colors[ch_idx])[0])
 
                 if gfp:  # 'only' or boolean True
                     gfp_color = 3 * (0.,) if spatial_colors else (0., 1., 0.)


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

Issue:
BUG: Breakages in time_gen with latest numpy and sklearn
First one probably needs to be `np.maximum` instead of `np.max`:

```
  File "/home/larsoner/custombuilds/mne-python/mne/decoding/csp.py", line 604, in _ajd_pham
    tmp2 = (tmp * g12 - g21) / np.max(omega - 1, 1e-9)
  File "/home/larsoner/.local/lib/python2.7/site-packages/numpy-1.12.0.dev0+b91e8d8-py2.7-linux-x86_64.egg/numpy/core/fromnumeric.py", line 2249, in amax
    return amax(axis=axis, out=out, **kwargs)
  File "/home/larsoner/.local/lib/python2.7/site-packages/numpy-1.12.0.dev0+b91e8d8-py2.7-linux-x86_64.egg/numpy/core/_methods.py", line 26, in _amax
    return umr_maximum(a, axis, None, out, keepdims)
TypeError: 'float' object cannot be interpreted as an index
```

Second one must be due to sklearn change:

```
  File "/home/larsoner/custombuilds/mne-python/mne/decoding/base.py", line 670, in _set_cv
    cv = XFold(n_folds=cv)
TypeError: __init__() got an unexpected keyword argument 'n_folds'
```

@kingjr do you have time to look?



Discussion:
see https://github.com/mne-tools/mne-python/pull/3579

let's see if CIs are happy...

I actually just hit that error, if alex s fix doesn't pass I'll have a look. Locally changing n_folds to n_splits solved it; didn't touch the np.max however

Pretty sure the `np.max` is a bug, can you submit a separate fix?


Resolving patch:
diff --git a/mne/decoding/base.py b/mne/decoding/base.py
--- a/mne/decoding/base.py
+++ b/mne/decoding/base.py
@@ -667,7 +667,7 @@ def _set_cv(cv, estimator=None, X=None, y=None):
         from sklearn.model_selection import (check_cv, StratifiedKFold, KFold)
         if isinstance(cv, (int, np.int)):
             XFold = StratifiedKFold if est_is_classifier else KFold
-            cv = XFold(n_folds=cv)
+            cv = XFold(n_splits=cv)
         elif isinstance(cv, str):
             if not hasattr(models, cv):
                 raise ValueError('Unknown cross-validation')
diff --git a/mne/decoding/time_gen.py b/mne/decoding/time_gen.py
--- a/mne/decoding/time_gen.py
+++ b/mne/decoding/time_gen.py
@@ -881,7 +881,7 @@ class GeneralizationAcrossTime(_GeneralizationAcrossTime):
     cv : int | object
         If an integer is passed, it is the number of folds.
         Specific cross-validation objects can be passed, see
-        scikit-learn.model_selection module for the list of possible objects.
+        scikit-learn.cross_validation module for the list of possible objects.
         If clf is a classifier, defaults to StratifiedKFold(n_folds=5), else
         defaults to KFold(n_folds=5).
     clf : object | None
@@ -1208,7 +1208,7 @@ class TimeDecoding(_GeneralizationAcrossTime):
     cv : int | object
         If an integer is passed, it is the number of folds.
         Specific cross-validation objects can be passed, see
-        scikit-learn.model_selection module for the list of possible objects.
+        scikit-learn.cross_validation module for the list of possible objects.
         If clf is a classifier, defaults to StratifiedKFold(n_folds=5), else
         defaults to KFold(n_folds=5).
     clf : object | None


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

Issue:
MINOR ENH: Epochs.set_channel_types overly verbose
When using set_channel_types to change multiple channels, there are a lot of redundant messages that could be summed up in a list:

```
The unit for channel ICA 019 has changed from NA to V.
The unit for channel ICA 034 has changed from NA to V.
The unit for channel ICA 011 has changed from NA to V.
The unit for channel ICA 021 has changed from NA to V.
The unit for channel ICA 029 has changed from NA to V.
The unit for channel ICA 028 has changed from NA to V.
The unit for channel ICA 022 has changed from NA to V.
The unit for channel ICA 031 has changed from NA to V.
The unit for channel ICA 025 has changed from NA to V.
```

to

```
The unit for channel(s) ICA 019, 034, ... has changed from NA to V.
```



Discussion:
PR welcome


Resolving patch:
diff --git a/mne/channels/channels.py b/mne/channels/channels.py
--- a/mne/channels/channels.py
+++ b/mne/channels/channels.py
@@ -354,6 +354,7 @@ def set_channel_types(self, mapping):
         ch_names = self.info['ch_names']
 
         # first check and assemble clean mappings of index and name
+        unit_changes = dict()
         for ch_name, ch_type in mapping.items():
             if ch_name not in ch_names:
                 raise ValueError("This channel name (%s) doesn't exist in "
@@ -375,8 +376,10 @@ def set_channel_types(self, mapping):
                                  "fix the measurement info of your data."
                                  % (ch_name, unit_old))
             if unit_old != _human2unit[ch_type]:
-                warn("The unit for channel %s has changed from %s to %s."
-                     % (ch_name, _unit2human[unit_old], _unit2human[unit_new]))
+                this_change = (_unit2human[unit_old], _unit2human[unit_new])
+                if this_change not in unit_changes:
+                    unit_changes[this_change] = list()
+                unit_changes[this_change].append(ch_name)
             self.info['chs'][c_ind]['unit'] = _human2unit[ch_type]
             if ch_type in ['eeg', 'seeg', 'ecog']:
                 coil_type = FIFF.FIFFV_COIL_EEG
@@ -387,6 +390,9 @@ def set_channel_types(self, mapping):
             else:
                 coil_type = FIFF.FIFFV_COIL_NONE
             self.info['chs'][c_ind]['coil_type'] = coil_type
+        msg = "The unit for channel(s) {0} has changed from {1} to {2}."
+        for this_change, names in unit_changes.items():
+            warn(msg.format(", ".join(sorted(names)), *this_change))
 
     def rename_channels(self, mapping):
         """Rename channels.


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

Issue:
BUG: mne.viz.plot_compare_evokeds overwrites style dicts
plot_compare_evokeds will currently internally overwrite provided `colors` and `linestyles` dicts, instead of working on a copy.
This means, for example, that you have to re-set the style dicts if you're plotting two different contrasts.

I'll take care of it ASAP.



Discussion:
I'm so lazy.


Resolving patch:
diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py
--- a/mne/viz/evoked.py
+++ b/mne/viz/evoked.py
@@ -11,6 +11,7 @@
 # License: Simplified BSD
 
 from functools import partial
+from copy import deepcopy
 
 import numpy as np
 
@@ -1500,7 +1501,12 @@ def plot_compare_evokeds(evokeds, picks=list(), gfp=False, colors=None,
     # are pulled from the 'colors' and 'linestyles' dicts via '/'-tag matching
     # unless they are overwritten by entries from a user-provided 'styles'.
 
-    # first, check if input is valid
+    # first, copy to avoid overwriting
+    styles = deepcopy(styles)
+    colors = deepcopy(colors)
+    linestyles = deepcopy(linestyles)
+
+    # second, check if input is valid
     if isinstance(styles, dict):
         for style_ in styles:
             if style_ not in conditions:
@@ -1528,14 +1534,14 @@ def plot_compare_evokeds(evokeds, picks=list(), gfp=False, colors=None,
     else:
         colors = _setup_styles(conditions, colors, "color", "grey")
 
-    # third, linestyles
+    # fourth, linestyles
     if not isinstance(linestyles, dict):
         linestyles = dict((condition, linestyle) for condition, linestyle in
                           zip(conditions, ['-'] * len(conditions)))
     else:
         linestyles = _setup_styles(conditions, linestyles, "linestyle", "-")
 
-    # fourth, put it all together
+    # fifth, put it all together
     if styles is None:
         styles = dict()
     for condition, color, linestyle in zip(conditions, colors, linestyles):


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

Issue:
ENH?: News / updates
It seems like we should have a little news/updates section of one-liners on the website, including things like:
1. Release notifications
2. Upcoming MNE-Python workshops
3. Upcoming coding sprints

If people agree I can put some old ones (last couple of release dates), and we can add to it as announcement-worthy things come up.



Discussion:
Sounds cool! I like this idea. 

+1 for also adding the old ones, typically useful when asking for
institutional support to show that we're serious

On 26 October 2016 at 16:16, Denis A. Engemann notifications@github.com
wrote:

> Sounds cool! I like this idea.
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> https://github.com/mne-tools/mne-python/issues/3703#issuecomment-256464112,
> or mute the thread
> https://github.com/notifications/unsubscribe-auth/AEp7DP9xxSOyEprXozviEzCf5P9wUob5ks5q37UYgaJpZM4Khnev
> .

+1


Resolving patch:
diff --git a/doc/sphinxext/cited_mne.py b/doc/sphinxext/cited_mne.py
--- a/doc/sphinxext/cited_mne.py
+++ b/doc/sphinxext/cited_mne.py
@@ -39,8 +39,8 @@
 # ##### Templates for citations #####
 html = (u""".. _cited
 
-Publications from MNE users
-===========================
+Publications by users
+=====================
 
 Papers citing MNE as extracted from Google Scholar (on %s).
 


Test patch: