Skip to content

Slicer: select channels by regex against CoordinateAxis labels - #170

Merged
cboulay merged 1 commit into
devfrom
feat-61-slicer-regex
Jul 8, 2026
Merged

Slicer: select channels by regex against CoordinateAxis labels#170
cboulay merged 1 commit into
devfrom
feat-61-slicer-regex

Conversation

@cboulay

@cboulay cboulay commented Jul 8, 2026

Copy link
Copy Markdown
Member

Closes #61.

parse_slice already matched comma-separated tokens exactly against CoordinateAxis labels. This PR adds the remaining half of the request: non-numeric tokens that fail an exact match are compiled as regular expressions and full-matched against the labels, e.g.:

Slicer(selection="C.*", axis="ch")       # C3, C4, Cz
Slicer(selection="O.*, C3", axis="ch")   # O1, O2, C3 (concatenated in order)

As sketched in the issue, patterns resolve to integer indices once at reset time and are cached in SlicerState; per-chunk cost is unchanged.

  • Exact label match still takes precedence over regex (and over int parsing).
  • re.fullmatch semantics: "Fp" does not match "Fp1" — use "Fp.*".
  • A token that matches nothing raises an informative ValueError instead of an int-parse error.
  • Documented limitation: tokens containing : parse as slices, so regexes cannot contain :.

Closes #61. parse_slice already matched comma-separated tokens exactly
against axis labels; non-numeric tokens that fail an exact match are now
compiled as regular expressions and full-matched against the labels,
resolving to integer indices at reset time as before. A token that matches
nothing raises an informative ValueError instead of an int-parse error.
@cboulay
cboulay merged commit 9f5a691 into dev Jul 8, 2026
12 checks passed
@cboulay
cboulay deleted the feat-61-slicer-regex branch July 8, 2026 05:42
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.

Select channels based on their labels

1 participant