Repository navigation
Implement advanced EEGBrowser display modes - #106
Conversation
|
Claude finished @suraj-ranganath's task in 6m 54s —— View job Code review
BlockingNone. Important
Nits
Test gaps
EEGLAB parity notes
Checked: bugs in changed lines, EEGLAB parity for |
|
🤖 Spec Problem Approach Key code def _apply_linked_scroll(self, source: Any, visited: set[int] | None = None) -> None:
if visited is None:
visited = {id(source)}
visited.add(id(self))
self._syncing_link = True
try:
self.model.state.time = source.model.state.time
self.model.state.winlength = source.model.state.winlength
self.model.state.channel_offset = source.model.state.channel_offset
self._redraw_local()
finally:
self._syncing_link = False
self._sync_linked_windows(visited)Tests Visual evidence |
| options.setdefault("xgrid", "off") | ||
| options.setdefault("ygrid", "off") | ||
| options.setdefault("data2", None) | ||
| options.setdefault("plotdata2", "off") |
There was a problem hiding this comment.
Severity: important
plotdata2 is added to _OPTION_NAMES (line 34) and given a default here, but its value is never read anywhere. The data2 overlay in EEGBrowserCanvas._draw_overlay_trace is rendered solely on the basis of flat_data2 is not None — passing plotdata2="on" or plotdata2="off" produces identical output.
EEGLAB's plotdata2 toggle controls whether data2 is rendered as a red overlay vs. acts as the primary trace. As-is the option is silently swallowed: users get no error and no behavior change, which is the worst of both worlds.
Either wire the value through to the canvas (e.g. an overlay_enabled flag on BrowserState) or drop "plotdata2" from _OPTION_NAMES and remove this default until the toggle is implemented.
eegprep/src/eegprep/functions/sigprocfunc/eegplot.py
Lines 31 to 48 in 49a636c
| def _plot_subcomp_confirmation(input_eeg: dict, output_eeg: dict) -> None: | ||
| icachansind = _icachansind(input_eeg) | ||
| preview = copy.deepcopy(input_eeg) | ||
| input_data = np.asarray(input_eeg["data"]) | ||
| output_data = np.asarray(output_eeg["data"]) | ||
| preview["data"] = np.array(input_data[icachansind], dtype=float, copy=True) | ||
| preview["nbchan"] = int(icachansind.size) | ||
| preview["chanlocs"] = _selected_chanlocs(input_eeg, icachansind) |
There was a problem hiding this comment.
Severity: important
copy.deepcopy(input_eeg) walks the entire EEG dict — including the full data array, which is the largest field in a typical recording (tens to hundreds of MB for multi-channel, multi-minute datasets). Two lines later preview["data"] = ... overwrites the copied array, so all of that work is thrown away on every plotag invocation.
Build the preview dict explicitly with only what eegplot actually reads (data, nbchan, chanlocs, plus event/srate/xmin/xmax/pnts/trials if you want eegplot's _default_* paths to find them) rather than deepcopying the full EEG.
eegprep/src/eegprep/functions/popfunc/pop_subcomp.py
Lines 140 to 155 in 49a636c
| rows = [] | ||
| new_rows = _continuous_rows(rej, n_channels, newcolor) | ||
| if new_rows.size: | ||
| rows.append(new_rows) | ||
| old_rows = _continuous_rows(oldrej, n_channels, oldcolor) | ||
| if old_rows.size: | ||
| rows.append(old_rows) | ||
| return np.vstack(rows) if rows else np.zeros((0, 5 + n_channels), dtype=float) |
There was a problem hiding this comment.
Severity: nit
The continuous path stacks rows as [new, old], but the epoched path right above stacks them as [old, new] (see _epoched_winrej). Where rejection rectangles overlap on screen, the later row paints over the earlier one — so the two modes produce opposite z-stacks.
EEGLAB's eeg_multieegplot.m consistently draws old marks first so new marks visually take precedence. Suggest mirroring the epoched order here so old marks sit below new ones in both modes.
| rows = [] | |
| new_rows = _continuous_rows(rej, n_channels, newcolor) | |
| if new_rows.size: | |
| rows.append(new_rows) | |
| old_rows = _continuous_rows(oldrej, n_channels, oldcolor) | |
| if old_rows.size: | |
| rows.append(old_rows) | |
| return np.vstack(rows) if rows else np.zeros((0, 5 + n_channels), dtype=float) | |
| def _continuous_winrej( | |
| rej: Any, | |
| oldrej: Any, | |
| *, | |
| n_channels: int, | |
| oldcolor: tuple[float, float, float], | |
| newcolor: tuple[float, float, float], | |
| ) -> np.ndarray: | |
| rows = [] | |
| old_rows = _continuous_rows(oldrej, n_channels, oldcolor) | |
| if old_rows.size: | |
| rows.append(old_rows) | |
| new_rows = _continuous_rows(rej, n_channels, newcolor) | |
| if new_rows.size: | |
| rows.append(new_rows) | |
| return np.vstack(rows) if rows else np.zeros((0, 5 + n_channels), dtype=float) |
The existing test_eeg_multieegplot_continuous_uses_old_and_new_colors will need to flip its expected order accordingly.
eegprep/src/eegprep/functions/popfunc/eeg_multieegplot.py
Lines 82 to 117 in 49a636c

Add EEGBrowser data2 overlays, linked/noui/frequency modes, eeg_multieegplot, and browser-backed property activity views. This also enables pop_subcomp(plotag=True) to show a before/after data2 browser and expands tests for advanced channel/component display behavior.
Fixes #100
Part of #94