Skip to content

Review fixes for #693: frame orientation cases - #694

Merged
neuromechanist merged 3 commits into
agent/20261125-fix-692from
fix/692-frame-orientation-review
Nov 25, 2026
Merged

neuromechanist merged 3 commits into
agent/20261125-fix-692from
fix/692-frame-orientation-review

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

This PR targets #693's branch, agent/20261125-fix-692, not develop, so its commits land in #693. It fixes the four cases from the review on #693:

  1. A coordsystem with no EEGCoordinateSystem was still read as RAS; it now leaves the locations unset, with a warning.
  2. Any name with EEGLAB in it, in any case ("eeglab", "EEGLAB " with a trailing space), is ALS again, as on develop.
  3. Names match without regard to case, so "captrak" is RAS, and MNI152NLin6Asym, the schema's spelling from BIDS 1.11.0, is RAS beside MNI152NLin6ASym. eegprep-lean's frame table gains the same spelling.
  4. A frame named "ALS" or "RAS" is no longer applied as that orientation; it is left unset, as Other is.

The unknown-frame warning now names the coordsystem file, not the channels file. All four cases go through one helper, bids_coordsystem_orientation in coords.py, which builds on #693's BIDS_ALS_SYSTEMS and BIDS_RAS_SYSTEMS. The changelog, the BIDS guide and the pop_load_frombids help describe the result.

Tests: #693's frame tests gain each case and an EEGCoordinateSystemDescription of EEGLAB. Eight of them fail on #693's head and pass here. eegprep-lean's tests gain MNI152NLin6Asym, including the cross-route comparison, and fail without the lean fix. Run locally: tests/test_bids_load_frombids_helpers.py (32 passed); the eegprep-lean suite as CI runs it (406 passed, 28 skipped); the full suite without MATLAB and without the pamica module (3397 passed, plus 5 ASR failures that also fail on develop on this macOS machine and pass in #693's CI); ruff, ty and ./pre-commit.py.

Part of #692

Agentic AI tools were used. Workflows follow the Research Skills (doi:10.5281/zenodo.20696515). The author assumes full responsibility for this content and associated changes.

Fixes four cases #693 left: a coordsystem that names no system was
still read as RAS; names with EEGLAB in them were no longer ALS unless
spelled exactly; MNI152NLin6Asym, the schema spelling from BIDS 1.11.0,
and miscased names such as captrak lost their positions; and a frame
named ALS or RAS was applied as that orientation. The unknown-frame
warning now names the coordsystem file, not the channels file.

Tested: uv run pytest tests/test_bids_load_frombids_helpers.py
The BIDS schema spells this template MNI152NLin6Asym from 1.11.0, while
the appendix's table and lean's frame table had only MNI152NLin6ASym,
so the Zarr route refused a current dataset's frame. The lean docs now
describe the import as it reads frames after the review fixes, and the
changelog no longer says the import turns CTF, 4DBti or KitYokogawa.

Tested: eegprep-lean tests -m "not network" (PYTHONPATH=src, from
packages/eegprep-lean, as CI runs them); the four new MNI152NLin6Asym
cases fail against the old table.
The changelog entry and BIDS guide no longer say a coordsystem with no
EEGCoordinateSystem is read as RAS, and now state the case-insensitive
match, the EEGLAB rules and the label-inference fallback. The older
eegprep_lean.to_eeg entry drops its CTF clause, and the
pop_load_frombids help gains the frame rule.

Tested: docutils parse of the edited RST; pytest
tests/test_guifunc_pophelp_chansel.py.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@claude

claude Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @neuromechanist's task in 47s —— View job


PR review: #694, the review fixes for #693's frame orientation

  • Gather context (diff against origin/agent/20261125-fix-692)
  • Review the coords helper and the pop_load_frombids changes
  • Review the eegprep-lean changes
  • Review the tests and docs
  • Post review

Verdict: No blocking issues. All four cases from the #693 review are fixed. There are two minor suggestions inline and one doc nit below.

I could not run the tests in this job: the sandbox asked for approval for uv run pytest. This review is from reading the code, and the test results below are the ones the PR description reports.

Correctness

  • bids_coordsystem_orientation (src/eegprep/plugins/EEG_BIDS/coords.py:66-80) handles each case correctly:
    • An EEGCoordinateSystemDescription of EEGLAB gives ALS.
    • A system that is not a string, or is missing, gives None.
    • A name containing EEGLAB gives ALS. This restores develop's 'EEGLAB' in coord_system.upper() rule, including "EEGLAB " with its trailing space.
    • Every other name is looked up after strip().lower().
  • Check order: the helper checks the description before the system name, while develop checked the name first. Both checks return ALS, so the order does not change any result.
  • Lowercase table: the comment saying no two frames differ only in case holds. The ALS and RAS sets have no lowercase collisions, and MNI152NLin6ASym and MNI152NLin6Asym both map to RAS.
  • Missing name or a name not in the table: these now give None and no override. The ALS, RAS and None test cases cover the old fallthrough, where coord_system = coord_system_name let a literal "ALS" or "RAS" through.
  • Variables in the warning (pop_load_frombids.py:353-357): coord_system is None only in the branch that has a coordsystem file. In that branch report['CoordsystemFrom'] and coord_system_name are always set, so neither can be undefined. When there is no coordsystem file, coord_system is still 'ALS' for .set and 'RAS' otherwise, as on develop.
  • Docs claim: the BIDS guide says that with infer_locations=None, locations are inferred from channel labels when no channel has coordinates. That matches pop_load_frombids.py:596-597.
  • eegprep-lean: only the MNI152NLin6Asym spelling is added; lookups there stay case-sensitive, and the module docstring and README now say that is deliberate. The new SAME_AS_THE_BIDS_IMPORT row exercises the import and lean routes on the same spelling.

Suggestions (inline)

  1. pop_load_frombids.py:355: a coordsystem that names no system produces the warning "Coordinate system None in … has no orientation in the BIDS coordinate-systems appendix", which reads as if a system called None was looked up. A separate message for a missing EEGCoordinateSystem would be clearer.
  2. coords.py:73: system names now match regardless of case, but the description must still equal 'EEGLAB' exactly. That is unchanged from develop. Worth normalizing only if case-insensitive matching is meant to apply everywhere.

Doc nit

The lean bullet in docs/source/changelog.rst (around line 280) now says the import gives the same values "except where the import guesses a unit or assumes a system". It leaves out the differences this PR adds:

  • The import accepts captrak and other names in a different case, while lean gives no positions for them.
  • The import reads any name containing EEGLAB as ALS, while lean does not.

packages/eegprep-lean/CHANGELOG.md has the same gap: its to_eeg bullet lists only the description difference. The lean README and the locations.py docstring already list these differences, so the two changelogs are the only places out of step.

Tests

The new cases are focused, and the PR description says they fail on #693's head:

  • the four orientation cases and the EEGLAB description;
  • MNI152NLin6Asym in eegprep-lean, including the cross-route comparison.

They extend the existing parametrized tests instead of adding a new file, as AGENTS.md asks.

elif coord_system is None:
warning(
f"Coordinate system {coord_system!r} of {fo.filename} has no "
f"Coordinate system {coord_system_name!r} in {report['CoordsystemFrom']} has no "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Nit: when the coordsystem has no EEGCoordinateSystem, this prints Coordinate system None in sub-01/eeg/..._coordsystem.json has no orientation in the BIDS coordinate-systems appendix. That reads as if a system called None was looked up. A separate message for the missing name would be clearer, e.g. "{report['CoordsystemFrom']} names no EEGCoordinateSystem; not overriding channel locations.". The parametrized test checks repr(system) in warning, so the None case would need its own assertion.

name, is ALS. Any other system is looked up in the BIDS coordinate-systems appendix.
Returns ``None`` for ``Other``, a name the appendix does not list, or no name at all.
"""
if coordsystem.get('EEGCoordinateSystemDescription') == 'EEGLAB':

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Nit: EEGCoordinateSystem now matches regardless of case and surrounding spaces, but EEGCoordinateSystemDescription still has to equal 'EEGLAB' exactly. So "eeglab" or "EEGLAB " in the description falls through to the system lookup. develop also compared it exactly, so this isn't a regression. If case-insensitive matching is the rule now, the description could be normalized the same way, e.g. str(...).strip().upper() == 'EEGLAB'. Fine to leave as is if the exact match is intentional.

@neuromechanist
neuromechanist merged commit 1cfc5df into agent/20261125-fix-692 Nov 25, 2026
17 checks passed
@neuromechanist
neuromechanist deleted the fix/692-frame-orientation-review branch November 25, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant