Repository: mne-tools/mne-python

Issue:
Bug: plot_compare_evokeds, issue with Neuromag-122-data (rename_channels)
#### Describe the bug
When I try to do the mne.viz.plot_compare_evokeds() with data from our Neuromag122-MEG (only planar-gradiometers), the following Error-Message occurs:
ValueError: New channel names are not unique, renaming failed

The traceback goes to rename_channels which is called within combine_grads.
I assume, the problem is, that the naming of the channels is here very simple:
MEG 001, MEG 002, MEG 003, [...] MEG 122

In _combine_grad(1545), the last letter of the ch_name ist changed to 'X', which leads for this data to the same ch_names.

I didn't understand the purpose of the 'X', so I hope, you can help me with fixing this.
Below is a code snippet with some Neuromag-122-data.
Thank you!

#### Steps and/or code to reproduce
[Neuromag122_test.zip](https://github.com/mne-tools/mne-python/files/3195652/Neuromag122_test.zip)

import mne
from os.path import join

path_to_file = '<your_path_to_test_file>'
data_path = join(path_to_file, 'Neuromag122_test-ave.fif')

evokeds = mne.read_evokeds(data_path)
mne.viz.plot_compare_evokeds(evokeds)


Discussion:
I confirm the pb. Here is the test to use for the PR:

```
import os.path as op
import mne
from mne.io.constants import FIFF

base_dir = op.join(op.dirname(mne.__file__), 'io', 'tests', 'data')
evoked_fname = op.join(base_dir, 'test-ave.fif')


def test_plot_compare_evokeds_neuromag122():
    """Test topomap plotting."""
    evoked = mne.read_evokeds(evoked_fname, 'Left Auditory',
                              baseline=(None, 0))
    evoked.pick_types(meg='grad')
    evoked.pick_channels(evoked.ch_names[:122])
    ch_names = ['MEG %03d' % k for k in range(1, 123)]
    for c in evoked.info['chs']:
        c['coil_type'] = FIFF.FIFFV_COIL_NM_122
    evoked.rename_channels({c_old: c_new for (c_old, c_new) in
                            zip(evoked.ch_names, ch_names)})
    mne.viz.plot_compare_evokeds([evoked, evoked])


test_plot_compare_evokeds_neuromag122()
```
So the issue is about `_combine_grads`/`combine_evokeds`, correct? In which case I'd pass. If it's about `plot_compare_evokeds`, assign me ...
I looked at the issue and to me you should not have to combine_grads when you show line plots like `plot_compared_evokeds`. Looking in more details to the API logic the fact that the choice of picks overwrites the gfp parameter is nuts. Another weirdness is that `gfp=False` means average.... I don't know what's the best way forward but we should aim for:

```
mne.viz.plot_compare_evokeds([evoked1, evoked2], picks='meg')
mne.viz.plot_compare_evokeds([evoked1, evoked2], picks=None)
```

returning the same thing. And have something like:

```
mne.viz.plot_compare_evokeds([evoked1, evoked2], picks='meg', combine='mean')
mne.viz.plot_compare_evokeds([evoked1, evoked2], picks=None, combine='mean')
```

where combine follows the API of `plot_epochs_image` ?

any thoughts?

wdyt @jona-sassenhagen ?

Yes, I think it's a good idea to follow @drammock 's work on `plot_epochs_image` here.

I will not have the time to do this any time soon myself I fear.

Resolving patch:
diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py
--- a/mne/viz/evoked.py
+++ b/mne/viz/evoked.py
@@ -1542,7 +1542,8 @@ def pair_and_combine(data):
     this_data = pair_and_combine(evoked.data[picks, :])
     ch_names = ch_names[::2]
     evoked = evoked.copy().pick_channels(ch_names)
-    combined_ch_names = [ch_name[:-1] + "X" for ch_name in ch_names]
+    combined_ch_names = [ch_name[:-3] + "%03dX" % (k + 1)
+                         for k, ch_name in enumerate(ch_names)]
     evoked.rename_channels({c_old: c_new for c_old, c_new
                             in zip(evoked.ch_names, combined_ch_names)})
     evoked.data = this_data
@@ -1771,7 +1772,7 @@ def _evoked_condition_legend(conditions, show_legend, split_legend, cmap,
 
 
 def _set_ylims_plot_compare_evokeds(ax, any_positive, any_negative, ymin, ymax,
-                                    truncate_yaxis,  truncate_xaxis, invert_y,
+                                    truncate_yaxis, truncate_xaxis, invert_y,
                                     vlines, tmin, tmax, unit,
                                     skip_axlabel=True):
     """Set ylims for an evoked plot. Helper for plot_compare_evokeds."""
@@ -1973,7 +1974,7 @@ def plot_compare_evokeds(evokeds, picks=None, gfp=False, colors=None,
         * If the selected channels are gradiometers, the signal from
           corresponding (gradiometer) pairs will be combined.
 
-    gfp : bool
+    gfp : bool | None
         If True, the channel type wise GFP is plotted.
         If None and `picks` is None or a (list of) channel type(s), this is set
         to True.


Test patch:
diff --git a/mne/viz/tests/test_evoked.py b/mne/viz/tests/test_evoked.py
--- a/mne/viz/tests/test_evoked.py
+++ b/mne/viz/tests/test_evoked.py
@@ -25,6 +25,7 @@
 from mne.viz.utils import _fake_click
 from mne.stats import _parametric_ci
 from mne.datasets import testing
+from mne.io.constants import FIFF
 
 base_dir = op.join(op.dirname(__file__), '..', '..', 'io', 'tests', 'data')
 evoked_fname = op.join(base_dir, 'test-ave.fif')
@@ -351,6 +352,20 @@ def test_plot_compare_evokeds():
     plt.close('all')
 
 
+def test_plot_compare_evokeds_neuromag122():
+    """Test topomap plotting."""
+    evoked = mne.read_evokeds(evoked_fname, 'Left Auditory',
+                              baseline=(None, 0))
+    evoked.pick_types(meg='grad')
+    evoked.pick_channels(evoked.ch_names[:122])
+    ch_names = ['MEG %03d' % k for k in range(1, 123)]
+    for c in evoked.info['chs']:
+        c['coil_type'] = FIFF.FIFFV_COIL_NM_122
+    evoked.rename_channels({c_old: c_new for (c_old, c_new) in
+                            zip(evoked.ch_names, ch_names)})
+    mne.viz.plot_compare_evokeds([evoked, evoked])
+
+
 @testing.requires_testing_data
 def test_plot_ctf():
     """Test plotting of CTF evoked."""