Skip to content

[GUI] Load the continuous or epoched sample at console startup - #837

Merged
arnodelorme merged 4 commits into
developfrom
agent/issue-824
Nov 29, 2026
Merged

arnodelorme merged 4 commits into
developfrom
agent/issue-824

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

From a source checkout, run uv run eegprep-console cont or uv run eegprep-console epoch to open the matching sample with dataset 1 selected in the GUI and console (--full is optional). The two sample recordings stay in the repository and are not in the wheel, which is back to 26.7 MB (it was 34.0 MB with them). When they are missing, the console prints how to get them and starts without a dataset.

Continuous sample in EEGLAB and EEGPrep

Epoched sample in EEGLAB and EEGPrep

Maximum difference from MATLAB on both sample recordings

Both recordings matched EEGLAB sample for sample, including 32 channels at 128 Hz. The continuous recording had 154 events, and the epoched recording had 157.

Editable Word report · PDF report

Cause and change

The launcher accepted only flags. It now loads the requested sample through pop_loadset and stores it in the shared session before opening the window.

Verification

249 local GUI and console tests passed. Four reference cases were deselected. Pre-commit, Ruff and ty passed. Both actual launch commands and both corresponding EEGLAB commands ran on jamming. After the recordings were taken out of the wheel (commits 39d95b4 and 7c4f6f6), the built wheel is 26,716,445 bytes and holds no .set and no .fdt file. A clean Python 3.12 environment installed that wheel and ran both real console commands outside the checkout: each printed the message that names git clone https://github.com/sccn/eegprep and uv run eegprep-console cont, opened the console without a dataset and ended with status 0. tests/test_console_workspace.py gives 115 passed. No number changes, so no EEGLAB parity run is needed for this packaging change. Windows CI reports the pre-existing one-pixel Qt row check #834, addressed by #835. Windows job.

Decision taken by Arno

The two recordings are kept out of the default wheel. They are loaded only from a source checkout (or an editable install), where sample_data sits beside src/eegprep. The new arguments apply to eegprep-console.

Fixes #824

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

Copy link
Copy Markdown
Contributor

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


Code review

  • Overall assessment: The launcher change is small and the test covers the source-checkout path. The way sample data reaches an installed wheel needs to change before merge.
  • Highest-risk area: Packaging and lookup of the sample .set/.fdt files outside a source checkout.
  • Merge recommendation: Needs changes.

Blocking

None.

Important

  • The installed-wheel lookup misses some install types (console.py run_console, pyproject.toml [tool.setuptools.data-files]). Details are in the inline comment.
    • pip writes data-files to the active install scheme. The code looks them up with sysconfig.get_path("data"), which uses the interpreter's default scheme. With pip install --user the two disagree, and eegprep-console cont fails with a raw FileNotFoundError.
    • Setuptools marks data-files in pyproject as deprecated.
    • Path(__file__).parents[4] is a guess about directory layout.
    • Every other runtime asset in the package is package data read with importlib.resources.
    • Suggested fix: ship the four files as package data under src/eegprep/resources/sample_data/ and resolve them with files("eegprep.resources").joinpath("sample_data", filename). Then drop sysconfig and the parents[4] probe.

Nits

  • docs/source/user_guide/interactive_console.rst:
    • The new section sits above the page's intro paragraph, so readers see the sample-data shortcut before learning what the console is. Moving it below the intro would read better.
    • The docs always pair the sample with --full, but cont/epoch works without it. Showing eegprep-console cont as the basic form, with --full as optional, would avoid implying the flag is required.

Test gaps

  • test_console_starts_with_sample_dataset only reaches the parents[4] checkout path, so the installed-wheel path is never run. With a single importlib.resources lookup, the existing test would cover the same code that installed users run, and no new test would be needed.

EEGLAB parity notes

  • Size decision for Arno: the four files add about 8.4 MB to every wheel (about 3.9 MB for each .fdt). That works against keeping a plain pip install eegprep lean. EEGLAB also ships sample_data/ inside its distribution, so bundling matches EEGLAB. If wheel size matters, the other option is to fetch the files on first use.
  • No issues found with how the dataset is stored or selected. store_current(..., new=True, mark_saved=True) selects dataset 1 in CURRENTSET, and the history command EEG = pop_loadset('<path>'); matches EEGLAB's form.

Comment on lines +781 to +788
if args.dataset:
filename = "eeglab_data.set" if args.dataset == "cont" else "eeglab_data_epochs_ica.set"
sample = Path(__file__).resolve().parents[4] / "sample_data" / filename
if not sample.is_file():
sample = Path(sysconfig.get_path("data")) / "share" / "eegprep" / "sample_data" / filename
session.store_current(
pop_loadset(sample), new=True, command=f"EEG = pop_loadset({str(sample)!r});", mark_saved=True
)

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: the installed-wheel lookup is fragile and doesn't follow repo convention.

The installed path depends on [tool.setuptools.data-files] (

eegprep/pyproject.toml

Lines 298 to 306 in 8bb71ed

[tool.setuptools.data-files]
"share/eegprep/sample_data" = [
"sample_data/eeglab_data.set",
"sample_data/eeglab_data.fdt",
"sample_data/eeglab_data_epochs_ica.set",
"sample_data/eeglab_data_epochs_ica.fdt",
]
) together with sysconfig.get_path("data"). Two problems:

  1. Paths can disagree. pip writes data-files into the active install scheme's data directory. sysconfig.get_path("data") returns the interpreter's default scheme. With pip install --user eegprep the files go under site.USER_BASE/share/..., but the lookup checks sys.prefix/share/..., so eegprep-console cont raises a raw FileNotFoundError from pop_loadset. Setuptools also marks data-files in pyproject as deprecated.
  2. parents[4] is a layout guess. In a source checkout it resolves to the repo root. In site-packages it resolves to lib/pythonX.Y. That only works because the fallback happens to catch it.

The rest of the package ships runtime data as package data and reads it with importlib.resources, e.g. extension_catalog.py, EEG_BIDS/montage.py, and the ICLabel ONNX model. AGENTS.md says the same: "make them EEGPrep-owned packaged resources."

Suggested fix: Put the four files under src/eegprep/resources/sample_data/, or symlink or copy them at build time if sample_data/ has to stay at the root for EEGLAB naming. Add "resources/**/*.set" and "resources/**/*.fdt" to [tool.setuptools.package-data], drop data-files, sysconfig, and the parents[4] probe, and resolve with:

sample = files("eegprep.resources").joinpath("sample_data", filename)

That gives one lookup that works in editable, venv, --user, pipx, and conda installs. A test that loads through files(...) would then cover the installed layout as well, not only the checkout path.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Review (Claude Fable): needs Arno

  • The launcher change is correct and small. 14 lines in console.py load the same two files as eeglab cont and eeglab epoch (eeglab.m lines 438 to 450) and store them through the shared session. I re-ran both commands from a checkout and from the built wheel in a clean Python 3.12 environment: both open with dataset 1 selected.
  • Decision for Arno: ship the two recordings in every wheel or not. The wheel grows from 26.7 MB to 34.0 MB (+7.25 MB, +27%), also for micropip.install("eegprep") in the browser. The other choices are checkout only (your request was uv run --no-sync eegprep-console --full, and that needs no packaging lines at all) or a download on first use. Issue eegprep-console: start with the sample epoched or continuous dataset, like eeglab epoch and eeglab cont #824 asked this question and has no answer from you yet.
  • If the wheel option stays, one fix is needed. With pip install --target (and --user, same mechanism) the sample is not found, and the error then says the file "is not a valid MATLAB .set dataset", which is wrong and gives no fix.
  • CI and conflicts. All checks pass except Windows, which fails on the known one pixel row test (test_window_without_a_height_is_as_high_as_its_rows fails on Windows (57 vs 56) #834, not touched here). It merges cleanly with develop and with [GUI] Read BioSig files with the optional Python BioSig library #857, the only other open pull request that touches one of its files.
Details

What I ran

  • tests/test_console_workspace.py at head 8bb71ed1: the two new cases pass. 85 of 112 tests pass locally. The 27 others all stop on ModuleNotFoundError: onnxruntime in my local environment (ICLabel tests), and they pass in CI on Ubuntu and macOS.
  • Built the wheel: 33,967,191 bytes, of which the four sample files take 7,250,100 compressed. This matches the number in the pull request.
  • Installed that wheel in a clean environment and ran run_console(["cont"]) and run_console(["epoch"]) outside the checkout: (32, 30504) with 154 events and (32, 384, 80) with 157 events, 128 Hz, CURRENTSET 1, saved yes.

The lookup that misses

[tool.setuptools.data-files] lets pip put the files in the data folder of the install scheme it uses. The code reads sysconfig.get_path("data"), which is the default scheme of the interpreter. They agree in a virtual environment, in conda, with pipx and with uv tool. They do not agree with --target (I checked: the files land in <target>/share/eegprep/sample_data) nor with --user (same mechanism, not run here so as not to touch the user site). I simulated the miss, and the message is:

ValueError: pop_loadset: '.../share/eegprep/sample_data/eeglab_data.set' is not a valid MATLAB .set dataset (MAT file). Re-export the dataset from its source or restore an intact copy.

Smallest fix: after the two candidates, test sample.is_file() once and raise a FileNotFoundError that names eegprep-console, the two folders searched and what to do. A more robust lookup is importlib.metadata.files("eegprep") with .locate(), which follows whatever scheme pip used.

I do not recommend the package data move proposed in the automatic review (copy the files under src/eegprep/resources/sample_data). It either duplicates 8 MB in git or moves files that many tests read from sample_data/. That is a larger change than this pull request.

Parity with EEGLAB

  • Same two files, same store step (eeg_store with a new index), same selected dataset.
  • EEGLAB also accepts continuous, and any letter case for cont. The pull request accepts only cont and epoch. Small, and the issue named only these two.
  • EEGLAB writes no history line for eeglab cont. EEGPrep records EEG = pop_loadset('<absolute path>');, which is useful for replay. The File menu writes the two key form pop_loadset('filename', ..., 'filepath', ...) (menu_actions.py line 586). Using the same form here would keep one history style. Not blocking.
  • Only eegprep-console takes the argument. eegprep-gui cont and the Python eeglab('cont') do not. This matches the request as written. Arno may want them later, in another issue.

Minimal

52 lines in 4 files, no refactoring. The checkout only variant would drop the 8 lines of pyproject.toml, the sysconfig import and the second lookup.

Tests and docs

  • The new test uses the stub launcher already used in this file and checks the shape, the selection and the history line. It covers the checkout path only. The installed path has no test in CI, which is one more reason for a clear error when the file is missing.
  • The new docs section sits above the introduction of the page. It reads better below the first paragraph.

What the pull request shows (rules 27 and 29)

Summary on top, two side by side captures (EEGLAB and EEGPrep, continuous and epoched), the difference figure, and the Word and PDF reports, which both exist at the linked paths. There is no "before" capture, which is normal since the command did not exist. Rules 23, 26 and 34 do not apply: no dialog layout code is touched.

— orchestrator review

arnodelorme and others added 2 commits November 28, 2026 23:36
@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Code review

This is an independent review by Codex (OpenAI, model gpt-6.1-terra, high reasoning effort), run read only on commit 39d95b4e, which takes the two sample recordings out of the wheel. The code itself was written by Claude Fable. Codex found nothing blocking and three important points. Two are fixed in commit 7c4f6f69, and one is left as it is, with the reason below.

What was fixed after the review

  • An unrelated sample_data folder can no longer be loaded. The recordings are now loaded only when the folder src/eegprep sits beside sample_data, which is true in a source checkout and in an editable install, and never beside an installed package.
  • A .set file without its .fdt file no longer stops the console. Both files must be there. If one is missing, the console prints the message and starts without a dataset.
  • Tests. The missing data test now runs on three layouts with the real recording: no folder, a sample_data folder outside a checkout, and a checkout without the .fdt file. The two new cases fail on 39d95b4e and pass on 7c4f6f69. The whole file gives 115 passed.

What was left, and why

  • The message names uv run. This is the way the README and the documentation start the console from a checkout, and the message already gives a second way that needs neither git nor uv: download the two files and open the .set file with File > Load existing dataset.
  • The tests use the stub window and the stub shell. Every run_console test of this file does the same. The real command was run by hand instead: the wheel of 7c4f6f69 was installed in a clean Python 3.12 environment, and eegprep-console cont and eegprep-console epoch both printed the message, opened the console and ended with status 0.
  • The built wheel was inspected by hand. It is 26,716,445 bytes (26.7 MB, as on develop, against 34.0 MB before) and holds no .set and no .fdt file.

This change is packaging and one message. It moves no number, so no EEGLAB parity run is needed.

The review of Codex, as written

Overall assessment

Needs changes: the lookup can load an unrelated recording, and a missing .fdt file prevents the console from starting. The packaging configuration excludes the recordings and the warning should appear on stderr through the real entry point, but I could not build a wheel or run the GUI in this read only environment.

Blocking

None.

Important

  • console.py:46: The path is correct in a source checkout and an editable install pointing to it. In a normal virtual environment or pip install --user, it points to lib/pythonX.Y/sample_data, while pip install --target /tmp/target points to /tmp/sample_data. An unrelated matching file there can be loaded as the requested sample. Restrict automatic lookup to a verified source checkout and otherwise report the sample as missing.

  • console.py:795: Only the .set is checked. If its .fdt is missing, pop_loadset raises before the GUI starts, so the promised empty startup and exit status 0 do not occur. Check both files for these known samples before loading and issue the missing data message if either is absent.

  • console.py:50: The clone and run commands are valid when Git and uv are installed, but a user who installed with pip may not have uv. State that requirement and how to install it, or give a working pip based route. The same assumption appears in interactive_console.rst:60.

Nits

None.

Test gaps

  • test_console_workspace.py:2112: The tests load real recordings, but replace the GUI and shell with fakes outside the permitted filesystem or network boundaries. Use a real GUI and entry point test with controlled shutdown to verify dataset 1, the warning, empty startup, and exit status for both modes.

  • test_console_workspace.py:2129: Add cases for a present .set with missing .fdt, and for an unrelated sample_data directory in an installed layout.

  • pyproject.toml:267: Build a clean wheel and inspect its archive for all .set and .fdt recordings. The current package data, data files, and manifest settings do not include them, but configuration inspection alone does not verify the built artifact.

— orchestrator

@arnodelorme
arnodelorme merged commit ceba6c0 into develop Nov 29, 2026
12 checks passed
@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 I merged this pull request into develop, at Arno's request.

Why. Arno wrote on November 28 "Yes, it only installs with a pip install --full, not by default. Make the necessary change then merge", and on November 29 "It's fine, we should only be added with --full", with the standing instruction to merge once the fix is in and another AI has checked it.

Why it was good to merge. The two sample recordings are out of the wheel and load from a source checkout only, which is the first half of his sentence. The review by Codex found nothing blocking. I merged develop into the branch this morning (head 2a0d699), and every check of that head passed, the one-hour Pyodide check included.

What is not done here. With pip install "eegprep[full]" the recordings are still not installed, because an extra can add packages and not files of the same wheel. The three ways to do it, with what each costs, wait for Arno's choice in the new issue eegprep-console cont and epoch: bring the two sample recordings with the full extra.

— 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.

eegprep-console: start with the sample epoched or continuous dataset, like eeglab epoch and eeglab cont

1 participant