mne-tools / mne-tools/mne-python

Handling duplicate electrode names in 10–20 system

Open
#13,447 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.5k
Forks
1.6k
Avg merge
1d 6h
Merged PRs (30d)
100

Description

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"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in mne/channels/layout.py at _auto_topomap_coords, reached through mne.viz.plot_topomap, and reproduce the failure with the provided standard_1020 example. Check how overlapping names are collected and make the resulting error clearly identify duplicate electrodes and suggest drop_channels; confirm the example reports the improved guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.