Skip to content

[GUI] Display the channel reference and original index as read-only fields - #944

Open
arnodelorme wants to merge 5 commits into
developfrom
agent/issue-875-channel-fields
Open

arnodelorme wants to merge 5 commits into
developfrom
agent/issue-875-channel-fields

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Display the channel reference and original index as read-only fields. The continuous window measured 671 px high in MATLAB, 671 px before the fix and 671 px afterward. Stack base is #929.

Continuous

Epoched

Displacement

Retained EEG samples and channel labels

Across 2 native openings, the largest vertical control offset was 0.69 px (target 1 px). Numerical comparison of retained eeg samples and channel labels: 2/2 measured cases within tolerance. The channel reference and original index now render as static text. The Set reference action and one-based navigation remain available.

EEGLAB 5e0be870, EEGPrep after d4aae6b3, clean Linux checkouts. Part of #875.

Fixes #947.

Full inventory report for the project team. pop_chanedit (p. 5). PDF · Editable Word.

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

Copy link
Copy Markdown
Contributor

PR #944 was updated after the trigger (52d7215 -> d4aae6b). Push again or mention Claude to run on the latest version.

@arnodelorme arnodelorme left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This review was written by an AI assistant during a nightly check, not by Arno.

Code review

  • Overall assessment: needs changes
  • Highest-risk area: channel navigation state and coordinate display in pop_chanedit (src/eegprep/functions/guifunc/qt.py, src/eegprep/functions/popfunc/pop_chanedit.py)
  • Merge recommendation: needs changes

Blocking

None.

Important

  1. Returning to channel 1 leaves field_urchan blank instead of showing "1" (src/eegprep/functions/guifunc/qt.py, _store_displayed_fields,

    def _store_displayed_fields(widgets: Mapping[str, Any], display: Mapping[str, Any]) -> None:
    if not isinstance(display, dict):
    return
    for tag, previous in list(display.items()):
    widget = widgets.get(tag)
    if widget is None:
    continue
    value = _read_widget(widget)
    if _same_displayed_value(previous, value):
    continue
    display[tag] = value
    , and src/eegprep/functions/popfunc/pop_chanedit.py, pop_chanedit_dialog_spec,
    field_displays = [_channel_field_displays(chan, field_rows) for chan in chanlocs]
    state = {
    "chanlocs": chanlocs,
    "chaninfo": deepcopy(EEG.get("chaninfo", {})),
    "urchans": chanlocs_as_list(EEG.get("urchanlocs")),
    "commands": [],
    "displays": field_displays,
    "field_rows": field_rows,
    "navigation": [],
    "windows": [],
    }
    state["chaninfo"].pop("nodatchans", None)
    nav_base = {
    "channel_tag": "channel",
    "max_index": len(chanlocs),
    "field_displays": field_displays,
    }
    def _nav(tag: str, delta: int) -> CallbackSpec | None:
    params = {**nav_base, "delta": delta, "source": tag, "state": state}
    state["navigation"].append(params)
    return CallbackSpec("navigate_channel", params=params)
    channel_callback = _nav("channel", 0)
    controls: list[ControlSpec] = [ControlSpec('text', 'Channel information ("field_name"):', font_weight="bold")]
    geometry: list[tuple[float, ...]] = [(1,)]
    for label, field, button_label in field_rows:
    value = current.get(field, "")
    if field == "urchan" and "urchans" not in current:
    value = ""
    elif field == "datachan":
    value = _is_data_location(current)
    else:
    value = _display_channel_value(current, field)
    controls.extend(
    )

    • Why it matters: pop_chanedit_dialog_spec initializes the field_urchan control on channel 1 with value="" (matching pop_chanedit.m lines 347 to 349) while storing "1" in field_displays[0]["field_urchan"]. Because field_urchan now renders as a QLabel (display_as_text=True), clicking > runs _store_displayed_fields(widgets, displays[0]), which reads QLabel.text() ("") via _read_widget and overwrites displays[0]["field_urchan"] with "". Clicking < to return from channel 2 to channel 1 then shows "" instead of "1" for the rest of the session, contradicting both EEGLAB (pop_chanedit.m lines 509 to 511 and 1064 to 1073, which fills num2str(chans(1).urchan) on cursor movement) and the new documentation in docs/source/api/interactive_pop_workflows.rst ("Moving between channels shows the original channel index using one-based numbering").
    • Suggested fix: Skip read-only QLabel widgets in _store_displayed_fields (if widget is None or _qt_isinstance(widget, "QLabel"): continue) so navigation only snapshots user-editable controls and preserves displays[0]["field_urchan"] == "1".
  2. _display_channel_value overwrites stored non-blank polar and spherical coordinates from X, Y, Z (src/eegprep/functions/popfunc/pop_chanedit.py, _display_channel_value,

    def _display_channel_value(chan: dict[str, Any], field: str) -> str:
    if field == "urchan":
    # urchan is 0-based in memory (pop_loadset.py) and 1-based in EEGLAB's window
    urchan = chan.get("urchan", "")
    return _display_value(urchan + 1 if isinstance(urchan, (int, float, np.integer, np.floating)) else urchan)
    if field not in {"theta", "radius", "sph_theta", "sph_phi", "sph_radius"} or _is_blank(chan.get(field)):
    return _display_value(chan.get(field, ""))
    converted = dict(chan)
    if all(not _is_blank(converted.get(item)) for item in ("X", "Y", "Z")):
    _cart_to_all(converted)
    return _display_value(converted.get(field, chan.get(field, "")))
    )

    • Why it matters: Adding or _is_blank(chan.get(field)) inverted the guard in _display_channel_value. When chan.get(field) is blank, line 615 now returns "" immediately. When chan.get(field) is non-blank, execution falls through to lines 616 to 619 and runs _cart_to_all(converted) whenever X, Y, and Z are present, replacing the stored field value on screen. For example, after edited = pop_chanedit(eeg, "changefield", [1, "radius", 0.65]) on eeglab_data.set (or after typing 0.65 in field_radius and clicking Set reference), EEGLAB pop_chanedit.m (lines 350 and 1069) shows "0.65", whereas pop_chanedit_dialog_spec shows "0.50669" recomputed from X, Y, Z. Because _store_form_edits (line 272) also compares form text against _display_channel_value(current, field), a user cannot even reset that field back to "0.50669" on Ok.
    • Suggested fix: Return _display_value(chan.get(field, "")) directly for every field other than "urchan" in _display_channel_value (matching pop_chanedit.m lines 350 and 1069, which never recompute coordinates during field display) and remove the unused _cart_to_all helper. If coordinate completion on raw X/Y/Z channel dicts without theta or sph_theta is needed when opening the dialog, run eeg_checkchanlocs once at dialog initialization as pop_chanedit.m line 268 does.

Nits

None.

Test gaps

  • In test_pop_chanedit_protects_reference_and_backup_index_in_gui (tests/test_phase1b_file_edit_pop_functions.py,
    assert widgets["field_urchan"].text() == ""
    widgets["next1"].click()
    assert widgets["field_urchan"].text() == "2"
    finally:
    ), click widgets["back1"] after widgets["next1"] and assert widgets["field_urchan"].text() == "1".
  • Add an assertion that opening pop_chanedit_dialog_spec after pop_chanedit(eeg, "changefield", [1, "radius", 0.65]) displays "0.65" in field_radius rather than recomputing "0.50669" from X, Y, Z.

EEGLAB parity notes

  • Rendering field_ref and field_urchan as centered QLabel widgets while measuring them as "edit" controls in supergui (display_as_text=True) matches EEGLAB pop_chanedit.m lines 354 to 356 and 421 to 422 (comeval switching chanediturchan and chaneditref from edit to text after supergui layout).
  • Starting channel 1 field_urchan as "" matches pop_chanedit.m line 347 (~isfield(chans, 'urchans')), allowing SHOWN_VALUES in tests/test_gui_geometry.py to be removed cleanly. Addressing the two items above will align subsequent channel navigation and coordinate display with pop_chanedit.m as well.

Tests run

  • PYTHONPATH=<worktree>/src:<worktree> .venv/bin/python -m pytest <worktree>/tests/test_gui_geometry.py <worktree>/tests/test_phase1b_file_edit_pop_functions.py: 170 passed, 33 skipped (32 Linux-only MATLAB reference pixel checks, 1 MATLAB engine check), 10 deselected in 12.34s.
  • PYTHONPATH=<worktree>/src:<worktree> .venv/bin/python -m pytest <worktree>/tests/test_phase2_file_channel_location.py: 15 passed, 25 deselected in 1.51s.
  • .venv/bin/ruff check and .venv/bin/ruff format --check on the 5 modified Python files: all passed.

@arnodelorme
arnodelorme changed the base branch from agent/issue-925-comments to develop December 1, 2026 19:14

This branch has not been deployed

No deployments
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_chanedit: Display the channel reference and original index as read-only fields

1 participant