Repository: mne-tools/mne-python

Issue:
"Sorted by RT" erpimage in examples clearly isn't sorted by RT
<img width="1010" alt="Screenshot 2020-10-15 at 10 34 04" src="https://user-images.githubusercontent.com/4321826/96098149-14cf8f00-0ed2-11eb-96e0-85a1db0f9d99.png">

This has been broken since 0.18: https://mne.tools/0.18/auto_examples/visualization/plot_roi_erpimage_by_rt.html#sphx-glr-auto-examples-visualization-plot-roi-erpimage-by-rt-py


Discussion:
@drammock do you want to take a look?
I'll take a look today

Resolving patch:
diff --git a/examples/visualization/plot_roi_erpimage_by_rt.py b/examples/visualization/plot_roi_erpimage_by_rt.py
--- a/examples/visualization/plot_roi_erpimage_by_rt.py
+++ b/examples/visualization/plot_roi_erpimage_by_rt.py
@@ -54,13 +54,13 @@
 # define target events:
 # 1. find response times: distance between "square" and "rt" events
 # 2. extract A. "square" events B. followed by a button press within 700 msec
-tmax = .7
+tmax = 0.7
 sfreq = raw.info["sfreq"]
 reference_id, target_id = 2, 1
 new_events, rts = define_target_events(events, reference_id, target_id, sfreq,
                                        tmin=0., tmax=tmax, new_id=2)
 
-epochs = mne.Epochs(raw, events=new_events, tmax=tmax + .1,
+epochs = mne.Epochs(raw, events=new_events, tmax=tmax + 0.1,
                     event_id={"square": 2})
 
 ###############################################################################
diff --git a/mne/viz/epochs.py b/mne/viz/epochs.py
--- a/mne/viz/epochs.py
+++ b/mne/viz/epochs.py
@@ -289,8 +289,8 @@ def plot_epochs_image(epochs, picks=None, sigma=0., vmin=None,
         this_image = combine_func(this_data * scalings[this_ch_type])
         # handle `order`. NB: this can potentially yield different orderings
         # in each figure!
-        this_image, overlay_times = _order_epochs(this_image, epochs.times,
-                                                  order, overlay_times)
+        this_image, _overlay_times = _order_epochs(this_image, epochs.times,
+                                                   order, overlay_times)
         this_norm = np.all(this_image > 0)
         # apply smoothing
         if sigma > 0.:
@@ -325,7 +325,7 @@ def plot_epochs_image(epochs, picks=None, sigma=0., vmin=None,
             if isinstance(combine, str) and len(title):
                 _comb = combine.upper() if combine == 'gfp' else combine
                 _comb = 'std. dev.' if _comb == 'std' else _comb
-                title += ' ({})'.format(_comb)
+                title += f' ({_comb})'
 
         # plot the image
         this_fig = _plot_epochs_image(
@@ -334,7 +334,7 @@ def plot_epochs_image(epochs, picks=None, sigma=0., vmin=None,
             style_axes=True, norm=this_group_dict['norm'],
             unit=units[this_ch_type], ax=this_axes_dict, show=False,
             title=title, combine=combine, combine_given=combine_given,
-            overlay_times=overlay_times, evoked=evoked, ts_args=ts_args)
+            overlay_times=_overlay_times, evoked=evoked, ts_args=ts_args)
         group_by[this_group].update(fig=this_fig)
 
         # detect ylims across figures
@@ -478,27 +478,25 @@ def _order_epochs(data, times, order=None, overlay_times=None):
 
     if overlay_times is not None:
         if len(overlay_times) != n_epochs:
-            raise ValueError('size of overlay_times parameter ({}) does not '
-                             'match the number of epochs ({}).'
-                             .format(len(overlay_times), n_epochs))
+            raise ValueError(
+                f'size of overlay_times parameter ({len(overlay_times)}) does '
+                f'not match the number of epochs ({n_epochs}).')
         overlay_times = np.array(overlay_times)
         times_min = np.min(overlay_times)
         times_max = np.max(overlay_times)
-        if ((times_min < times[0]) or (times_max > times[-1])):
+        if (times_min < times[0]) or (times_max > times[-1]):
             warn('Some values in overlay_times fall outside of the epochs '
-                 'time interval (between %s s and %s s)'
-                 % (times[0], times[-1]))
+                 f'time interval (between {times[0]} s and {times[-1]} s)')
 
     if callable(order):
         order = order(times, data)
 
     if order is not None:
         if len(order) != n_epochs:
-            raise ValueError('If order is a {}, its length ({}) must match '
-                             'the length of the data ({}).'
-                             .format(type(order).__name__, len(order),
-                                     n_epochs))
-        order = np.asarray(order)
+            raise ValueError(f'If order is a {type(order).__name__}, its '
+                             f'length ({len(order)}) must match the length of '
+                             f'the data ({n_epochs}).')
+        order = np.array(order)
         data = data[order]
         if overlay_times is not None:
             overlay_times = overlay_times[order]


Test patch: