Repository navigation
Description
Phase 2 of #324.
Base: epic/324-pyodide-browser.
Depends on: phase 1.
Blocks: phase 3 and phase 5.
Parallel with: phase 4.
Why
This phase is the epic's go/no-go gate.
Two commitments in #324 rest on numbers nobody has measured yet:
that picard should be the browser default ICA, and that routing matmuls through scipy.linalg.blas under Emscripten is worth a code change.
Measure both before building on either.
It also converts phase 1's static resolution check into a live one: does micropip.install("eegprep") actually work, and does a real pipeline run.
Scope
Build the harness:
tools/pyodide/runner that boots Pyodide under node,micropip-installs the wheel built from the working tree, and executes a Python script inside it.
Keep it out of the installed package;tools/is not shipped.
Add a CI job to .github/workflows/test.yml:
- build the wheel, install it under Pyodide, import
eegprep, and run a short continuous-data pipeline onsample_data. - The job must fail on a resolution error, not skip.
Benchmark and publish:
- ICA wall clock at 64 channels x 60 s x 250 Hz, for
runicaandeeg_picard, native and Pyodide, reporting iterations to convergence as well as seconds.
Iteration count is the number that actually justifies picard on a single WebAssembly thread; wall clock alone hides it. - A matmul microbenchmark at the shapes runica's inner loop actually uses, comparing
numpy@againstscipy.linalg.blasdgemm/sgemm, native and Pyodide.
Take the shapes fromrunica.py:684and:692, which are(ncomps, ncomps) @ (ncomps, block)and(ncomps, ncomps) @ (ncomps, ncomps). - Commit the results as a Markdown table under
docs/source/and publish the raw output as a CI artifact.
What the numbers decide
Record the answers on #324, because later phases read them:
- Does picard's iteration advantage survive Pyodide, and by how much?
Confirms or overturns the recorded decision to default to picard in the browser. - Is the
scipyBLAS path materially faster than numpy@at runica's shapes under Emscripten?
If the gap is small, phase 3 shrinks to a documentation note and should say so rather than ship a helper nobody needs.
Known complication the benchmark must surface
eeg_picard.py delegates to the third-party picard package, and picard's hot matmuls live inside it, not in eegprep: picard/_core_picard.py:84, :163, :206, :207, and picard/_tools.py:70, :71, :84, :86.
eegprep's own file has only two cheap post-processing matmuls at eeg_picard.py:63 and :65.
So no eegprep-side BLAS helper can speed up picard's inner loop.
Benchmark picard as it actually is, and report that constraint explicitly so phase 3 scopes honestly.
Non-goals
No BLAS helper implementation; that is phase 3 and only if the numbers justify it.
No ICLabel work.
No attempt to patch or vendor python-picard.
Acceptance criteria
-
tools/pyodide/harness runs locally with one documented command. - CI job installs the built wheel under Pyodide via
micropipand fails loudly on resolution errors. - CI runs an importable smoke pipeline on
sample_dataunder Pyodide. - Benchmark covers runica and picard, native and Pyodide, reporting both seconds and iterations to convergence, at 64 ch x 60 s x 250 Hz.
- Matmul microbenchmark covers numpy
@versusscipy.linalg.blasat runica's real inner-loop shapes. - Results committed as a Markdown table under
docs/source/and published as a CI artifact. - Both decisions above answered in a comment on Epic: eegprep in the browser (Pyodide) with a small ONNX ICLabel #324.
- Pyodide version pinned explicitly, with the pin and the reason recorded.
- Pre-commit, ruff, ruff format, ty clean; existing suite unaffected.
/goal prompt
/goal Prove what eegprep actually does under Pyodide and produce the numbers that decide phases 3 and 5.
Source of truth: the built wheel from this working tree, sample_data, runica.py:684 and :692 for inner-loop shapes, and the picard call sites listed on the issue. Read AGENTS.md first.
Constraints: tools/ is developer tooling and must not be installed as part of the package; do not implement a BLAS helper in this phase; do not patch or vendor python-picard; pin the Pyodide version explicitly.
Finish line: the CI job installs the wheel under Pyodide and runs a smoke pipeline; the benchmark table is committed under docs/source/ with seconds and iteration counts for runica and picard, native and Pyodide; the matmul microbenchmark is committed; and you have posted a comment on #324 answering, with numbers, whether picard keeps its advantage in the browser and whether the scipy BLAS path is worth a code change.
If the numbers contradict either recorded decision, say so plainly in the comment rather than working around them. Report any review finding you chose not to fix, with the reason.
Activity
neuromechanist commentedon Sep 17, 2026
🤖 Added scope to this phase from a blocker phase 1 uncovered.
docoptis sdist-only and blocksmicropip.install("eegprep").pybids -> num2words -> docopt, anddocopt0.6.2 publishes no wheel at all on PyPI, onlydocopt-0.6.2.tar.gz. Verified against the PyPI JSON API. micropip installs wheels and does not build sdists, so the base requirement set still cannot resolve in the browser even after phase 1 removedoct2py,psutil, andpyedflib.num2wordsdeclaresdocoptunconditionally although only its own command line entry point uses it, so nothing in eegprep's import path ever touches it.Decision: pre-install a built
docoptwheel from this phase's harness.docoptis pure Python, so building apy3-none-anywheel from the sdist once and installing it ahead ofeegprepis the cheapest fix. It keepspybidsin the base install, which matters because NEMAR datasets are BIDS and the assistant needs to load them.Rejected alternatives, recorded so they are not relitigated: moving
pybidsto a[bids]extra would cost BIDS loading in the browser, and fixingnum2wordsupstream is the correct long-term answer but would gate this epic on an external maintainer. Worth opening upstream separately.Add to this phase's scope and acceptance criteria:
docoptwheel and installs it beforeeegprep.micropip.install("eegprep")succeeds end to end under the harness. This is the real version of phase 1's gate, which Phase 1: Move oct2py, psutil, and pyedflib out of the base install #374's static check could only approximate.tools/check_pyodide_base_resolution.pyhas itsdocoptentry moved out ofKNOWN_GAPSonce the harness handles it, so the script stops passing over a live blocker.Note for the phase agent: #374's check script currently reports
docoptas a non-blocking known gap and still exits 0. Do not treat a green run of that script as evidence the browser install works.neuromechanist commentedon Sep 17, 2026
🤖 # Research
The live browser gate is missing:
.github/workflows/test.ymlonly runs Python checks formaster/develop, whiletools/check_pyodide_base_resolution.pytreatsdocopt==0.6.2as non-blocking even though its sdist cannot be installed by micropip.runicareports its effective training iterations through the returned learning-rate history, and the installedpython-picard==0.8.2API exposesreturn_n_iter=True; neither production path needs modification.Relevant code
tools/check_pyodide_base_resolution.py#L38-L49- current docopt gap.github/workflows/test.yml#L1-L15- current trigger scopesrc/eegprep/functions/sigprocfunc/runica.py#L252-L258- block heuristicsrc/eegprep/functions/sigprocfunc/runica.py#L1290-L1371- iteration historysrc/eegprep/functions/popfunc/eeg_picard.py#L48-L66- exact wrapper configurationProposed Fix
Add a developer-only Node/Pyodide 0.29.5 runner that serves staged local wheels and sample files over localhost, builds a hash-checked pure-Python docopt wheel from the locked sdist before installing the working-tree EEGPrep wheel, and propagates every load/install/script failure. Add smoke and deterministic benchmark scripts, a CI job triggered for both the epic branch and
develop, raw-output artifacts, and a committed results table. Keep the Picard benchmark on its underlyingpicard(..., return_n_iter=True)API with the wrapper parameters, and leave BLAS production work to phase 3.