Hello, I assume it has to do with the fact that you drop channels from the data you fit ICA on, while keeping those channels in the data you then apply the ICA unmixing matrix to.
I’m a little confused - I was following exactly the tutorial here Repairing artifacts with ICA — MNE 1.0.0 documentation where the same is done - the ica is fitted to the filtered data and then the normal raw is used to plot the sources
Edit: I reread your comment and do you think it’s because I drop the ECG channel? I tried doing plot_sources with raw_filtered instead and no joy there either (same error)
Edit 2: Just to check your hunch, I tried rerunning without dropping the ECG channel, and I still get the same error - there must be some kind of mismatch between the info and annotations but I have no idea how to fix
What happens if you fit and apply ICA on the exact same data? That is, don’t run ICA on the filtered data and apply it to the unfiltered data (as is normally recommended), but just use your raw everywhere?
Note that this is normally not recommended, but merely an attempt to better understand the problem you’re seeing here
Also, can you please provide the complete traceback if you hit the error again? Not just the last line or two, but all of them?
Same error if I just use raw rather than raw_filtered, here it is:
Traceback (most recent call last):
File "/data/pt_02569/Python_Cardiac/main.py", line 74, in <module>
run_ica(subject, condition, srmr_nr, sampling_rate)
File "/data/pt_02569/Python_Cardiac/ICA.py", line 49, in run_ica
ica.plot_sources(raw) # Just for visualising
File "/data/pt_02569/Python_Cardiac/venv/lib/python3.6/site-packages/mne/preprocessing/ica.py", line 1852, in plot_sources
show_scrollbars=show_scrollbars)
File "/data/pt_02569/Python_Cardiac/venv/lib/python3.6/site-packages/mne/viz/ica.py", line 88, in plot_ica_sources
show_scrollbars=show_scrollbars)
File "/data/pt_02569/Python_Cardiac/venv/lib/python3.6/site-packages/mne/viz/ica.py", line 989, in _plot_sources
inst_array.set_annotations(inst.annotations)
File "<decorator-gen-183>", line 24, in set_annotations
File "/data/pt_02569/Python_Cardiac/venv/lib/python3.6/site-packages/mne/io/base.py", line 659, in set_annotations
new_annotations._prune_ch_names(self.info, on_missing)
File "/data/pt_02569/Python_Cardiac/venv/lib/python3.6/site-packages/mne/annotations.py", line 422, in _prune_ch_names
on_missing, 'At least one channel name in '
File "/data/pt_02569/Python_Cardiac/venv/lib/python3.6/site-packages/mne/utils/check.py", line 757, in _on_missing
raise error_klass(msg)
ValueError: At least one channel name in annotations missing from info: S35
And I guess my ica problems get even weirder… If I plot the ICA components, it shows that almost all of them explain a high amount of the variance, which doesn’t make sense
This is only the scores for the automated artifact detection, so you’re not seeing how much variance each component explains in this figure.
As for your issue, I just realized that your MNE version is quite old. Is there any chance you could update to MNE-Python 1.0 and see if the problem persists?
Otherwise I’m at a loss and I think I cannot help without getting my hands on the data.
So whatever quirk/bug it is it’s just not letting me plot the sources but the ICA seems to do just fine! Thanks for your help and I’ll update if I change my MNE version
I don’t think it’s working well based on this figure and the scores you presented earlier… In the first subplot in the last figure you posted, one can clearly see a black trace capturing heartbeats. I wouldn’t really trust these results…
Because I was allowing the auto selection, I think it’s using far too many components (I think I’m right in that it selects all the red bars in the plot_scores figure?) so it’s kind of killing the whole signal, but other than that it is removing the heart artefact