Repository navigation
Phase 8: ICLabel extended properties dashboard - #109
suraj-ranganath merged 6 commits into
Conversation
|
Claude finished @suraj-ranganath's task in 5m 59s —— View job Code review
BlockingNone. Important
Nits
Test gaps
EEGLAB parity notes
Review checklist
|
| def _plot_event_markers( | ||
| axis: Any, | ||
| x_values: np.ndarray, | ||
| dashboard: ExtendedPropertyData, | ||
| scroll_event: bool, | ||
| ) -> None: | ||
| if not scroll_event: | ||
| return | ||
| events = ( | ||
| (axis.figure.eegprep_dashboard_state["EEG"].get("event") or []) | ||
| if hasattr(axis.figure, "eegprep_dashboard_state") | ||
| else [] | ||
| ) | ||
| if not events: | ||
| return | ||
| first = float(np.nanmin(x_values)) | ||
| last = float(np.nanmax(x_values)) | ||
| for event in events: | ||
| if not isinstance(event, dict): | ||
| continue | ||
| try: | ||
| sample = int(round(float(event.get("latency", 1)))) - 1 | ||
| except (TypeError, ValueError): | ||
| continue | ||
| if sample < 0 or sample >= dashboard.times_ms.size: | ||
| continue | ||
| x_value = float(dashboard.times_ms[sample]) | ||
| if first <= x_value <= last: | ||
| axis.axvline(x_value, color="red", linestyle="--", linewidth=0.75) | ||
| axis.text(x_value, 0.98, str(event.get("type", "")), transform=axis.get_xaxis_transform(), rotation=45) |
There was a problem hiding this comment.
Severity: important — Event-marker mapping is incorrect for epoched data.
event["latency"] in EEGLAB is the continuous-stream sample index (1-based across the whole recording), but this loop treats it as an index into the single-epoch dashboard.times_ms (length pnts). For epoched datasets:
- events whose
latency > pntsare silently dropped (sample >= times_ms.size), and - events that happen to fall in
[1, pnts]but actually belong to a later epoch are drawn at the wrong time.
property_activity_browser forwards events to eegplot, which handles this correctly, so the dashboard's static activity panel is the only place this regresses.
Two reasonable fixes:
- Walk
EEG.epoch[trial].event(per-trial event indices) and only draw markers for the currently displayed trial. - Skip the static overlay on epoched data and rely on the browser-backed view:
| def _plot_event_markers( | |
| axis: Any, | |
| x_values: np.ndarray, | |
| dashboard: ExtendedPropertyData, | |
| scroll_event: bool, | |
| ) -> None: | |
| if not scroll_event: | |
| return | |
| events = ( | |
| (axis.figure.eegprep_dashboard_state["EEG"].get("event") or []) | |
| if hasattr(axis.figure, "eegprep_dashboard_state") | |
| else [] | |
| ) | |
| if not events: | |
| return | |
| first = float(np.nanmin(x_values)) | |
| last = float(np.nanmax(x_values)) | |
| for event in events: | |
| if not isinstance(event, dict): | |
| continue | |
| try: | |
| sample = int(round(float(event.get("latency", 1)))) - 1 | |
| except (TypeError, ValueError): | |
| continue | |
| if sample < 0 or sample >= dashboard.times_ms.size: | |
| continue | |
| x_value = float(dashboard.times_ms[sample]) | |
| if first <= x_value <= last: | |
| axis.axvline(x_value, color="red", linestyle="--", linewidth=0.75) | |
| axis.text(x_value, 0.98, str(event.get("type", "")), transform=axis.get_xaxis_transform(), rotation=45) | |
| def _plot_event_markers( | |
| axis: Any, | |
| x_values: np.ndarray, | |
| dashboard: ExtendedPropertyData, | |
| scroll_event: bool, | |
| ) -> None: | |
| if not scroll_event or dashboard.activity.shape[2] > 1: | |
| return | |
| events = ( | |
| (axis.figure.eegprep_dashboard_state["EEG"].get("event") or []) | |
| if hasattr(axis.figure, "eegprep_dashboard_state") | |
| else [] | |
| ) | |
| if not events: | |
| return | |
| first = float(np.nanmin(x_values)) | |
| last = float(np.nanmax(x_values)) | |
| for event in events: | |
| if not isinstance(event, dict): | |
| continue | |
| try: | |
| sample = int(round(float(event.get("latency", 1)))) - 1 | |
| except (TypeError, ValueError): | |
| continue | |
| if sample < 0 or sample >= dashboard.times_ms.size: | |
| continue | |
| x_value = float(dashboard.times_ms[sample]) | |
| if first <= x_value <= last: | |
| axis.axvline(x_value, color="red", linestyle="--", linewidth=0.75) | |
| axis.text(x_value, 0.98, str(event.get("type", "")), transform=axis.get_xaxis_transform(), rotation=45) |
The above is the minimal-risk change (gate on trials > 1); a per-epoch implementation would be richer but requires walking EEG.epoch and is a larger change.
Ref:
eegprep/src/eegprep/plugins/ICLabel/pop_prop_extended.py
Lines 650 to 679 in 8875bbc
| finite = np.isfinite(dashboard.spectrum_power) | ||
| if np.any(finite): | ||
| axis.set_ylim( | ||
| float(np.nanmin(dashboard.spectrum_power[finite])), float(np.nanmax(dashboard.spectrum_power[finite])) | ||
| ) |
There was a problem hiding this comment.
Severity: nit — Redundant nan-handling and degenerate ylim.
finite already masks out NaN/inf, so dashboard.spectrum_power[finite] is finite by construction — np.min/np.max are sufficient. Also, when the spectrum is constant (e.g., all zeros for a flat trace), set_ylim(v, v) emits a UserWarning and yields a degenerate axis. A small padding (or letting matplotlib autoscale) avoids both:
| finite = np.isfinite(dashboard.spectrum_power) | |
| if np.any(finite): | |
| axis.set_ylim( | |
| float(np.nanmin(dashboard.spectrum_power[finite])), float(np.nanmax(dashboard.spectrum_power[finite])) | |
| ) | |
| finite = np.isfinite(dashboard.spectrum_power) | |
| if np.any(finite): | |
| finite_values = dashboard.spectrum_power[finite] | |
| low = float(np.min(finite_values)) | |
| high = float(np.max(finite_values)) | |
| if high == low: | |
| high = low + 1.0 | |
| axis.set_ylim(low, high) |
Ref:
eegprep/src/eegprep/plugins/ICLabel/pop_prop_extended.py
Lines 485 to 489 in 8875bbc
|
@claude review this |
|
Claude finished @suraj-ranganath's task in 3m 34s —— View job Code review
Prior findings — all addressed
New surface area — looks correct
Nits (non-blocking, optional)
EEGLAB parity notes
Risk-adjusted summaryThe PR is large (2259 / -54), but the bulk is well-factored: one new dashboard module, one small MRI helper, packaged resources, focused tests, and tightly scoped GUI wiring in
|












Summary
pop_prop_extendedfor the ICLabel/viewprops extended component-property dashboardpop_viewpropscomponent mode to the extended dashboard when usable classifier data are present, while preserving lightweight fallback without classifier dataACCEPT/REJECT,Cancel,Values,HELP, andOKcontrols that commit selected dashboard marks toEEG.reject.gcomprejectand persist GUI-launched viewprops updates back to the shared sessionscrollplot1-based sample coordinates for continuous and epoched data, including visible epoch boundariesCloses #108
Verification
QT_QPA_PLATFORM=offscreen uv run --no-sync pytest tests/test_gui_pop_prop_extended.py tests/test_pop_prop_extended.py tests/test_gui_rejection_dialogs.py tests/test_rejection_workflows.pyQT_QPA_PLATFORM=offscreen uv run --no-sync pytest tests/test_visual_parity.pyuv run --no-sync ruff check .uv run --no-sync ruff format --check .uv run --no-sync ty check./pre-commit.pyQT_QPA_PLATFORM=offscreen EEGPREP_SKIP_MATLAB=1 uv run --no-sync pytest -m "not slow"Visual Evidence
iclabel_pop_prop_extended_dashboardwithQT_QPA_PLATFORM=offscreen uv run --no-sync python tools/visual_parity/capture.py --case iclabel_pop_prop_extended_dashboard --target eegprep --timeout 60.EEGPREP_EEGLAB_ROOT=/Users/suraj/Desktop/eeglab uv run --no-sync python tools/visual_parity/capture.py --case iclabel_pop_prop_extended_dashboard --target eeglab --timeout 180.uv run --no-sync python tools/visual_parity/compare.py --case iclabel_pop_prop_extended_dashboard(mean_abs_delta=0.146510,different_pixel_ratio=0.450519).Accepted Deviations
OK..matassets at runtime; this preserves standalone EEGPrep behavior while matching the MRI-slice DIPFIT dashboard surface and metadata.