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

Issue:
[DOC] plot_trans meg_sensors='points' not supported
The documentation and exception that is raised for mne.viz.plot_trans needs to be updated to reflect that 'points' is not a supported input option for meg_sensors.

it seems to have been replaced with 'sensors'



Discussion:
Yeah that's my bad. Should be able to fix this week.


Resolving patch:
diff --git a/mne/viz/_3d.py b/mne/viz/_3d.py
--- a/mne/viz/_3d.py
+++ b/mne/viz/_3d.py
@@ -268,9 +268,9 @@ def _plot_mri_contours(mri_fname, surf_fnames, orientation='coronal',
 @verbose
 def plot_trans(info, trans='auto', subject=None, subjects_dir=None,
                ch_type=None, source=('bem', 'head'), coord_frame='head',
-               meg_sensors='helmet', eeg_sensors='original', dig=False,
-               ref_meg=False, ecog_sensors=True, head=None, brain=None,
-               verbose=None):
+               meg_sensors=('helmet', 'sensors'), eeg_sensors='original',
+               dig=False, ref_meg=False, ecog_sensors=True, head=None,
+               brain=None, verbose=None):
     """Plot head and sensor alignment in 3D.
 
     Parameters
@@ -297,10 +297,9 @@ def plot_trans(info, trans='auto', subject=None, subjects_dir=None,
     coord_frame : str
         Coordinate frame to use, 'head', 'meg', or 'mri'.
     meg_sensors : bool | str | list
-        Can be "helmet" or "points" to show MEG sensors as points or as part
-        of the the helmet, respectively, or a combination of the two like
-        ``['helmet', 'sensors']`` (equivalent to True, default) or ``[]``
-        (equivalent to False).
+        Can be "helmet" (equivalent to False) or "sensors" to show the MEG
+        helmet or sensors, respectively, or a combination of the two like
+        ``['helmet', 'sensors']`` (equivalent to True, default) or ``[]``.
     eeg_sensors : bool | str | list
         Can be "original" (default; equivalent to True) or "projected" to
         show EEG sensors in their digitized locations or projected onto the


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

Issue:
BUG/API: overwrite flag not passed in SourceEstimate.save with ftyp='h5' 
The title says it all.

cc @Eric89GXL 


Discussion:
Do you have time to make a PR?

Yes I guess so.

On Thu, Nov 17, 2016 at 9:24 PM Eric Larson notifications@github.com
wrote:

> Do you have time to make a PR?
> 
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> https://github.com/mne-tools/mne-python/issues/3774#issuecomment-261359113,
> or mute the thread
> https://github.com/notifications/unsubscribe-auth/AB0fig_tnVyGziM1cwQChKYaOa8vuGrxks5q_LfegaJpZM4K1wp8
> .


Resolving patch:
diff --git a/mne/source_estimate.py b/mne/source_estimate.py
--- a/mne/source_estimate.py
+++ b/mne/source_estimate.py
@@ -1020,7 +1020,8 @@ def save(self, fname, ftype='stc', verbose=None):
             write_hdf5(fname + '-stc.h5',
                        dict(vertices=self.vertices, data=self.data,
                             tmin=self.tmin, tstep=self.tstep,
-                            subject=self.subject), title='mnepython')
+                            subject=self.subject), title='mnepython',
+                            overwrite=True)
         logger.info('[done]')
 
     def __repr__(self):  # noqa: D105


Test patch:
diff --git a/mne/tests/test_source_estimate.py b/mne/tests/test_source_estimate.py
--- a/mne/tests/test_source_estimate.py
+++ b/mne/tests/test_source_estimate.py
@@ -201,6 +201,7 @@ def test_io_stc_h5():
     assert_raises(ValueError, stc.save, op.join(tempdir, 'tmp'), ftype='foo')
     out_name = op.join(tempdir, 'tmp')
     stc.save(out_name, ftype='h5')
+    stc.save(out_name, ftype='h5')  # test overwrite
     stc3 = read_source_estimate(out_name)
     stc4 = read_source_estimate(out_name + '-stc.h5')
     assert_raises(RuntimeError, read_source_estimate, out_name, subject='bar')
Repository: mne-tools/mne-python

Issue:
BUG: plot_brainstorm_auditory.py example broken
For some reason the bst_auditory `stc_difference` plot looks bad on [dev builds](https://3360-1301584-gh.circle-artifacts.com/0/home/ubuntu/mne-python/doc/_build/html/auto_tutorials/plot_brainstorm_auditory.html) compared to [stable](https://mne-tools.github.io/stable/auto_tutorials/plot_brainstorm_auditory.html).


Discussion:

Resolving patch:
diff --git a/mne/annotations.py b/mne/annotations.py
--- a/mne/annotations.py
+++ b/mne/annotations.py
@@ -82,7 +82,7 @@ def __init__(self, onset, duration, description,
 
         self.onset = onset
         self.duration = duration
-        self.description = np.array(description)
+        self.description = np.array(description, dtype=str)
 
 
 def _combine_annotations(annotations, last_samps, first_samps, sfreq):
diff --git a/tutorials/plot_brainstorm_auditory.py b/tutorials/plot_brainstorm_auditory.py
--- a/tutorials/plot_brainstorm_auditory.py
+++ b/tutorials/plot_brainstorm_auditory.py
@@ -126,7 +126,7 @@
 # Conversion from samples to times:
 onsets = annotations_df['onset'].values / raw.info['sfreq']
 durations = annotations_df['duration'].values / raw.info['sfreq']
-descriptions = map(str, annotations_df['label'].values)
+descriptions = annotations_df['label'].values
 
 annotations = mne.Annotations(onsets, durations, descriptions)
 raw.annotations = annotations
@@ -258,7 +258,8 @@
     notches = [60, 120, 180]
     for evoked in (evoked_std, evoked_dev):
         evoked.data[:] = notch_filter(evoked.data, sfreq, notches)
-        evoked.data[:] = filter_data(evoked_std.data, sfreq, None, 100)
+        evoked.data[:] = filter_data(evoked.data, sfreq, l_freq=None,
+                                     h_freq=100.)
 
 ###############################################################################
 # Here we plot the ERF of standard and deviant conditions. In both conditions
@@ -271,6 +272,7 @@
 evoked_std.plot(window_title='Standard', gfp=True)
 evoked_dev.plot(window_title='Deviant', gfp=True)
 
+
 ###############################################################################
 # Show activations as topography figures.
 times = np.arange(0.05, 0.301, 0.025)


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

Issue:
When using mne.viz.iter_topography, on_pick callback is called with pyplot instance instead of the axes
This is the line:

https://github.com/mne-tools/mne-python/blob/master/mne/viz/topo.py#L223

Shouldn't it be the axes? This would suggest so: http://martinos.org/mne/stable/auto_examples/visualization/plot_topo_customized.html

Thanks,
Tk


Discussion:
what fix do you suggest?

As even the docstring of the iter_topography says: 

"on_pick : callable | None
        The callback function to be invoked on clicking one
        of the axes. Is supposed to instantiate the following
        API: `function(axis, channel_index)`",

I would be as daring as replacing the line "show_func(plt, ch_idx)" with "show_func(ax, ch_idx)" and let people fix their code (they can always introduce pyplot themselves if they want minimal changes)..

-- Tk
+1 that sounds like a bug in our implementation

Are you up for making a PR?
I can do that, yes

-- Tk
thanks !


Resolving patch:
diff --git a/mne/viz/topo.py b/mne/viz/topo.py
--- a/mne/viz/topo.py
+++ b/mne/viz/topo.py
@@ -220,7 +220,7 @@ def _plot_topo_onpick(event, show_func):
         ax.set_axis_bgcolor(face_color)
 
         # allow custom function to override parameters
-        show_func(plt, ch_idx)
+        show_func(ax, ch_idx)
 
     except Exception as err:
         # matplotlib silently ignores exceptions in event handlers,
@@ -381,9 +381,9 @@ def _erfimage_imshow(ax, ch_idx, tmin, tmax, vmin, vmax, ylim=None, data=None,
     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,
-              interpolation='nearest')
+    img = ax.imshow(this_data, extent=[tmin, tmax, 0, len(data)],
+                    aspect='auto', origin='lower', vmin=vmin, vmax=vmax,
+                    picker=True, cmap=cmap, interpolation='nearest')
 
     ax = plt.gca()
     if x_label is not None:
@@ -391,7 +391,7 @@ def _erfimage_imshow(ax, ch_idx, tmin, tmax, vmin, vmax, ylim=None, data=None,
     if y_label is not None:
         ax.set_ylabel(y_label)
     if colorbar:
-        plt.colorbar()
+        plt.colorbar(mappable=img)
 
 
 def _erfimage_imshow_unified(bn, ch_idx, tmin, tmax, vmin, vmax, ylim=None,


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

Issue:
CNT files with event_type == 3
A friend has a recent CNT file that fails to be read in. The reader assumes `event_type` to be either 1 or 2, but here it is 3.

Minimally, I think we'd just have to go from
`elif event_type == 2:`
to
`elif event_type > 1:`

I can make a PR later.

@jaeilepp 


Discussion:
The best [documentation](http://paulbourke.net/dataformats/eeg/) I've been able to find says that it should be either 1 or 2.
```
typedef struct {
   char Teeg;                   /* Either 1 or 2                           */
   long Size;                   /* Total length of all the events          */
   long Offset;                 /* Hopefully always 0                      */
} TEEG;
```
Not sure what 3 means...
Also, it seems that there are a lot of cnt files that don't really conform to these definitions, so the reader maybe needs a revision anyway, but it's hard to find good docs on this.


Resolving patch:
diff --git a/mne/io/cnt/cnt.py b/mne/io/cnt/cnt.py
--- a/mne/io/cnt/cnt.py
+++ b/mne/io/cnt/cnt.py
@@ -233,7 +233,7 @@ def _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format):
         event_size = np.fromfile(fid, dtype='<i4', count=1)[0]
         if event_type == 1:
             event_bytes = 8
-        elif event_type == 2:
+        elif event_type in (2, 3):
             event_bytes = 19
         else:
             raise IOError('Unexpected event size.')
@@ -245,8 +245,10 @@ def _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format):
             event_id = np.fromfile(fid, dtype='u2', count=1)[0]
             fid.seek(event_offset + 9 + i * event_bytes + 4)
             offset = np.fromfile(fid, dtype='<i4', count=1)[0]
-            event_time = (offset - 900 - 75 * n_channels) // (n_channels *
-                                                              n_bytes)
+            if event_type == 3:
+                offset *= n_bytes * n_channels
+            event_time = offset - 900 - 75 * n_channels
+            event_time //= n_channels * n_bytes
             stim_channel[event_time - 1] = event_id
 
     info = _empty_info(sfreq)


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

Issue:
concatenate_epochs should check event_id values correspondence
I've recently had a weird bug - concatenating two epochs led to assertion error in epoch constructor. After some debugging I found out that the cause of the problem was that the epochs did not have the same event_id values (the same key corresponded to different values in these files). [This line in `concatenate_epochs`](https://github.com/mne-tools/mne-python/blob/master/mne/epochs.py#L2708) assumes that same keys correspond to same values and uses `update` method dict method to join dicts. It would be better if concatenate_epochs checked if this is true and threw error otherwise.


Discussion:
+1

can you open a PR?

sure, will open today

Resolving patch:
diff --git a/mne/epochs.py b/mne/epochs.py
--- a/mne/epochs.py
+++ b/mne/epochs.py
@@ -2700,6 +2700,16 @@ def _concatenate_epochs(epochs_list, with_data=True):
         if epochs.baseline != baseline:
             raise ValueError('Baseline must be same for all epochs')
 
+        # compare event_id
+        common_keys = list(set(event_id).intersection(set(epochs.event_id)))
+        for key in common_keys:
+            if not event_id[key] == epochs.event_id[key]:
+                msg = ('event_id values must be the same for identical keys '
+                       'for all concatenated epochs. Key "{}" maps to {} in '
+                       'some epochs and to {} in others.')
+                raise ValueError(msg.format(key, event_id[key],
+                                            epochs.event_id[key]))
+
         if with_data:
             data.append(epochs.get_data())
         events.append(epochs.events)


Test patch:
diff --git a/mne/tests/test_epochs.py b/mne/tests/test_epochs.py
--- a/mne/tests/test_epochs.py
+++ b/mne/tests/test_epochs.py
@@ -2041,6 +2041,13 @@ def test_concatenate_epochs():
     epochs.info['dev_head_t'] = None
     concatenate_epochs([epochs, epochs2])  # should work
 
+    # check that different event_id does not work:
+    epochs1 = epochs.copy()
+    epochs2 = epochs.copy()
+    epochs1.event_id = dict(a=1)
+    epochs2.event_id = dict(a=2)
+    assert_raises(ValueError, concatenate_epochs, [epochs1, epochs2])
+
 
 def test_add_channels():
     """Test epoch splitting / re-appending channel types."""
Repository: mne-tools/mne-python

Issue:
Doc of mne.decoding.Scaler.fit_transform() is not correct
`fit_transform()` accepts 3D epoch data, but when i run `help(fit_transform)` command in python then it gives-
````
scaler.fit_transform(X, y=None, **fit_params)
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params
and returns a transformed version of X.

Parameters
----------
X : numpy array of shape [n_samples, n_features]
    Training set.

y : numpy array of shape [n_samples]
    Target values.

Returns
-------
X_new : numpy array of shape [n_samples, n_features_new]
    Transformed array.
````
This comes from `fit_transform()` in `TransformerMixin` class.


Discussion:
does https://github.com/mne-tools/mne-python/pull/4025
fix your pb?

I'm still getting the same output. Reason for this I think is that Scaler
imports TransformerMixin and in this class fit_transform contain this
doc. We should redefine that function in Scaler class and update the doc.

Thanks

On Sun, Mar 12, 2017 at 6:59 PM, Alexandre Gramfort <
notifications@github.com> wrote:

> does https://github.com/mne-tools/mne-python/pull/4025
> fix your pb?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/mne-tools/mne-python/issues/4055#issuecomment-285944609>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ANfGMMqcKwGZlNMoAOARaSjxQU0jw8qWks5rk_M6gaJpZM4Mahta>
> .
>

can you open a PR?

OK, I can do it.

Resolving patch:
diff --git a/mne/decoding/transformer.py b/mne/decoding/transformer.py
--- a/mne/decoding/transformer.py
+++ b/mne/decoding/transformer.py
@@ -172,6 +172,32 @@ def transform(self, epochs_data, y=None):
         return _sklearn_reshape_apply(self._scaler.transform, True,
                                       epochs_data, y)
 
+    def fit_transform(self, epochs_data, y=None):
+        """Fit to data, then transform it.
+
+        Fits transformer to epochs_data and y and returns a transformed version
+        of epochs_data.
+
+        Parameters
+        ----------
+        epochs_data : array, shape (n_epochs, n_channels, n_times)
+            The data.
+        y : None | array, shape (n_epochs,)
+            The label for each epoch.
+            Defaults to None.
+
+        Returns
+        -------
+        X : array, shape (n_epochs, n_channels, n_times)
+            The data concatenated over channels.
+
+        Notes
+        -----
+        This function makes a copy of the data before the operations and the
+        memory usage may be large with big data.
+        """
+        return self.fit(epochs_data, y).transform(epochs_data)
+
     def inverse_transform(self, epochs_data):
         """Invert standardization of data across channels.
 


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

Issue:
Evoked comparison figure changes default pyplot style params 
Buggy behavior in `mne.viz.plot_compare_evokeds` that botches some/all default matplotlib rc params. Both with my own data as well as [tutorial] gist(http://martinos.org/mne/stable/auto_tutorials/plot_visualize_evoked.html#sphx-glr-auto-tutorials-plot-visualize-evoked-py) I get arbitrarily colored axes background that I can't control.
```
import os.path as op
import numpy as np
import matplotlib.pyplot as plt

import mne

data_path = mne.datasets.sample.data_path()
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
evoked = mne.read_evokeds(fname, baseline=(None, 0), proj=True)
conditions = ["Left Auditory", "Right Auditory", "Left visual", "Right visual"]
evoked_dict = dict()
for condition in conditions:
    evoked_dict[condition.replace(" ", "/")] = mne.read_evokeds(
        fname, baseline=(None, 0), proj=True, condition=condition)
print(evoked_dict)

colors = dict(Left="Crimson", Right="CornFlowerBlue")
linestyles = dict(Auditory='-', visual='--')
pick = evoked_dict["Left/Auditory"].ch_names.index('MEG 1811')

mne.viz.plot_compare_evokeds(evoked_dict, picks=pick,
                             colors=colors, linestyles=linestyles) 
```
Returns

<img width="619" alt="screen shot 2017-03-24 at 2 02 25 pm" src="https://cloud.githubusercontent.com/assets/4381290/24313584/9eda74ec-109a-11e7-8d98-7e61947f2366.png">

cc @jona-sassenhagen 


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
@@ -1715,7 +1715,6 @@ def plot_compare_evokeds(evokeds, picks=list(), gfp=False, colors=None,
     # finishing touches
     if invert_y:
         axes.invert_yaxis()
-    axes.patch.set_alpha(0)
     axes.spines['right'].set_color('none')
     axes.set_xlim(tmin, tmax)
 


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

Issue:
WIP: example docstring to extract matrix of fwd operator
@Eric89GXL and I discussed how to extract the numpy array containing the forward operator and he suggested I add in an example docstring. This PR does that in the docstring for `apply_forward`.


Discussion:
please put it there

http://martinos.org/mne/dev/auto_tutorials/plot_forward.html

thx


Resolving patch:
diff --git a/tutorials/plot_forward.py b/tutorials/plot_forward.py
--- a/tutorials/plot_forward.py
+++ b/tutorials/plot_forward.py
@@ -94,8 +94,7 @@
 # and spacing parameter.
 
 src = mne.setup_source_space(subject, spacing='oct6',
-                             subjects_dir=subjects_dir,
-                             add_dist=False, overwrite=True)
+                             subjects_dir=subjects_dir, add_dist=False)
 print(src)
 
 ###############################################################################
@@ -154,8 +153,7 @@
 # See :func:`mne.make_forward_solution` for details on parameters meaning.
 
 fwd = mne.make_forward_solution(raw_fname, trans=trans, src=src, bem=bem,
-                                fname=None, meg=True, eeg=False,
-                                mindist=5.0, n_jobs=2)
+                                meg=True, eeg=False, mindist=5.0, n_jobs=2)
 print(fwd)
 
 ###############################################################################
@@ -165,6 +163,24 @@
 leadfield = fwd['sol']['data']
 print("Leadfield size : %d sensors x %d dipoles" % leadfield.shape)
 
+###############################################################################
+# To extract the numpy array containing the forward operator corresponding to
+# the source space `fwd['src']` with cortical orientation constraint
+# we can use the following:
+
+fwd_fixed = mne.convert_forward_solution(fwd, surf_ori=True,
+                                         force_fixed=True)
+leadfield = fwd_fixed['sol']['data']
+print("Leadfield size : %d sensors x %d dipoles" % leadfield.shape)
+
+###############################################################################
+# This is equivalent to the following code that explicitly applies the
+# forward operator to a source estimate composed of the identity operator:
+n_dipoles = leadfield.shape[1]
+vertices = [src_hemi['vertno'] for src_hemi in fwd_fixed['src']]
+stc = mne.SourceEstimate(1e-9 * np.eye(n_dipoles), vertices, tmin=0., tstep=1)
+leadfield = mne.apply_forward(fwd_fixed, stc, info).data / 1e-9
+
 ###############################################################################
 # To save to disk a forward solution you can use
 # :func:`mne.write_forward_solution` and to read it back from disk


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

Issue:
create_ecg_epochs crashes if data is not preloaded
I found this error when I ran create_ecg_epochs before create_eog_epochs. 

create_eog_epochs will preload the data when it creates the epochs, and then create_ecg_epochs will run fine. 
However, create_ecg_epochs will crash on data that is not preloaded, if run first. This happens when it tries to run the line `raw.add_channels([ecg_raw])` which needs the data to be preloaded.

You can easily recreate this error by running create_ecg_epochs on raw_fif data that has not been preloaded. I can create an example if need be, I can also create a pull request to fix this if you want me to. My solution to the problem would just be preloading the data though, not sure if that is too naive of an approach or not.


Discussion:
please open a PR.

thx


Resolving patch:
diff --git a/mne/preprocessing/ecg.py b/mne/preprocessing/ecg.py
--- a/mne/preprocessing/ecg.py
+++ b/mne/preprocessing/ecg.py
@@ -305,6 +305,9 @@ def create_ecg_epochs(raw, ch_name=None, event_id=999, picks=None, tmin=-0.5,
         raw, ch_name=ch_name, event_id=event_id, l_freq=l_freq, h_freq=h_freq,
         return_ecg=True, verbose=verbose)
 
+    # Load raw data so that add_channels works
+    raw.load_data()
+
     if not has_ecg:
         ecg_raw = RawArray(
             ecg[None],


Test patch:
diff --git a/mne/preprocessing/tests/test_ecg.py b/mne/preprocessing/tests/test_ecg.py
--- a/mne/preprocessing/tests/test_ecg.py
+++ b/mne/preprocessing/tests/test_ecg.py
@@ -16,7 +16,8 @@
 
 def test_find_ecg():
     """Test find ECG peaks."""
-    raw = read_raw_fif(raw_fname)
+    # Test if ECG analysis will work on data that is not preloaded
+    raw = read_raw_fif(raw_fname, preload=False)
 
     # once with mag-trick
     # once with characteristic channel
@@ -33,7 +34,10 @@ def test_find_ecg():
         eog=False, ecg=True, emg=False, ref_meg=False,
         exclude='bads')
 
-    raw.load_data()
+    # There should be no ECG channels, or else preloading will not be
+    # tested
+    assert_true('ecg' not in raw)
+
     ecg_epochs = create_ecg_epochs(raw, picks=picks, keep_ecg=True)
     assert_equal(len(ecg_epochs.events), n_events)
     assert_true('ECG-SYN' not in raw.ch_names)
@@ -55,4 +59,5 @@ def test_find_ecg():
     assert_true(len(w) == 1 and 'unit for channel' in str(w[0].message))
     create_ecg_epochs(raw)
 
+
 run_tests_if_main()