Repository navigation
[CI] Fix five EEGLAB reference failures on develop - #691
Conversation
Install Optimization_Toolbox in eeglab-reference.yml and require fminunc explicitly in the coregister and DIPFIT parity helpers so MATLAB no longer falls back to fminsearch. Remove the duplicate +1 offset in the MATLAB kmeans clustering test and restore strict empty-struct parity in assert_matlab_struct_near while adapting pop_copyset empty dicts in the Python reference transport. Fixes sccn#685
arnodelorme
left a comment
There was a problem hiding this comment.
This review was written by an AI assistant during a nightly check, not by Arno.
Code review
- Overall assessment: needs more context. The five diagnoses hold up against the code and against the MATLAB checks listed at the bottom. The fix for three of the five sits in a workflow change that has not run yet.
- Highest-risk area:
.github/workflows/eeglab-reference.ymltogether with the newfminuncguard in the four MATLAB helpers. Only a real run of that workflow exercises them. - Merge recommendation: needs more context (one
eeglab-reference.ymlrun on this branch, linked in the description).
Blocking
None.
Important
1. No reference run on this branch yet (severity: important, .github/workflows/eeglab-reference.yml and the pull request description)
Issue #685 asks, as its definition of done, for a linked eeglab-reference.yml run in which each of the 5 tests passes. GitHub reports no checks on this branch. The workflow is workflow_dispatch only and reads secrets.MATLAB_BATCH_TOKEN, which a fork does not have, so the Optimization_Toolbox line and the guard have never run on the R2024b runner. The description gives "MATLAB R2024a (27 passed, 0 failed)" without the command, the EEGLAB and eeglab_tests commits, or the list of tests.
Two things only that run can show. First, that setup-matlab installs Optimization_Toolbox and the batch token licenses it. Second, that license('test', 'optimization_toolbox') returns true under that token. If it returns false, all four helpers now raise and the core shard gets worse, not better.
Suggested fix: a maintainer dispatches eeglab-reference.yml on a copy of this branch in sccn/eegprep, then the description gets the run link, the two pinned commits, the pass, fail and skip counts and the runtime, as the Testing section of AGENTS.md asks.
Nits
1. The guard also blocks the grid case, which needs no optimizer (tests/matlab/eegprep_dipfit_component_parity.m)
eegprep/tests/matlab/eegprep_dipfit_component_parity.m
Lines 4 to 7 in 2680844
The guard sits above the kind dispatch. For kind = 'grid' the helper only calls ft_inside_headmodel and returns (lines 24 to 30). test_inside_brain_grid_counts_match_eeglab passes today on a MATLAB without the Optimization Toolbox and would raise after this change. Suggested fix: move the guard to just before the pop_multifit call.
2. The guard does not ask the question FieldTrip asks (the four helpers in tests/matlab/)
The guard uses exist('fminunc', 'file') and license('test', ...). FieldTrip picks its optimizer with ft_hastoolbox('optim'), which does license('checkout', 'optimization_toolbox') and checks that fminunc and optimset are on the path (utilities/ft_hastoolbox.m lines 295 to 296 and 736 in FieldTrip-lite 20240111, the copy I had locally. CI uses 20250523). license('test') only says a license exists. If the checkout fails, the guard passes and FieldTrip still takes fminsearch silently, which is the case the guard is there to stop. Suggested fix: call ft_hastoolbox('optim') once FieldTrip is on the path, from one small shared helper in tests/matlab/ in place of the four copies.
Test gaps
None. test_struct_near_assertion_matches_source already pins assert_matlab_struct_near against near.m, and test_matlab_kmeans_numbering_matches_fixed_initial_centroids pins the label numbering.
EEGLAB parity notes
What I ran, at commit 2680844.
MATLAB R2025b with the Optimization Toolbox, through matlab -batch, on a local eeglab_tests checkout that is not the pinned commit:
near.mon the 14 cases oftest_struct_near_assertion_matches_sourcegives[1 1 0 1 0 0 0 0 1 0 0 1 1 0].assert_matlab_struct_nearat this head gives the same 14 answers.near(struct(), struct())is 0, so removing the early return is right.eeg_checkset.msetsEEG.etc = []andEEG.roi = [](lines 1266 and 1269). Pythonpop_loadsetreturns{}for both, and these are the only empty dicts in thepop_copysetoutput, so mapping{}to[]in that presentation matches EEGLAB.kmeanscluster.mon the test data returns[1 2 1 1 2 2]. Pythonkmeansclusterreturns the same since #657 moved the+ 1into the function. Dropping+ 1in the test is right.- Synthetic traditional warp of
eegprep_warp_optim_parity.m: withfminunc,ft_warp_optimrecovers the true parameters (z rotation 1.718876). Thefminsearchbranch offt_warp_optimgives[4.992872 -3.000655 1.997129 2.911925 -2.291934 0.3347925 2.00154 1.504206 1.1929], which are the MATLAB values of failure 2 in #685. This confirms that the runner fell back tofminsearch.
Python backend, pinned eeglab_tests fec88f9f and EEGLAB d0963be9, on the six test files that call assert_matlab_struct_near (test_phase1b_file_edit_pop_functions.py, test_eegh.py, test_gethelpvar.py, test_phase2_file_channel_location.py, test_sigprocfunc_plotting_eeglab_tests.py, test_erpimage.py) with --eeglab-backend=python: 238 passed, 1 skipped, 1 failed, 1 deselected (test_struct_near_assertion_matches_source, which needs MATLAB). Both pop_copyset tests pass. With the assertions.py change alone and the old transport, test_reference_copyset_original_set_out fails, so the transport change is needed. The one failure is test_reference_plotcurve_original_eight_cases (plotcurve maskarray shape does not match data), in code this pull request does not touch. I did not check it on develop.
I did not run the MATLAB reference suite itself, so the coregister, warp and BEM tests are not confirmed end to end here.
test.yml and fuzz-nightly.yml also install MATLAB without the Optimization Toolbox. They are not affected: the four helpers are only called from reference tests, which stay deselected without --eeglab-backend.
Share FieldTrip's ft_hastoolbox('optim') check in tests/matlab/eegprep_require_fminunc.m across the four parity helpers and move the check in eegprep_dipfit_component_parity.m after the kind='grid' early return.
|
Thanks for the review. Addressed the feedback in commit
Local MATLAB R2024a Verification (
|
|
This second review was written by an AI assistant at Arno's request, not by Arno. Second review at c7cff11: the reference tests passVerdict: ready to merge. The tests I ran pass on this branch merged into today's develop. Develop alone fails the two tests this pull request fixes in the test harness. The earlier review asked for one reference run on this branch. A fork cannot run
All five tests of #685 pass on the merge. So do the three DIPFIT component tests (grid, single, symmetric), which the GitHub runner skips. The baseline tells us something useful. When Both points from the first review are addressed. The check now calls FieldTrip's own One thing this run cannot show: whether the MATLAB batch token on the GitHub runner licenses the Optimization Toolbox under R2024b. If it does not, the same three tests still fail, now with the clear error How the run was done
— orchestrator |
|
Review (Claude Fable): ready to merge
Details: what I ran, what I found, two small remarksWhat each fix does, and my check
MATLAB R2025b Update 2 (Mac,
|
Install Optimization_Toolbox in eeglab-reference.yml and require fminunc through the shared eegprep_require_fminunc helper across the coregister and DIPFIT parity scripts, leaving DIPFIT grid counting unguarded. Remove the duplicate +1 offset in the MATLAB kmeans clustering test and restore strict empty-struct parity in assert_matlab_struct_near while adapting pop_copyset empty dicts in the Python reference transport. Verified locally on MATLAB R2024a against EEGLAB d0963be9 and eeglab_tests fec88f9f (48 passed, 0 failed, 0 skipped in 31.08s).
Fixes #685