Skip to content

[GUI] Add Enter comments button and bold labels to pop_importdata - #759

Merged
arnodelorme merged 2 commits into
developfrom
agent/20261127-fix-756
Nov 27, 2026
Merged

arnodelorme merged 2 commits into
developfrom
agent/20261127-fix-756

Conversation

@claude

@claude claude Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

The pop_importdata window now has EEGLAB's Enter comments button next to About this dataset, which opens the pop_comments editor and keeps the text on the button, and shows Data sampling rate (Hz) and Channel location file or info in bold. Run_dialog_action updates now store values on value-holding pushbuttons instead of relabelling them. Adds an offscreen Qt test of the button.

Fixes #756
Part of #737

🤖 Generated with Claude Code

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

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 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @claude[bot]'s task in 1m 20s —— View job


Code review

  • Overall assessment: Needs one fix. The button wiring, the bold labels and the _run_dialog_action change look right. Multi-line comments, which this PR makes possible for the first time, produce a broken history command.
  • Highest-risk area: pop_importdata history and com when the comment has more than one line.
  • Merge recommendation: Needs changes.

Blocking

None.

Important

  • pop_importdata._history_command writes a raw newline into the 'comments' literal (src/eegprep/functions/popfunc/pop_importdata.py, _edit_comments → _history_command). The old QLineEdit could not hold \n, but pop_comments uses a QTextEdit. For the text in the new test, EEG['history']/com becomes ... 'comments', 'line one⏎line two');, which can't be replayed in MATLAB or Python and breaks LASTCOM/ALLCOM. pop_comments._history_comments_value already solves this by emitting a cell of lines.
    Fix: reuse that formatting for comments in pop_importdata, ideally by moving the helper to _pop_utils. See the inline comment for details.

Nits

None.

Test gaps

  • test_pop_importdata_enter_comments_button_opens_pop_comments already enters two lines but checks only eeg['comments']. Call with return_com=True and assert that com has no raw newline and keeps both lines. That assertion would have caught the issue above.

EEGLAB parity notes

None. EEGLAB's pop_importdata.m stores the comments in figure userdata through an Enter comments button that calls pop_comments(..., 'Edit comments of current dataset'), and shows the sampling-rate and channel-location labels in bold. The new spec matches that. I couldn't open the vendored .m file because src/eegprep/eeglab/ is not in this checkout, so this comparison is from the upstream source.

What I checked: the _run_dialog_action change against its other callers (pop_chanedit, pop_rejmenu). Their update() targets are edits and text widgets, not pushbuttons with a stored value, so they behave as before. I also checked that the pushbutton value='' initialisation makes _read_widget return the stored text, that the row and geometry count is unchanged, that cancelling pop_comments keeps the previous text, and the changelog entry.



def _edit_comments(values, update):
update({'comments': pop_comments(values['comments'], 'Edit comments of current dataset')})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Important: multi-line comments now produce a history command that won't parse.

Before this PR, comments came from a single-line QLineEdit, so it could never contain \n. Now pop_comments returns text from a QTextEdit, and _history_command passes it through format_history_value, which only wraps the string in quotes:

"ref",
"comments",
"chanlocs",
"icaweights",
"icaweight",
"icasphere",

For the text in the new test ('line one\nline two'), EEG['history'] and the returned com contain a raw newline inside a quoted literal:

EEG = pop_importdata(..., 'comments', 'line one
line two');

That can't be replayed in MATLAB or Python, and it breaks LASTCOM/ALLCOM and exported scripts. pop_comments already handles this case by emitting a cell of lines:

def _history_comments_value(comments: str) -> str:
if "\n" not in comments:
return format_history_value(comments)
lines = [line if line else " " for line in comments.split("\n")]
return format_history_value(lines, cell_for_sequence="always")

Suggested fix: format comments in pop_importdata._history_command the same way, for example by sharing _history_comments_value (moving it to _pop_utils would avoid a cross-module private import). Also extend test_pop_importdata_enter_comments_button_opens_pop_comments to call with return_com=True and check that com stays on one line and round-trips the two lines.

@arnodelorme

Copy link
Copy Markdown
Collaborator

The review bot found that a comment of several lines, now possible because the Enter comments button opens the pop_comments text box, wrote a raw line break into the history command, so LASTCOM, ALLCOM and exported scripts could not be replayed. Commit c87cb15 moves the formatting pop_comments already used into _pop_utils (format_history_comments), uses it in pop_importdata's history so the comments become a cell of lines, and lets pop_importdata accept that cell when the command is replayed. The test now calls the dialog with return_com=True, checks the command stays on one line, and replays it.

The new check fails on the previous commit and passes now. The touched test files pass (test_stream9_gui_importers, test_pop_comments, test_pop_utils, test_stream9_import_options: 48 passed); a wider run of 13 related test files shows the same 30 failures before and after the change, all from onnxruntime missing in this local environment. This pull request is the one to keep for issue #756; #757 does the same job and has the same history problem.

— orchestrator

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_importdata window: Enter comments button and two bold labels as in EEGLAB

1 participant