Skip to content

Handling duplicate electrode names in 10–20 system #13447

@scott-huberty

Description

@scott-huberty

I would expect this to run without error out of the box but it doesn't:

import mne
import numpy as np

standard_montage = mne.channels.make_standard_montage("standard_1020")
data = np.random.randn(len(standard_montage.ch_names))
info = mne.create_info(ch_names=standard_montage.ch_names, sfreq=1000, ch_types="eeg")
info.set_montage(standard_montage)
mne.viz.plot_topomap(data, pos=info)
File ~/devel/repos/mne-python/mne/channels/layout.py:974, in _auto_topomap_coords(info, picks, ignore_overlap, to_sphere, sphere)
    968 if len(locs3d) > 1 and np.min(dist) < 1e-10 and not ignore_overlap:
    969     problematic_electrodes = [
    970         chs[elec_i]["ch_name"]
    971         for elec_i in squareform(dist < 1e-10).any(axis=0).nonzero()[0]
    972     ]
--> 974     raise ValueError(
    975         "The following electrodes have overlapping positions,"
    976         " which causes problems during visualization:\n"
    977         + ", ".join(problematic_electrodes)
    978     )
    980 if to_sphere:
    981     # translate to sphere origin, transform/flatten Z, translate back
    982     locs3d -= sphere[:3]

ValueError: The following electrodes have overlapping positions, which causes problems during visualization:
T7, T8, P7, P8, T3, T5, T4, T6

My understanding is that there are essentially two flavors of the 10–20 system (ref) that differ slightly in electrode naming:

the MCN system renames four electrodes of the 10–20 system:
T3 is now T7
T4 is now T8
T5 is now P7
T6 is now P8

MNE’s standard_1020 montage includes both sets of names, which is usually fine, because acquisition systems will stick to one convention or the other.

But when I used MNE's interpolate_to function to map an EGI net to the 10-20 montage, I ended up with both versions (e.g. T3 and T7), which triggered the same error I demonstrated above.

After speaking with @britta-wstnr @drammock and @larsoner , we agreed that in this specific case, it would be helpful to raise a clearer error message, something like:

"You have duplicate electrodes (T3, T7), please use drop_channels to drop one of them"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions