You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Follow-up: time-warped newtimef marker and cycle GUI workflows #146
🤖 Follow-up from Phase 7 (#138) of epic #131.\n\nRows covered: pop_newtimef, newtimef, timewarp, angtimewarp, tf_cycle_calc.\n\nScope: port or redesign the EEGLAB time-warped event-marker workflow for ERSP/ITC and the cycle-calculation GUI helper with standalone EEGPrep runtime behavior, tests, and GUI parity evidence where user-facing.\n\nNon-goal: do not make package runtime depend on src/eegprep/eeglab.
Duplicate-work preflight (no overlapping open PRs/issues)
Inventory current repo state for pop_newtimef, newtimef, timewarp, angtimewarp, tf_cycle_calc
Post Research + Proposed Approach (this comment, multi-module scope → no PR yet)
Await human approval on approach before implementation
Research
Scope of #146 spans five EEGLAB rows that together form one workflow: time-warped event markers feeding newtimef's wavelet path, plus the GUI cycle-calculator that picks cycles/winsize from the dialog. Three of the five have no EEGPrep port today (timewarp, angtimewarp, tf_cycle_calc); the other two exist but explicitly reject the time-warp options and disable the cycle-calc button in the GUI, so they are not user-reachable yet. Root cause is missing helper modules plus a hard-rejection guard added during the initial pop_newtimef port that needs to be replaced once the helpers land. This is multi-module (>100 LOC) and design-shaped, so per instructions I'm posting analysis instead of a PR.
Multi-module port. EEGLAB parity oracle: eeglab/functions/timefreqfunc/{timewarp,angtimewarp,newtimef}.m and eeglab/functions/popfunc/pop_newtimef.m (the vendored tree is not in this CI checkout; I'll read it at implementation time and cite real lines in the PR).
New module src/eegprep/functions/timefreqfunc/timewarp.py exposing timewarp(latencies, newlatencies) -> (warpmat, warped_indices) — linear piecewise time mapping between per-trial event latencies (pnts-units) and target latencies. Pure NumPy, channel-major; returns both the index map and the sparse warp matrix EEGLAB returns. EEGLAB latencies are 1-based; converted at the boundary.
New module src/eegprep/functions/timefreqfunc/angtimewarp.py exposing angtimewarp(latencies, newlatencies, phases) -> warped_phases — circular interpolation of phases along the warp map from (1). Reuses that map; does not re-derive.
Extend compute_time_frequency and newtimef in functions/timefreqfunc/newtimef.py with timewarp (per-trial event-latency matrix, ms), timewarpms (common target latencies, ms), timewarpidx (optional event subset to mark). When timewarp is supplied, _trial_wavelet shifts each trial's time-output indices through timewarp(...) before applying Morlet wavelets; ITC uses angtimewarp-aligned phases. STFT path raises a clear NotImplementedError to match EEGLAB (wavelet-only).
New helper src/eegprep/functions/timefreqfunc/tf_cycle_calc.py exposing tf_cycle_calc(srate, frame_count, freqs, cycles) -> dict returning winsize, min_freq, max_freq, n_cycles_low, n_cycles_high. Pure numeric; no plotting. A small Qt dialog (functions/guifunc/tf_cycle_calc_dialog.py) wraps it and writes results back into the parent pop_newtimef dialog.
pop_newtimef.py:
Drop timewarp* from _reject_unsupported_options; thread the options through to newtimef.
Replace enabled=False on calcpush with a callback that opens the tf_cycle_calc dialog and writes results back into the cycles/tlimits controls.
Add three GUI controls behind a "Time warp (optional)" section: timewarp (per-trial event-latency matrix or workspace name), timewarpms (target latencies), timewarpidx (event indices to mark). Defaults empty so the no-warp path stays byte-identical.
Update history_command so generated pop_newtimef(EEG, ...) is replayable from eegprep-console.
Help: extend src/eegprep/resources/help/pop_newtimef.md; add src/eegprep/resources/help/tf_cycle_calc.md. No MD for timewarp/angtimewarp — not directly user-facing.
Tests:
tests/test_timewarp.py (new): identity warp, known-fixture latency → expected linear map, unsorted-input rejection; angtimewarp wrap-around at ±π, numeric parity on a hand-computed case.
Extend tests/test_phase4_timefreq_statistics.py: pop_newtimef with timewarp=..., timewarpms=..., timewarpidx=... on sample_epoch; assert result.times aligns to timewarpms, history is replayable, GUI path round-trips through _run_gui with the default renderer.
Extend tests/test_console_workspace.py: bare pop_newtimef(EEG, ..., timewarp=...) auto-stores.
Visual parity case under tools/visual_parity/pop_newtimef_timewarp/, gated by the existing visual marker.
MATLAB parity (@pytest.mark.matlab): numerical compare against newtimef(..., 'timewarp', ...) on a 4-channel synthetic; skipped under EEGPREP_SKIP_MATLAB=1.
Open questions before implementation:
EEGLAB's cycle-calc button pops a modal sub-dialog with its own inputs. Ship the Qt dialog now, or land the numeric tf_cycle_calc() first and the GUI dialog in a follow-up?
EEGLAB accepts timewarp as either an (ntrials × nevents) matrix or per-trial cell arrays. Restrict to the matrix form (recommended path) and reject cell input with a clear message?
Visual parity snapshot — gate behind the visual marker and skip when X11 capture is unavailable, matching other pop_* parity cases?
Estimated diff: ~600-800 LOC across 5 source files + 3 test files + 2 help files. Branch will be agent/20260606-fix-146 once approach is approved.
🤖 Resolved by the work now included in PR #152. Closing this constituent phase/follow-up issue now; parent epic #131 remains open until the epic PR merges.
Activity
claude commentedon Jun 6, 2026
🤖 Plan:
pop_newtimef,newtimef,timewarp,angtimewarp,tf_cycle_calcResearch
Scope of #146 spans five EEGLAB rows that together form one workflow: time-warped event markers feeding
newtimef's wavelet path, plus the GUI cycle-calculator that pickscycles/winsizefrom the dialog. Three of the five have no EEGPrep port today (timewarp,angtimewarp,tf_cycle_calc); the other two exist but explicitly reject the time-warp options and disable the cycle-calc button in the GUI, so they are not user-reachable yet. Root cause is missing helper modules plus a hard-rejection guard added during the initialpop_newtimefport that needs to be replaced once the helpers land. This is multi-module (>100 LOC) and design-shaped, so per instructions I'm posting analysis instead of a PR.Relevant code
src/eegprep/functions/popfunc/pop_newtimef.py#L107- "tf cycle calc" button hard-wiredenabled=Falsesrc/eegprep/functions/popfunc/pop_newtimef.py#L227-L231-timewarp*options rejected up frontsrc/eegprep/functions/timefreqfunc/newtimef.py#L26-L86-newtimef/compute_time_frequencysignature has notimewarp*kwargssrc/eegprep/functions/timefreqfunc/newtimef.py#L179-L205-_trial_wavelet, where time-warped time grids must be applied per trial.notes/eeglab-migration-gap-audit.md#L103-L108- audit rows enumerated for this follow-up (timewarp,angtimewarp,tf_cycle_calcalso listed at L196/L215/L218)Proposed Approach (design)
Multi-module port. EEGLAB parity oracle:
eeglab/functions/timefreqfunc/{timewarp,angtimewarp,newtimef}.mandeeglab/functions/popfunc/pop_newtimef.m(the vendored tree is not in this CI checkout; I'll read it at implementation time and cite real lines in the PR).src/eegprep/functions/timefreqfunc/timewarp.pyexposingtimewarp(latencies, newlatencies) -> (warpmat, warped_indices)— linear piecewise time mapping between per-trial event latencies (pnts-units) and target latencies. Pure NumPy, channel-major; returns both the index map and the sparse warp matrix EEGLAB returns. EEGLAB latencies are 1-based; converted at the boundary.src/eegprep/functions/timefreqfunc/angtimewarp.pyexposingangtimewarp(latencies, newlatencies, phases) -> warped_phases— circular interpolation of phases along the warp map from (1). Reuses that map; does not re-derive.compute_time_frequencyandnewtimefinfunctions/timefreqfunc/newtimef.pywithtimewarp(per-trial event-latency matrix, ms),timewarpms(common target latencies, ms),timewarpidx(optional event subset to mark). Whentimewarpis supplied,_trial_waveletshifts each trial's time-output indices throughtimewarp(...)before applying Morlet wavelets; ITC usesangtimewarp-aligned phases. STFT path raises a clearNotImplementedErrorto match EEGLAB (wavelet-only).src/eegprep/functions/timefreqfunc/tf_cycle_calc.pyexposingtf_cycle_calc(srate, frame_count, freqs, cycles) -> dictreturningwinsize,min_freq,max_freq,n_cycles_low,n_cycles_high. Pure numeric; no plotting. A small Qt dialog (functions/guifunc/tf_cycle_calc_dialog.py) wraps it and writes results back into the parentpop_newtimefdialog.pop_newtimef.py:timewarp*from_reject_unsupported_options; thread the options through tonewtimef.enabled=Falseoncalcpushwith a callback that opens thetf_cycle_calcdialog and writes results back into thecycles/tlimitscontrols.timewarp(per-trial event-latency matrix or workspace name),timewarpms(target latencies),timewarpidx(event indices to mark). Defaults empty so the no-warp path stays byte-identical.history_commandso generatedpop_newtimef(EEG, ...)is replayable fromeegprep-console.src/eegprep/resources/help/pop_newtimef.md; addsrc/eegprep/resources/help/tf_cycle_calc.md. No MD fortimewarp/angtimewarp— not directly user-facing.tests/test_timewarp.py(new): identity warp, known-fixture latency → expected linear map, unsorted-input rejection;angtimewarpwrap-around at ±π, numeric parity on a hand-computed case.tests/test_tf_cycle_calc.py(new): deterministic outputs for representative(srate, frames, freqs, cycles)tuples.tests/test_phase4_timefreq_statistics.py:pop_newtimefwithtimewarp=..., timewarpms=..., timewarpidx=...onsample_epoch; assertresult.timesaligns totimewarpms, history is replayable, GUI path round-trips through_run_guiwith the default renderer.tests/test_console_workspace.py: barepop_newtimef(EEG, ..., timewarp=...)auto-stores.tools/visual_parity/pop_newtimef_timewarp/, gated by the existingvisualmarker.@pytest.mark.matlab): numerical compare againstnewtimef(..., 'timewarp', ...)on a 4-channel synthetic; skipped underEEGPREP_SKIP_MATLAB=1.Open questions before implementation:
tf_cycle_calc()first and the GUI dialog in a follow-up?timewarpas either an(ntrials × nevents)matrix or per-trial cell arrays. Restrict to the matrix form (recommended path) and reject cell input with a clear message?visualmarker and skip when X11 capture is unavailable, matching otherpop_*parity cases?Estimated diff: ~600-800 LOC across 5 source files + 3 test files + 2 help files. Branch will be
agent/20260606-fix-146once approach is approved.suraj-ranganath commentedon Jun 7, 2026
🤖 Resolved by the work now included in PR #152. Closing this constituent phase/follow-up issue now; parent epic #131 remains open until the epic PR merges.
arnodelorme commentedon Dec 1, 2026
🤖 The tf_cycle_calc dialog and native jamming captures are tracked in #928.