Skip to content

release: promote dev to main for v1.5.1 - #97

Merged
tabedzki merged 22 commits into
mainfrom
dev
Nov 16, 2026
Merged

tabedzki merged 22 commits into
mainfrom
dev

Conversation

@tabedzki

@tabedzki tabedzki commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Promotes dev to main for PixelMap 1.5.1, a patch release that fixes the event-loop stalls.

#96 passed lint and the full test suite on dev. This PR needs its own CI to pass before it merges.

🤖 Generated with Claude Code

tabedzki and others added 22 commits October 30, 2026 10:56
The multi-shank PDF matched shank IDs and electrode IDs separately against
the forbidden list for all shanks. That is a cross-product, not a pair
match: an electrode ID forbidden on one shank was drawn black on every
shank that had any forbidden electrode. This affected 2.0-4shanks and
QuadBase PDF exports since the initial commit. The GUI, IMRO and kilosort
outputs were already correct.

- Filter the forbidden list to the current shank (as the selected list
  already was) and match on electrode ID.
- Reshape forbidden_electrodes to (n, 2) so an empty conflict list no
  longer raises IndexError in either the single- or multi-shank branch.
- Add regression tests for both.

Assisted-by: ClaudeCode:claude-opus-5-5
Fix the empty-shape crash at its source instead of reshaping at the
plot_probe_layout call site. No caller relied on the 1-D empty result,
and (0, 2) matches the documented [[shank_id, electrode_id], ...] shape.

- Drop the call-site reshape and filter selected electrodes inline per
  shank, the same way as forbidden ones (removes shank_m_selected).
- Tests: assert the (0, 2) empty shape in test_wiring_lookup; share the
  colour/collection helpers in test_pdf_export; reuse the GUI's loaded
  wiring/positions frames; run the no-conflict PDF test once per drawing
  branch (single- and multi-shank).

Assisted-by: ClaudeCode:claude-opus-5-5
fix: colour only forbidden (shank, electrode) pairs in multi-shank PDFs
Add a sixth drag-box tool, "Zigzag-deselect Dependents". It filters the
box to the zigzag-pattern sites (the same filter Zigzag-select uses) and
then runs the existing deselect-dependents logic on them, through a
shared `_deselect_dependents` helper. Only the zigzag half of a blocked
region is freed, and the complementary half of the blocking selection
stays selected, so a following Zigzag-select drag finishes the job
without re-selecting the blocking region.

Pass tool descriptions to the active-tool JS via CustomJS args instead of
order-dependent placeholder replacement. Use the upstream icon exported
from selector_boxes.svg, and mirror it and the updated Deselect
dependents icon into docs/_static. Document the tool in the GUI guide and
the in-GUI selection tools panel, and clarify that red blockers are deselected
wherever they sit, inside or outside the box.

Tests pin the wiring closure property (zigzag sites only conflict with
zigzag sites) on all four probe types, filtered freeing, in-box red
blockers, no-op cases, single-tap toggling, one undo step per drag, the
unchanged existing tool, toolbar wiring, and that the side-panel help covers every box tool.

Assisted-by: Codex:gpt-6.1-sol
Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
docs: fix "elese" typo in the GUI guide tip
With an anatomy overlay on screen, picking a not-yet-cached atlas from
the dropdown live-recomputed the overlay synchronously
(_on_atlas_change -> _recompute_anatomy_if_active ->
compute_anatomy_overlay), so the atlas download ran on the Bokeh event
loop and froze every session and the healthcheck for 5-10 s per switch.

_recompute_anatomy_if_active now only draws inline when the atlas is
already local; otherwise it schedules the Compute button's async handler,
which downloads in a worker thread and redraws under the document lock.

The handler also keeps fetching until the currently selected atlas is
local, since the user can switch again mid-download and the subsequent
draw reads the dropdown, and it skips starting a second download while
one is in flight.

Assisted-by: ClaudeCode:claude-opus-5-5
The cold-atlas download was not the only thing blocking the Bokeh event
loop. Measured on cached atlases:

- Every live pose edit recomputed the overlay inline: 0.7 s on
  allen_mouse_25um, 3.3 s on allen_mouse_10um, per keystroke.
- Switching to a human or fish atlas derived its anterior-commissure
  origin inline, a whole-volume scan taking 0.8-7.7 s.
- Any on-loop annotation read could wait on _resident_lock, which
  another session's download holds for its whole duration.

The overlay is now three steps: snapshot the widget inputs on the loop
(_anatomy_request), do every atlas read in a worker thread
(_compute_anatomy: bands, AC origin, locator render, tip depth), and
write Bokeh models back on the loop under the document lock
(_apply_anatomy, ~3 ms). _drain_anatomy_requests runs one compute per
session at a time and coalesces edits made during it. Clear bumps a
generation counter so a result that outlives its overlay is dropped,
and a failed download clears the stale overlay instead of retrying on
every later edit.

derive_origin_from_ac gets a hand-rolled memo plus
peek_origin_from_ac, so _origin_spec on the loop only reads the memo.
When no overlay is showing, switching to a cached AC atlas derives the
origin in a worker and fills the fields afterwards.

_region_fill_rgba builds one palette entry per distinct region and
gathers through np.unique's inverse index, instead of a full-slice mask
per region. That was 2.4 s of the 3.5 s render on a 10 um atlas; total
compute work is now 0.41 s / 1.16 s on allen_mouse_25um / 10um.

Assisted-by: ClaudeCode:claude-opus-5-5
- Locate a pending AC origin in the drain before the snapshot, so a lap
  draws with the origin. This drops origin_was_pending, the derive in
  _compute_anatomy, and the extra fill-and-recompute lap in
  _apply_anatomy, which cost a full 0.7-3.3 s recompute on the first
  overlay for a human or fish atlas.
- Merge the two AC paths into one _locate_ac_origin coroutine and a
  _fill_reference_params helper.
- Make derive_origin_from_ac single-flight per atlas name, so concurrent
  callers wait on the running scan instead of starting another.
- Fold _anatomy_overlay_wanted into _anatomy_overlay_active, now set on
  Compute rather than on the first draw.
- Pass the tip depth into one _update_tip_depth_readout(depth) and drop
  the _UNSET sentinel, _set_tip_depth_readout, and the readout's on-loop
  atlas read. Share the lookup and error handling via
  _measure_tip_depth.
- Add button-label constants, _refresh_compute_button, and an
  _anatomy_recompute_suppressed() context manager. Drop dead button
  writes from the sync compute_anatomy_overlay.
- Tests: reset the AC memo in the layered_atlas fixture, share one
  _assert_off_loop helper, and add a single-flight test.

Assisted-by: ClaudeCode:claude-opus-5-5
Second /simplify pass, widened from this PR's diff to everything since
v1.4.1.

- compute_anatomy_overlay() now runs the same off-loop drain as the
  Compute button (synchronous when no event loop is running), so the
  separate inline pipeline and its duplicate AC-origin handling are gone.
  _request_anatomy_recompute drops its redundant "already running" check;
  the drain's own guard is the one that matters.
- The overlay worker no longer writes session state: the locator figure
  travels in the request/result and is adopted (or closed if stale) on
  the loop. Label width/offset are computed at draw time instead of
  being snapshotted.
- Anatomy flags are initialised in __init__, so the getattr fallbacks go;
  _selected_atlas_name() replaces eight copies of the name lookup; the
  unreachable "available once downloaded" readout branch and the
  test-only _tip_depth_below_surface are removed.
- AC-origin memo is a plain dict (no hand-rolled eviction).
- Wiring maps: a cold rebuild indexed the wiring table once per
  electrode (~55 s in the first session's constructor); it now indexes
  each table once (~1.1 s), with identical output.
- PDF electrodes are drawn as one PolyCollection built from a vertex
  array with precomputed colours, sharing one path between single- and
  multi-shank probes: pixel-identical renders, 2-3x faster.
- `import pixelmap` no longer loads Panel/Bokeh (1.28 s -> 0.55 s): the
  IMRO parser imports the notification helper lazily.
- One notify() helper in error_reporting replaces gui._notify and
  error_reporting._toast; traceback helpers use the stdlib directly;
  survey parsing converts all columns in one pass.

Assisted-by: ClaudeCode:claude-opus-5-5
panel serve runs app.py per session on the event loop that serves every
session and /liveness, so the first visit after each start paid for the
imports, the wiring pickle and the default atlas's metadata on that loop.

Run one throwaway ChannelmapGUI through panel serve --setup instead, before
the port is bound. It has no document, so it leaves no session behind. A
failed warmup logs a warning and the server still starts.

Assisted-by: ClaudeCode:claude-opus-5-5
The script swallows every exception, so tests must also assert no failure
was logged, or they pass when the constructor raises. Cover opening the
default atlas when it is on disk, and share the run-and-collect-failures
helper.

Say that the warmup only runs before the port is bound with NUM_PROCS=1,
and drop the bytecode and "exactly what a session needs" claims.

Assisted-by: ClaudeCode:claude-opus-5-5
Each session builds, validates, serialises and sends its Bokeh document on
the loop that serves every other session and /liveness.

- Draw shank outlines, bank lines and labels with one renderer per style.
  A 4-shank document drops from 33 renderers and 485 models to 9 and 269.
- Limit tap and box-select tools to the electrode and survey-bar renderers,
  so a tap on a shared outline renderer can't dim the other outlines.
- Send numeric electrode columns as arrays, compute their geometry with
  NumPy, and skip Bokeh's per-cell check of that fixed-shape source.
- Reuse the cached data URI for tool icons instead of re-encoding six PNGs.

Assisted-by: ClaudeCode:claude-opus-5-5
Configure code owners for backend, GUI, docs, and deployment
Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
@tabedzki
tabedzki merged commit f191e2f into main Nov 16, 2026
4 checks passed
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.

2 participants