Repository navigation
BUG: Accept alternate CTF .hc head-coil descriptors - #14191
Merged
Merged
Conversation
Match the .hc descriptor line case-insensitively and accept LPA/RPA as aliases for left ear/right ear, so CTF datasets that spell the coils Nasion/LPA/RPA are read instead of raising about missing HPI info.
neuromechanist
requested review from
agramfort,
drammock and
larsoner
as code owners
August 22, 2026 21:57
larsoner
approved these changes
Aug 23, 2026
larsoner
left a comment
Member
There was a problem hiding this comment.
Seems like a straightforward fix, thanks @neuromechanist !
This was referenced Aug 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference issue
Fixes #14190.
What does this implement/fix?
read_raw_ctfraisesRuntimeError: Some of the mandatory HPI device-coordinate info was not there.on CTF datasets whose.hcspells the head coilsNasion,LPA,RPArather thannasion,left ear,right ear. The coordinates are present and correct and every other part of the.hcparse succeeds; only the descriptor vocabulary differs, so every point getskind = -1and_make_ctf_coord_trans_setfinds no LPA/RPA/NAS.This does two things:
lpaandrpaas aliases. These are a different vocabulary rather than a casing difference, so lower-casing alone does not fix them.CTF's own reference reader is more permissive than this on both counts:
readHcinsidereadCTFds.mreads the coil name positionally and does not check it against a vocabulary at all (MEGCoilLabel = strvcat('nasion','left ear','right ear')is declared at line 528 and never used), and it carries an explicit workaround for astadardtypo emitted by some Acq releases. I have kept the fixed vocabulary here rather than going positional, since that is a much larger behavioural change; this is the minimum that reads the affected files.One judgement call worth flagging: I applied the lower-casing to the whole descriptor match, so
measured,relative to dewar/relative to headand theUnablesentinel are now matched case-insensitively too, not just the coil names. That felt more coherent than leaving one of four lookups case-sensitive, but I am happy to narrow it to_kind_dictif you would rather keep the diff tighter.Testing
test_hc_coil_name_variantscopies the CTF testing dataset, rewrites only the three descriptor words in the.hc, and asserts that the resultingdev_head_tand every digitization point match a read of the untouched original. It is parametrized overNasion/LPA/RPAand a mixed-case spelling. Both parametrizations fail onmainwith exactly the error from the issue and pass with this change; the rest ofmne/io/ctf/tests/test_ctf.pyis unaffected.The originating data is OpenNeuro
ds006502(CC0). The failure is raised before the.meg4is opened, so one recording's metadata reproduces it in about 3 MB:With this change that recording's
.hcparses to[NAS, LPA, RPA, NAS, LPA, RPA]across both coordinate frames and the read proceeds to the data stage.