How to exclude externals in ICA plot_components

  • MNE version: 1.3.0
  • operating system: Windows 10

I have performed ICA on my EEG data which included four external electrodes (placed around the eye and mastoid). The 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:

Is it possible to include the external electrodes in my ICA calculations but not include them in plot_components?

Here is an excerpt of my code:

raw ='pilot_1.bdf', stim_channel = -1,preload=True, exclude=['EXG5', 'EXG6', 'EXG7', 'EXG8'])

# Use the preloaded montage
easycap_montage = mne.channels.make_standard_montage('biosemi64')
raw.set_montage(easycap_montage, on_missing='warn')

# add annotations from file
annotations = mne.read_annotations('saved-annotations.csv')

raw_ref, ref_data = mne.set_eeg_reference(raw, ref_channels='average',copy=True)

filtered_data = raw_ref.filter(l_freq=0, h_freq=40)

### ICA ###
channels = mne.pick_channels(raw.ch_names,include=[x],exclude=['AFz','Status'])
ica = mne.preprocessing.ICA(n_components=20, random_state=0),reject_by_annotation=True,picks=channels)'biosemi64',on_missing='warn')

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.


Thanks for your response!

How do you add the externals to a channel layout?

And yes, the externals are using the same reference as the rest of the channels.

You can create your own custom montage with mne.channels.make_dig_montage — MNE 1.3.0 documentation.

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 will ignore EOG channels, but you can overwrite this by explicitly passing the picks argument to 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 ='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,
    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 or with raw.set_channel_types(). External channels are often reference electrodes (type “eeg”), EOG electrodes (type “eog”) or EMG electrodes (type “emg”).


Thanks so much for the help! That fixes the problem.