Skip to content

feat(dashboard): score the SBD v3/v4 sham and mid-probe stages - #298

Draft
shubhamTR wants to merge 1 commit into
mainfrom
feat/dashboard-sbd-v3-stages
Draft

shubhamTR wants to merge 1 commit into
mainfrom
feat/dashboard-sbd-v3-stages

Conversation

@shubhamTR

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #249 (Michael's PR comment / DM): score the v3 sham and mid-probe stages of the SBD place-learning protocols in the data-browser dashboard.

The v3 (p3-sbd-placelearning-coupled-v3-led14) and v4 (…-coupled-v4-led14, …-uncoupled-v4-led14) protocols add three tests around the training: sham_preprobe (before preprobe, closed loop with the LED off), probe_mid (heated test after bout 10) and sham_probe (LED off, after bout 20, before probe). The dashboard's SBD scorer only knew preprobe / training / probe, so those bouts were dropped. Now:

  • Stage mapping (analysis-core.js sbdStage): sham_preprobe / probe_mid / sham_probe are stages of their own; training also matches the v4 uncoupled control's train_k<k>_<plus|minus> bout names (the classifier's condition-name fallback uses the same regex, so a renamed v4 copy still routes to sbd-place).
  • Protocol-order position per bout, shared across protocol versions: sham before −1, before 0, train_k = k, mid test / sham test = k + 0.5 after bout k, test = N + 1.
  • Heat-off shams: the two sham stages carry heatOff = true (no led_activation on the trialParams, ledDrive 0 before), so the LED-on fraction is 0 for them and uniformHeat is false; their preference index uses the same zone geometry as the probes.
  • Stage summary + pages: sbdStageSummary carries all six stages (zero bouts when a protocol lacks one), stages (those present, in protocol order), a short label ("sham before", "before", "training", "mid test", "sham test", "test") and the heat-off flag. The occupancy and preference pages show only the stages the loaded runs ran (a mixed v2 + v4 group shows the union), the sequence pages label the tests on the x axis and shade one band per test. CSV rows gain heat_off and stage_label.
  • v1/v2 runs score as before: the existing checks pass unchanged, and a new check pins the v1/v2 run's flags, summary and tick labels.
  • Semantics mirror the lab's local Python sbd-dashboard (sbd.py: STAGES, SHAM_STAGES, bout positions, stage_summary), not its code.

Files: dashboard/data-browser/analysis-core.js, dashboard/data-browser/plot-specs.js, dashboard/data-browser/README.md, tests/test-dashboard-sbd.js.

Tier

Next candidate.

Release notes

Dashboard

  • The SBD place-learning pages now score the v3/v4 sham tests and the mid test. sham_preprobe, probe_mid and sham_probe bouts appear as their own stages ("sham before", "mid test", "sham test") on the time-in-zone, first-entry, LED-on, occupancy and preference pages, scored on the same safe zone as the probe. Sham tests show an LED-on fraction of 0 and are flagged heat_off in the CSV.
  • Bout positions line up across protocol versions: sham before −1, before 0, training bouts 1…N, mid test / sham test half a step after the bout they follow, test N + 1. The sequence x axis labels the tests and numbers the training bouts.
  • The v4 uncoupled control is recognised (train_k<k>_<plus|minus> bout names). v1/v2 runs are unchanged.

Test plan

  • pixi run test -- dashboard-sbd — 26 / 26 checks (17 existing + 9 new: stage mapping, positions, heat-off flags, summary, pages, v1/v2 regression, v4 classification)
  • pixi run test — every dashboard test passes; the 7 files that fail on this Windows checkout (test-arena-studio-alt, test-project-skills, test-protocol-roundtrip-v3, test-rig-qc, test-studio-runtime-vars, test-studio-shell, test-three-viewer-partial-columns) do not reference the dashboard and fail identically without this change
  • Load a v4 run (p3-sbd-placelearning-coupled-v4-led14) in the data-browser and check the six stages on the preference page

🤖 Generated with Claude Code

The data-browser's SBD place-learning scorer only knew preprobe / training /
probe, so the v3 (p071 port) and v4 protocols' sham_preprobe, probe_mid and
sham_probe bouts were dropped. They are now stages of their own, scored like
the probe on the same zone geometry:

- sbdStage maps sham_preprobe / probe_mid / sham_probe to their own stages and
  accepts the v4 uncoupled control's train_k<k>_<plus|minus> bout names (the
  classifier's condition-name fallback uses the same regex).
- Every bout gets a protocol-order position shared across protocol versions:
  sham before -1, before 0, train_k = k, mid test / sham test = k + 0.5 after
  bout k, test = N + 1.
- The two sham stages are heat-off (no led_activation, ledDrive 0 before the
  trial): heatOff = true, LED-on fraction 0, uniformHeat false.
- sbdStageSummary carries all six stages (zero bouts when a protocol lacks
  one) plus `stages` (those present, in order), a short label and the
  heat-off flag; the stage pages (occupancy, preference) show only the stages
  the loaded runs ran, the sequence pages label the tests on the x axis and
  shade one band per test; CSV rows gain heat_off / stage_label.
- v1/v2 runs score as before (the existing checks pass unchanged); new checks
  build a synthetic v4-style run covering stage mapping, positions, heat-off
  flags, summary and pages, plus a v1/v2 regression check.

Semantics mirror the lab's local sbd-dashboard (sbd.py: STAGES, SHAM_STAGES,
bout positions, stage_summary).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant