Skip to content

[pop_chansel] Use the shared selection tokenizer - #587

Merged
suraj-ranganath merged 6 commits into
developfrom
cursor/fix-pop-chansel-token-parser-0367
Nov 11, 2026
Merged

suraj-ranganath merged 6 commits into
developfrom
cursor/fix-pop-chansel-token-parser-0367

Conversation

@suraj-ranganath

@suraj-ranganath suraj-ranganath commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Parse pop_chansel selection text with parse_text_tokens. An empty quoted token is an empty label, and leading and trailing braces are removed. EEGLAB parsetxt drops empty pieces and keeps brace characters. That difference is documented and locked by regressions.

Fixes #508

Open in Web Open in Cursor 

The private copy raised StopIteration on an empty quoted token.
Brace-wrapped lists now resolve to the labels inside the braces.

Co-authored-by: Suraj Ranganath <[email protected]>
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 06:14

@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 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 44s —— View job


Code review

  • Check the PR is reviewable: open, not a draft, no earlier review, and the checked-out commit matches the PR head 044dcd2

  • Read AGENTS.md, the diff, parse_text_tokens, and the callers of _selection_to_indices

  • Review in four passes: repo rules, conventions, correctness, EEGLAB parity

  • Post the review

  • Overall assessment: Looks good. Removing _parse_text and calling parse_text_tokens fixes the StopIteration from pop_chansel duplicates parse_text_tokens and raises StopIteration on an empty quoted token #508.

    • Ordinary input such as Cz, 'Fp1', 1 3 or Fp1 Pz should parse the same way as before, because both used the same token regex.
    • Brace-wrapped text that used to fail now resolves. Before, "{Cz" was not a valid label.
  • Highest-risk area: _selection_to_indices in pop_chansel.py. pop_chansel, pop_chansel_selected_string and pop_topochansel (through pop_chansel_resolve) all use it.

    • An empty token goes down the label path because int("") raises inside _is_int_text.
    • If an empty label exists, it matches. If none exists, the user gets a clear Cannot find '' error.
  • Merge recommendation: Safe to merge.

Blocking

None.

Important

None.

Nits

None.

Test gaps

None. The two new tests cover the empty quoted token and the brace-wrapped list from #508.

EEGLAB parity notes

None. This only changes how the text field is parsed. Selection still uses 1-based indices and case-insensitive label matching, as before.

Not done: I could not run uv run pytest tests/test_guifunc_pophelp_chansel.py because running it needed permission this job doesn't have. CI has to show the tests pass. I also didn't post a separate gh pr comment or inline comments: writing the review file needed permission too, and nothing needed a line-level comment.

Empty quotes stay empty labels here, and one layer of braces is removed.
parsetxt drops empty pieces and keeps the brace characters.

Co-authored-by: Suraj Ranganath <[email protected]>
@cursor
cursor Bot marked this pull request as draft November 11, 2026 06:21
@cursor
cursor Bot marked this pull request as ready for review November 11, 2026 06:21
@cursor

cursor Bot commented Nov 11, 2026

Copy link
Copy Markdown

🤖 After the first review I compared the shared tokenizer with parsetxt.m. Empty quotes stay empty labels here, and one layer of braces is removed. parsetxt drops empty pieces and keeps the brace characters. That difference is now in Known Differences.

@cursor
cursor Bot marked this pull request as draft November 11, 2026 06:22
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 06:22
@claude

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 39s —— View job


Code review

  • Check the PR can be reviewed: it is open and not a draft, no earlier review has the eegprep-claude-review marker, and the checked-out commit matches the PR head c61ec96

  • Read AGENTS.md, the diff, parse_text_tokens / _TOKEN_PATTERN and the caller _selection_to_indices

  • Review in four passes: repo rules, conventions, correctness, EEGLAB parity

  • Post the review

  • Overall assessment: Looks good, with one small docs wording nit.

  • Highest-risk area: _selection_to_indices in src/eegprep/functions/popfunc/pop_chansel.py:123. pop_chansel, pop_chansel_selected_string and pop_chansel_resolve / pop_topochansel all go through it.

    • An empty token takes the label path, because _is_int_text("") is false.
    • If the dataset has no empty label, the user gets Cannot find '', which is a clear error.
  • Merge recommendation: Safe to merge.

Blocking

None.

Important

None.

Nits

  • docs/source/user_guide/eeglab_migration.rst (Known Differences row) and the PR comment say "it removes one layer of surrounding braces".
    • parse_text_tokens actually calls str(text).strip().strip("{}") (value_parsing.py:43). That removes every leading and trailing { and }, and the two ends don't have to match.
    • So {{Cz}} resolves to Cz, and so do {Cz and Cz}.
    • This doesn't matter for real input. But this row exists to tell users exactly how EEGPrep differs from parsetxt, so it should be accurate.
    • Suggested fix: change the wording to "removes leading and trailing braces". Do not change the shared tokenizer; other dialogs use it too.

Test gaps

None.

EEGLAB parity notes

None blocking.

  • parsetxt drops empty pieces and keeps the brace characters. That difference is now listed under Known Differences, and the two tests above lock the EEGPrep behaviour. Under the repo's rule (documented and tested), that is an accepted difference, not a parity bug.
  • Indices are still 1-based, and labels still match case-insensitively.
  • The help resource (resources/help/pop_chansel.md) and the changelog are updated, as AGENTS.md requires.
  • I couldn't compare against the MATLAB source line by line: parsetxt.m and pop_chansel.m are not in this checkout's src/eegprep/eeglab/.

Checked for correctness bugs, EEGLAB parity, data structure compatibility, changed-behavior tests, and CLAUDE.md/AGENTS.md compliance.

Not done:

  • I didn't run the tests; CI needs to show they pass.
  • I posted no inline comments. The nit is a one-word docs change and is fully described above.

parse_text_tokens removes every brace at either end of the selection text.

Co-authored-by: Suraj Ranganath <[email protected]>
@cursor

cursor Bot commented Nov 11, 2026

Copy link
Copy Markdown

🤖 The Known Differences row now says leading and trailing braces are removed, which is what strip("{}") does.

@cursor
cursor Bot marked this pull request as draft November 11, 2026 06:29
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 06:29
@claude

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 24s —— View job


Code review — skipped

  • Check the PR can be reviewed: it is open, not a draft, and both the checked-out commit and the PR head are c7be681
  • Look for an earlier review with the eegprep-claude-review marker
  • Stop: a review already exists, and nobody asked for another one

Why I stopped: A full review was posted at 06:23 against c61ec96, with the eegprep-claude-review marker. Marking the PR ready for review doesn't count as asking for a new one, so the review skill stops here.

What changed since that review: c7be681 changed only the Known Differences row in docs/source/user_guide/eeglab_migration.rst. It now says "removes leading and trailing braces", which fixes the one nit from that review. That wording is correct: parse_text_tokens calls str(text).strip().strip("{}") (src/eegprep/functions/miscfunc/value_parsing.py:43). No code or tests changed, so the earlier recommendation still applies: safe to merge.

For a full new review, comment @claude review this on the PR.

Not done: I didn't run the tests; CI needs to show they pass.

…nsel-token-parser-0367

Co-authored-by: Suraj Ranganath <[email protected]>

# Conflicts:
#	docs/source/changelog.rst
…nsel-token-parser-0367

Co-authored-by: Suraj Ranganath <[email protected]>

# Conflicts:
#	docs/source/changelog.rst
…nsel-token-parser-0367

Co-authored-by: Suraj Ranganath <[email protected]>

# Conflicts:
#	docs/source/changelog.rst
@suraj-ranganath
suraj-ranganath merged commit 2667ef7 into develop Nov 11, 2026
10 checks passed
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.

pop_chansel duplicates parse_text_tokens and raises StopIteration on an empty quoted token

2 participants