Skip to content

[GUI] Separate the EEG export filename and format dialogs - #951

Open
arnodelorme wants to merge 4 commits into
agent/issue-875-file-chaneventfrom
agent/issue-875-file-writeeeg
Open

arnodelorme wants to merge 4 commits into
agent/issue-875-file-chaneventfrom
agent/issue-875-file-writeeeg

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

The public export first asks whether to concatenate epoched data, then opens the save chooser and the EDF/GDF/BDF list. Cancellation at each stage returns an empty command. The Help button opens the packaged format help. Stacked on #923 (agent/issue-875-file-chanevent).

Save chooser, MATLAB and EEGPrep before and after

Format or settings window, MATLAB and EEGPrep before and after

Native height differences and histogram of normalized numerical distances

Measurements and verification

Native client geometry on jamming was 276.8 × 183.3 px in MATLAB, 417 × 223 before and 276 × 183 after. Screenshots use each toolkit’s captured frame. BIOSIG read back both writers’ EDF, BDF and GDF outputs from the same continuous sample. MATLAB padded to 30,592 samples. EEGPrep preserved 30,504. The histogram compares the overlapping 32 EEG channels only. Its normalized distances were 3.69e-5, 1.54e-5 and 7.90e-8. BIOSIG also exposed an additional event channel for MATLAB EDF. It reported 128 Hz for MATLAB and 128.00044 Hz for the EEGPrep EDF and BDF headers. The Qt list scrolls to the last format on Linux. The focused File menu run passed 246 tests (six deselected). Both source trees passed the capture safeguards.

Closes #952. Part of #875.

Full inventory report for the project team. pop_writeeeg (p. 20). PDF · Editable Word.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 Review before taking this out of draft.

State. The updated parent (#923) is merged in (9498a72d1). On the Mac 227 tests pass and jamming passes 295 geometry tests.

What I checked against pop_writeeeg.m. The order is now the one of EEGLAB: the question about epochs, then the file chooser, then the format list with geometry [1 1] and geomvert [1 2.5]. The file filter and the titles match.

Findings, none blocking.

  1. When the question about epochs is closed without an answer, EEGLAB goes on (it only stops on "No"). EEGPrep stops. I find the EEGPrep choice safer, it only needs to be a known difference.
  2. The format list has no recorded geometry case, unlike the other forms of this chain.
  3. The two new tests replace questdlg2 and the file chooser with monkeypatch. These are modal windows, so I accept it, but it is the limit of the no mock rule.

Verdict: ready for review.

@arnodelorme
arnodelorme marked this pull request as ready for review December 2, 2026 05:49

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

Copy link
Copy Markdown
Contributor

Claude finished @arnodelorme's task in 1m 24s —— View job


Code review

  • Overall assessment: Needs one small change. The order of the dialogs matches EEGLAB pop_writeeeg.m lines 52–74: epoch question, then file chooser, then the format form (geometry [1 1], geomvert [1 2.5], title and Help). Every cancel returns "". I also checked the history command, the BDF warning, the menu entry (menu_actions.py:843) and the spec callers in tests.
  • Highest-risk area: the format list does not follow the extension the user typed in the file chooser.
  • Merge recommendation: Needs changes, but only a small one.

Blocking

None.

Important

_writeeeg_dialog (pop_writeeeg.py:139): if the file name has an extension, the default format can make the export fail. The list always opens on EDF. If the user types rec.bdf (or .gdf) and clicks Ok, the extension check at pop_writeeeg.py:73-77 raises TYPE EDF does not match the extension .bdf. This happens after all three dialogs, when the file chooser can no longer be changed. Before this PR, the name and the format were in the same form, and EEGLAB never fails here. Fix: set the default listbox value from the chosen suffix (_FORMATS.index(suffix) + 1, or 1 when the suffix is not a known format) and add one .bdf case to the test. Details are in the inline comment.

Nits

  • tests/test_stream10_export_bids.py:298: from importlib import import_module is a local import inside the test. AGENTS.md says: "All imports go at the top. No local imports except for circular dependency breaks or optional dependency guards." Move it to the top of the module.
  • pop_writeeeg.py:118: the PySide6 error does not name the function that hit it. The review standard asks for the function name and the exact fix. Use something like "pop_writeeeg: the file chooser requires PySide6. Install it with pip install eegprep[gui].".

Test gaps

The test never closes the epoch question with "". See the parity note below.

EEGLAB parity notes

pop_writeeeg.py:127: EEGLAB only stops on an explicit No (if strcmpi(res, 'No'), return; end). If the question is closed, EEGLAB carries on to the file chooser. EEGPrep cancels in that case. The PR thread acknowledges this, but the help page does not mention it and no test covers it. Either match EEGLAB with if answer == "No" (one line), or document the difference in pop_writeeeg.md and add a "" answer to the test.

Monkeypatching questdlg2 and QFileDialog is fine. These modal dialogs are a UI I/O boundary, and other File menu tests patch them the same way.

Out of scope, not caused by this PR: the pop_writeeeg branch of _export_filter (menu_actions.py:2123) is never reached, because pop_writeeeg is handled before the else branch that calls it.

Checked for correctness bugs, EEGLAB parity, data structure compatibility, tests for the changed behavior, and AGENTS.md compliance. Two inline comments were posted.

if not filename:
return None
if int(EEG.get("trials") or 1) > 1 and not result.get("concatenate", True):
result = inputgui(pop_writeeeg_dialog_spec(), renderer=renderer)

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: if the file name has an extension, the default format can make the export fail.

The format list always opens on EDF (value=1). If the user types recording.bdf or recording.gdf in the save dialog and clicks Ok, output_type becomes "edf". The extension check at

)
if output_type != path.suffix.lstrip(".").lower():
raise ValueError(
f"pop_writeeeg: TYPE {output_type.upper()} does not match the extension {path.suffix}. "
"Use the same format in TYPE and in the file name."
)
then raises TYPE EDF does not match the extension .bdf. This happens after the user has gone through all three dialogs. Before this PR, the name and the format were in the same form, so the user could fix both before pressing Ok. Now the file chooser is already closed. EEGLAB never fails here, because writeeeg writes whatever name it gets.

Suggested fix: set the default selection from the chosen extension and fall back to EDF otherwise. For example, pass the value into the spec:

suffix = Path(filename).suffix.lstrip(".").upper()
default = _FORMATS.index(suffix) + 1 if suffix in _FORMATS else 1
result = inputgui(pop_writeeeg_dialog_spec(default), renderer=renderer)

Here pop_writeeeg_dialog_spec(value: int = 1) forwards the value to the listbox. Add one case to test_pop_writeeeg_dialog_selects_filename_then_format: a .bdf name with the default selection should write a BDF file.

"Yes",
"Yes",
)
if answer != "Yes":

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.

Nit (EEGLAB parity): closing the epoch question works differently from EEGLAB, and this difference is not documented.

pop_writeeeg.m only stops on an explicit No: if strcmpi(res, 'No'), return; end. If the user closes the question without answering, questdlg2 returns '' and EEGLAB carries on to the file chooser. Here, answer != "Yes" cancels the export. The author's review comment calls this a known difference. However, neither resources/help/pop_writeeeg.md nor the test records it, and the review standard requires an intentional deviation to be documented and covered by a test.

Suggested fix: pick one of these:

  • Match EEGLAB with if answer == "No": return None (one line, and the current test still passes).
  • Keep the safer behavior, add a sentence to the help ("Closing the epoch question cancels the export"), and add a "" answer to the test sequence.

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.

1 participant