I have performed ICA on my EEG data which included four external electrodes (placed around the eye and mastoid). The ica.fit function works but when I try and plot the ICA components using ica.plot_components, I get the following error:
ValueError: The following electrodes have overlapping positions, which causes problems during visualization:
EXG1, EXG2, EXG3, EXG4
Is it possible to include the external electrodes in my ICA calculations but not include them in plot_components?
Just to make sure, you should only include “external” electrodes (such as EOG) if they share the same reference with your EEG channels.
Regarding your question, I don’t think there’s an option to exclude specific electrodes in the plot, but you could assign locations for those four channels. Then you should be able to generate the topoplot.
Is it possible to include the external electrodes in my ICA calculations but not include them in plot_components?
If you make sure the external channels are set to a different channel type than the EEG channels, then you can choose not to have them plotted. For example, if the external channels are EOG channels, make sure they are flagged as such. By default ICA.fit() will ignore EOG channels, but you can overwrite this by explicitly passing the picks argument to ICA.fit(). Take note of what @cbrnr told you about the importance of all channels included in the ICA sharing the same reference, and then take a look at this example code:
raw = mne.io.read_raw.bdf('pilot_1.bdf', eog=['EXG1', 'EXG2', 'EXG3', 'EXG4'],
exclude=['EXG5', 'EXG6', 'EXG7', 'EXG8'])
# Check the channel-type assigned to each channel
for ch_name, ch_type in zip(raw.ch_names, raw.info.get_channel_types()):
print(ch_name, ch_type)
# Fit ICA including both "eeg" and the "eog" channels
ica = mne.preprocessing.ICA().fit(raw, picks=['eeg', 'eog'])
# Plot the first component. Just the "eeg" channels.
ica.plot_components([0], ch_type='eeg')
As a general rule, it is important to configure the channel types properly for MNE-Python functions to work correctly. BDF files don’t store any sort of channel type information, so you need to specify the types manually when calling mne.io.read_raw_bdf or with raw.set_channel_types(). External channels are often reference electrodes (type “eeg”), EOG electrodes (type “eog”) or EMG electrodes (type “emg”).