Skip to content

read_dig_hpts crashes on BioSemi-style .hpts with named cardinal fiducials #14538

Open

Description

@Jay2006sawant

Description of the problem

mne.channels.read_dig_hpts fails on the BioSemi cap coordinates file shipped in the repository (mne/io/edf/tests/data/biosemi.hpts). That file uses text cardinal labels (nasion, lpa, rpa), while read_dig_hpts only maps numeric identifiers (1, 2, 3) for cardinal rows (as in the docstring example and mne/io/brainvision/tests/data/test.hpts).

The EDF test suite already references this file with a comment # XXX: missing reader, so the failure looks unintentional.


Steps to reproduce

from pathlib import Path

import mne

# From a clone of mne-python (adjust if installed differently):
repo = Path(mne.__file__).resolve().parents[1]
fname = repo / "io" / "edf" / "tests" / "data" / "biosemi.hpts"

from mne.channels import read_dig_hpts

montage = read_dig_hpts(fname)
print(montage)

Alternative (fixed path in a dev checkout):

from pathlib import Path
from mne.channels import read_dig_hpts

read_dig_hpts(Path("mne/io/edf/tests/data/biosemi.hpts"))

Link to data

No external data needed. Reproduction uses the file already in the repo:

mne/io/edf/tests/data/biosemi.hpts

(BioSemi-style layout; cardinal section uses lines like cardinal nasion …, cardinal lpa …, cardinal rpa ….)


Expected results

read_dig_hpts returns a DigMontage with EEG electrode positions and three cardinal fiducials (nasion, lpa, rpa), similar to other .hpts files that load successfully (e.g. mne/io/brainvision/tests/data/test.hpts).


Actual results

Traceback (most recent call last):
  ...
  File ".../mne/channels/montage.py", line 1177, in read_dig_hpts
    fid_idx_to_label[label[ii]]: this_xyz
KeyError: 'nasion'

Activity

  1. changed the title [-]**`read_dig_hpts` crashes on BioSemi-style `.hpts` with named cardinal fiducials**[/-] [+]`read_dig_hpts` crashes on BioSemi-style `.hpts` with named cardinal fiducials[/+] on Nov 16, 2026
  2. Jay2006sawant commented on Nov 16, 2026

    @Jay2006sawant
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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