Skip to content

pop_newset: Show the correct storage options for saved and modified datasets - #1016

Merged
arnodelorme merged 5 commits into
developfrom
agent/issue-938-newset
Dec 1, 2026
Merged

arnodelorme merged 5 commits into
developfrom
agent/issue-938-newset

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Part of #938 and #875. Show the correct storage options for saved and modified datasets. Stacked on #974.

Live MATLAB, EEGPrep before and after

Previous dataset has unsaved changes

Function output distances

Vertical control offsets

Native measurements and validation

With a saved previous dataset the native windows both measure 247 px high. With unsaved changes both measure 273 px, showing an extra filename row that can actually save the previous recording. The largest vertical displacement across both cases was 0.49 px. A native edit, rename and store returned identical samples and metadata when creating a new dataset and when replacing the current dataset. All 10 focused tests passed, including a test writing and reading the requested previous-dataset file. The measured cases used the ordinary in-memory dataset workflow.

Full inventory report for the project team. pop_newset (p. 97). 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

Claude finished @arnodelorme's task in 59s —— View job


Code review

  • Overall assessment: The dialog changes look correct for the saved and modified cases. One silent-ignore path can drop a requested save of the old dataset.
  • Highest-risk area: How _run_gui handles the old dataset's "Save it as file" choice (src/eegprep/functions/popfunc/pop_newset.py:232-233)
  • Merge recommendation: Needs changes (a small fix)

Blocking

None.

Important

  • pop_newset.py _run_gui L232-233: if the "Save it as file" box is ticked but the old-dataset filename field is empty, saveold is silently dropped. A recording that was never saved has no filename, so oldfile starts empty. If the user also keeps Overwrite on, the old recording is replaced in memory without being saved and without any error. Fix: handle it the same way as savenew on L231, using str(result.get("oldfile") or "on").strip() or "on". _save_existing_datasets then raises a clear error instead. I posted this as an inline suggestion.

Nits

  • docs/source/user_guide/scripting_workflows.rst: the new paragraph about the GUI dialog sits at the end of the scripting Guardrails section, where it reads like part of the scripting checklist. It would fit better near the pop_newset usage on L80-84, or in src/eegprep/resources/help/pop_newset.md, which already documents saveold and savenew.

Test gaps

None. The parametrized GUI test covers both saved states, checks the prefilled old filename and the enable toggle, and confirms the file is written and the history command is recorded.

EEGLAB parity notes

  • The vendored src/eegprep/eeglab tree is not in this checkout, so I could not compare line by line against pop_newset.m.
  • The three prompt strings match EEGLAB's wording for the not-modified, STUDY and unsaved-changes cases. So does the extra "Save it as file" row shown only when saved == "no", which means "justloaded" is treated as unmodified.
  • The default Overwrite value depends on storedisk_enabled() when the old dataset has changes. This deserves a quick check against pop_newset.m during the reference/parity run. Note that docs/source/user_guide/eegbrowser.rst:108 says "The dialog's default is a new dataset", which is no longer always true when storedisk is enabled.

Checked: correctness of the new previous/study plumbing, the dialog geometry and control counts, the saveold save path, the new test, and AGENTS.md compliance.

Comment on lines +232 to +233
if is_on(result.get("saveold")) and result.get("oldfile"):
gui_options["saveold"] = str(result["oldfile"])

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.

Important: a checked "Save it as file" with an empty filename is silently ignored

if is_on(result.get("savenew")):
gui_options["savenew"] = str(result.get("savefile") or "on").strip() or "on"
if is_on(result.get("saveold")) and result.get("oldfile"):
gui_options["saveold"] = str(result["oldfile"])
return gui_options

oldfile is pre-filled from _dataset_filename(previous) (L173). A recording that was never written to disk has no filename, so the field starts empty. The PR measurements used this ordinary in-memory workflow. If the user ticks the old-dataset "Save it as file" box, leaves the field empty and also ticks Overwrite, saveold is dropped here. The old recording is then replaced in memory without being saved and without an error, which loses the user's unsaved changes.

Suggested fix: handle this the same way as savenew on L231. An empty field then becomes "on", and _save_existing_datasets raises saveold requires the existing dataset to have filename and filepath instead of discarding the request:

Suggested change
if is_on(result.get("saveold")) and result.get("oldfile"):
gui_options["saveold"] = str(result["oldfile"])
if is_on(result.get("saveold")):
gui_options["saveold"] = str(result.get("oldfile") or "on").strip() or "on"

@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 for two GUI workflow gaps (STUDY forwarding from GUI actions and CURRENTSET list handling in pop_newset).
  • Highest-risk area: STUDY forwarding in src/eegprep/functions/guifunc/menu_actions.py and src/eegprep/functions/popfunc/pop_newset.py, plus CURRENTSET list handling when dataset 1 has unsaved changes.
  • Merge recommendation: Needs changes.

Blocking

None.

Important

  1. Important (src/eegprep/functions/guifunc/menu_actions.py _commit_processed_dataset_from_gui, src/eegprep/functions/popfunc/pop_newset.py _command_options, docs/source/user_guide/eegbrowser.rst):
    pop_newset_dialog_spec and _run_gui add study handling (

    elif study:
    prompt = "The old dataset has not been modified since last saved. What do you want to do with it?"
    else:
    prompt = "What do you want to do with the old dataset (not modified since last saved)?"
    geometry.extend([(1,), (1,), (0.15, 1.8, 0.1, 0.1)])
    controls.extend(
    (
    ControlSpec("spacer"),
    ControlSpec("text", prompt, font_weight="bold"),
    ControlSpec(
    "checkbox",
    "",
    tag="overwrite",
    value=study or (previous_modified and storedisk_enabled()),
    enabled=not study,
    ),
    and
    pop_newset_dialog_spec(
    EEG,
    CURRENTSET,
    guistring=str(options.get("guistring") or ""),
    previous=previous,
    study=is_on(options.get("study", False)),
    ),
    renderer=renderer,
    ), and docs/source/user_guide/eegbrowser.rst (
    ``ALLEEG``, and history synchronized. Rejecting marked data from the GUI menu
    records ``eeg_eegrej`` or ``pop_rejepoch`` and then opens the dataset dialog
    (``pop_newset``). The dialog defaults to a new dataset unless a ``STUDY`` is
    active or ``option_storedisk`` is enabled with unsaved changes, where
    overwriting in memory is checked. Cancel discards the rejection. A console
    ``pop_eegplot`` call stores the returned dataset directly.
    ) states that rejecting marked data from the GUI menu opens pop_newset with overwriting checked when a STUDY is active. However, MenuActionDispatcher._commit_processed_dataset_from_gui (
    newset_options = (
    {"study": int(bool(self.session.STUDY))}
    if isinstance(eeg, list)
    else {"gui": "on" if gui else "off", "overwrite": "off" if gui or new else "on"}
    )
    alleeg, current, current_set, newset_command = pop_newset(
    self.session.ALLEEG,
    eeg,
    old_currentset,
    **newset_options,
    )
    ) only passes "study": int(bool(self.session.STUDY)) when isinstance(eeg, list). When eeg is a single dict (all GUI menu actions and EEGBrowser rejections that open the dialog), "study" is omitted, so options.get("study", False) is always False. Even when a STUDY is active, the STUDY prompt is never shown, and overwrite stays unchecked and enabled (unlike EEGLAB eeglab.m L515 and eeglab_new.m L52, which always pass 'study', ~isempty(STUDY)+0).
    Suggested fix: pass "study": int(bool(self.session.STUDY)) in the dict branch of _commit_processed_dataset_from_gui as well, and drop "study" from _command_options (
    command_options = {}
    for key in ("setname", "comments", "overwrite", "saveold", "savenew", "study"):
    if key in options and _has_value(options[key]):
    command_options[key] = options[key]
    if command_options.get("overwrite") == "off":
    command_options.pop("overwrite", None)
    return command_options
    ) so history strings for one dataset match EEGLAB pop_newset.m L567 without adding 'study', 0 or 'study', 1 (retrieve and isinstance(EEG, list) already handle "study" on L48 and L73).

  2. Important (src/eegprep/functions/popfunc/pop_newset.py pop_newset L51 to L55):
    pop_newset resolves previous using _first_currentset(CURRENTSET) (

    if is_on(options.get("gui", False)) and isinstance(EEG, dict):
    previous_index = _first_currentset(CURRENTSET)
    previous = alleeg[previous_index - 1] if previous_index and previous_index <= len(alleeg) else None
    gui_result = _run_gui(EEG, CURRENTSET, options, previous, renderer=renderer)
    if gui_result is None:
    ) even when CURRENTSET selects multiple datasets (for example [1, 2] before Edit > Append datasets / pop_mergeset, which commits one merged dict). In MATLAB EEGLAB (functions/popfunc/pop_newset.m L215), saved = 0 and filenameold are only set when length(OLDSET) == 1. Here, if dataset 1 has saved == "no" while CURRENTSET == [1, 2], the dialog displays the saveold row prefilled with dataset 1's path, and checking saveold makes _save_existing_datasets (
    if explicit_target and len(indices) != 1:
    raise ValueError("saveold with multiple datasets requires each dataset to have filename metadata")
    ) raise ValueError: saveold with multiple datasets requires each dataset to have filename metadata.
    Suggested fix: only resolve previous on L52 and L53 when CURRENTSET refers to one dataset (not a list or tuple with len(CURRENTSET) > 1), matching pop_newset.m L215.

Nits

None.

Test gaps

  • Add a GUI session test verifying that committing one processed dataset when session.STUDY is active opens pop_newset with the STUDY prompt and overwrite checked and disabled, without adding 'study' to the history string.
  • Add a pop_newset GUI test with CURRENTSET=[1, 2] and alleeg[0]["saved"] == "no" verifying that the saveold row is not shown.

EEGLAB parity notes

  • Checked against functions/popfunc/pop_newset.m (L211 to L336 and L428 to L567), eeglab.m (L515), and eeglab_new.m (L52).
  • When CURRENTSET selects one dataset, the three prompts for the old dataset, the supergui row geometry, the saveold row visibility (saved == "no" only, treating "justloaded" and "yes" as unmodified), and the overwrite defaults (study or previous_modified and storedisk_enabled()) match pop_newset.m Cases 6 through 9.
  • Under Case 7 (~saved && option_storedisk, pop_newset.m L268 to L288), MATLAB blocks unchecking both overwrite and saveold inside the dialog, whereas EEGPrep raises RuntimeError: Cannot offload unsaved dataset 1 in eeg_store if the user unchecks overwrite without checking saveold. That fails explicitly without losing unsaved changes.
  • Tests run in a detached worktree at fc14164253428628f25cc3357be14bbf7c0fb7d1: tests/test_pop_newset.py (11 passed), tests/test_eeg_store_storedisk.py (4 passed), and tests/test_stream3_scroll_window.py -k newset (2 passed), plus direct Python reproduction of both findings above.

@arnodelorme
arnodelorme changed the base branch from agent/issue-939-study-geom to develop December 1, 2026 06:54

@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: Looks good.
  • Highest-risk area: None identified.
  • Merge recommendation: Safe to merge.

Blocking

None.

Important

None.

Nits

None.

Test gaps

None.

EEGLAB parity notes

  • Checked against functions/popfunc/pop_newset.m (L211 to L336 and L428 to L567) and eeglab.m (L515).
  • Both findings from the prior review on fc14164253428628f25cc3357be14bbf7c0fb7d1 are resolved: MenuActionDispatcher._commit_processed_dataset_from_gui forwards study for single datasets while _command_options omits study from single dataset history commands (matching pop_newset.m L567), and pop_newset only resolves previous when CURRENTSET refers to one dataset (matching pop_newset.m L215).
  • Prompts, supergui row geometry, saveold row visibility (saved == "no" only), and overwrite defaults (study or previous_modified and storedisk_enabled()) match pop_newset.m Cases 6 through 9.
  • Tests run in a detached worktree at 036a26fd2e33d837fbaf4f3f797eff144b195dd4: tests/test_pop_newset.py (12 passed), tests/test_eeg_store_storedisk.py (4 passed), tests/test_gui_main_window.py filtered on newset or commit_processed_dataset or transform_action (4 passed), tests/test_stream3_scroll_window.py filtered on newset (2 passed), and ruff check plus ruff format check on the modified Python files (all passed).

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

@arnodelorme
arnodelorme merged commit 520de02 into develop Dec 1, 2026
11 of 15 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.

1 participant