Repository: mne-tools/mne-python

Issue:
plot_compare_evokeds is missing the channel location plot
for a few workshop attendants.


Discussion:
Ok, the issue comes from https://github.com/mne-tools/mne-python/pull/5575

@jasmainak , do I understand correctly that `_check_ch_locs` returns  false if there are channel locations present, and true if there are none? That is a bit weird. 

If so, https://github.com/mne-tools/mne-python/blob/0ddc0e4175f99105b025d879cf832cf29f25c268/mne/viz/evoked.py#L2125 needs to be fixed I think.
Agreed I would assume a `_check` function would return `True`  for the "is usable" case

@jona-sassenhagen can you alter the logic and fix the issue?

Resolving patch:
diff --git a/mne/channels/layout.py b/mne/channels/layout.py
--- a/mne/channels/layout.py
+++ b/mne/channels/layout.py
@@ -656,7 +656,7 @@ def _auto_topomap_coords(info, picks, ignore_overlap=False, to_sphere=True):
     locs3d = np.array([ch['loc'][:3] for ch in chs])
 
     # If electrode locations are not available, use digization points
-    if _check_ch_locs(chs):
+    if not _check_ch_locs(chs):
         logging.warning('Did not find any electrode locations (in the info '
                         'object), will attempt to use digitization points '
                         'instead. However, if digitization points do not '
diff --git a/mne/utils.py b/mne/utils.py
--- a/mne/utils.py
+++ b/mne/utils.py
@@ -2388,8 +2388,9 @@ def _check_ch_locs(chs):
         The channels from info['chs']
     """
     locs3d = np.array([ch['loc'][:3] for ch in chs])
-    return (locs3d == 0).all() or \
-        (~np.isfinite(locs3d)).all() or np.allclose(locs3d, 0.)
+    return not ((locs3d == 0).all() or
+                (~np.isfinite(locs3d)).all() or
+                np.allclose(locs3d, 0.))
 
 
 def _clean_names(names, remove_whitespace=False, before_dash=True):
diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py
--- a/mne/viz/evoked.py
+++ b/mne/viz/evoked.py
@@ -415,7 +415,7 @@ def _plot_lines(data, info, picks, fig, axes, spatial_colors, unit, units,
             if not gfp_only:
                 chs = [info['chs'][i] for i in idx]
                 locs3d = np.array([ch['loc'][:3] for ch in chs])
-                if spatial_colors is True and _check_ch_locs(chs):
+                if spatial_colors is True and not _check_ch_locs(chs):
                     warn('Channel locations not available. Disabling spatial '
                          'colors.')
                     spatial_colors = selectable = False
@@ -2122,22 +2122,21 @@ def plot_compare_evokeds(evokeds, picks=None, gfp=False, colors=None,
     # and now for 3 "legends" ..
     # a head plot showing the sensors that are being plotted
     if show_sensors:
-        if not _check_ch_locs(one_evoked.info['chs']):
-            pos = _auto_topomap_coords(one_evoked.info, pos_picks,
-                                       ignore_overlap=True, to_sphere=True)
-        else:
+        _validate_type(show_sensors, (np.int, bool, str, type(None)),
+                       "show_sensors", "numeric, str, None or bool")
+        if not _check_ch_locs(np.array(one_evoked.info['chs'])[pos_picks]):
             warn("Cannot find channel coordinates in the supplied Evokeds. "
                  "Not showing channel locations.")
-
-        if show_sensors is True:
-            ymin, ymax = np.abs(ax.get_ylim())
-            show_sensors = "lower right" if ymin > ymax else "upper right"
         else:
+            if show_sensors is True:
+                ymin, ymax = np.abs(ax.get_ylim())
+                show_sensors = "lower right" if ymin > ymax else "upper right"
+
+            pos = _auto_topomap_coords(one_evoked.info, pos_picks,
+                                       ignore_overlap=True, to_sphere=True)
             head_pos = {'center': (0, 0), 'scale': (0.5, 0.5)}
             pos, outlines = _check_outlines(pos, np.array([1, 1]), head_pos)
 
-            _validate_type(show_sensors, (np.int, bool, str),
-                           "show_sensors", "numeric, str or bool")
             show_sensors = _check_loc_legal(show_sensors, "show_sensors")
             _plot_legend(pos, ["k"] * len(picks), ax, list(), outlines,
                          show_sensors, size=25)


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
@@ -196,7 +196,10 @@ def test_plot_evoked():
     evoked.plot_white([cov, cov], time_unit='s')
 
     # plot_compare_evokeds: test condition contrast, CI, color assignment
-    plot_compare_evokeds(evoked.copy().pick_types(meg='mag'))
+    fig = plot_compare_evokeds(evoked.copy().pick_types(meg='mag'),
+                               show_sensors=True)
+    assert len(fig.axes) == 2
+
     plot_compare_evokeds(
         evoked.copy().pick_types(meg='grad'), picks=[1, 2],
         show_sensors="upper right", show_legend="upper left")