Repository: mne-tools/mne-python

Issue:
ica.plot_sources ignores ica_names if picks is used

#### Describe the bug
if you specify `picks` to `ica_plot_sources` the labels are in order starting with ICA0000, ICA0001....

For instance
`ica.plot_sources(raw, picks=[4, 6])`
will make a plot whose ch_name labels are ICA0000 ICA0001

#### Steps to reproduce
this is reproduced in the final plot of the ica example
https://mne.tools/dev/auto_examples/preprocessing/plot_run_ica.html#sphx-glr-auto-examples-preprocessing-plot-run-ica-py

CC @drammock 



Discussion:

Resolving patch:
diff --git a/examples/preprocessing/plot_run_ica.py b/examples/preprocessing/plot_run_ica.py
--- a/examples/preprocessing/plot_run_ica.py
+++ b/examples/preprocessing/plot_run_ica.py
@@ -58,5 +58,5 @@
 ica.plot_properties(epochs, picks=ecg_inds)
 
 ###############################################################################
-# Plot the estimated source of detected ECG related components
+# Plot the estimated source of detected ECG related components:
 ica.plot_sources(raw, picks=ecg_inds)
diff --git a/mne/io/ctf/info.py b/mne/io/ctf/info.py
--- a/mne/io/ctf/info.py
+++ b/mne/io/ctf/info.py
@@ -245,7 +245,7 @@ def _convert_channel_info(res4, t, use_eeg_pos):
                         warn('EEG electrode (%s) location omitted because of '
                              'missing HPI information' % ch['ch_name'])
                         ch['loc'].fill(np.nan)
-                        coord_frame = FIFF.FIFFV_COORD_CTF_HEAD
+                        coord_frame = FIFF.FIFFV_MNE_COORD_CTF_HEAD
                     else:
                         ch['loc'][:3] = apply_trans(
                             t['t_ctf_head_head'], ch['loc'][:3])
diff --git a/mne/viz/ica.py b/mne/viz/ica.py
--- a/mne/viz/ica.py
+++ b/mne/viz/ica.py
@@ -941,11 +941,12 @@ def _plot_sources(ica, inst, picks, exclude, start, stop, show, title, block,
         (picks, ica.n_components_ + np.arange(len(extra_picks))))
     ch_order = np.arange(len(picks))
     n_channels = min([20, len(picks)])
+    ch_names_picked = [ch_names[x] for x in picks]
 
     # create info
-    info = create_info([ch_names[x] for x in picks], sfreq, ch_types=ch_types)
+    info = create_info(ch_names_picked, sfreq, ch_types=ch_types)
     info['meas_date'] = inst.info['meas_date']
-    info['bads'] = [ch_names[x] for x in exclude]
+    info['bads'] = [ch_names[x] for x in exclude if x in picks]
     if is_raw:
         inst_array = RawArray(data, info, inst.first_samp)
         inst_array.set_annotations(inst.annotations)
@@ -984,7 +985,7 @@ def _plot_sources(ica, inst, picks, exclude, start, stop, show, title, block,
                   ica_inst=inst,
                   info=info,
                   # channels and channel order
-                  ch_names=np.array(ch_names),
+                  ch_names=np.array(ch_names_picked),
                   ch_types=np.array(ch_types),
                   ch_order=ch_order,
                   picks=picks,


Test patch:
diff --git a/mne/viz/tests/test_ica.py b/mne/viz/tests/test_ica.py
--- a/mne/viz/tests/test_ica.py
+++ b/mne/viz/tests/test_ica.py
@@ -231,6 +231,9 @@ def test_plot_ica_sources():
     _close_event(fig)
     assert len(plt.get_fignums()) == 0
     assert_array_equal(ica.exclude, [0])
+    # test when picks does not include ica.exclude.
+    fig = ica.plot_sources(raw, picks=[1])
+    assert len(plt.get_fignums()) == 1
     plt.close('all')
 
     # dtype can change int->np.int64 after load, test it explicitly