From c0d1372d41288ed392c6ccec1aea11559c5b0c6e Mon Sep 17 00:00:00 2001 From: Christian Tabedzki <35670232+tabedzki@users.noreply.github.com> Date: Mon, 2 Nov 2026 11:07:58 -0500 Subject: [PATCH] feat: add zigzag-deselect dependents box tool 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 --- docs/_static/dependent_deselector.png | Bin 4537 -> 4494 bytes docs/_static/zigzag_dependent_deselector.png | Bin 0 -> 6492 bytes docs/gui-guide.md | 6 +- pixelmap/gui/gui.py | 127 +++++++++----- tests/test_zigzag_dependent_deselect.py | 170 +++++++++++++++++++ 5 files changed, 262 insertions(+), 41 deletions(-) create mode 100644 docs/_static/zigzag_dependent_deselector.png create mode 100644 tests/test_zigzag_dependent_deselect.py diff --git a/docs/_static/dependent_deselector.png b/docs/_static/dependent_deselector.png index 001cd327f36fc243834a3618ad4711996dfaf8bd..3b6f885868717f79c08f075364ce9cd350cd8322 100644 GIT binary patch delta 4357 zcma)9rZtRNp31RTVjaG+O?UyxjAQi7l5Dc~vQTLJR{bpUFF zJqnxBh;Dg_AZj|$1o#)Z;^lUg$|jn32rN)%a4qpB9y|!}sHb3gaWaUpE(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}gmn2BexD^>*J9{*7s3Uo=$T({rM1gcmDZEjo3PHITG3ZXleTgQe~?=v z_+5o@s!JQc=MXQTz1g*=fL@z}BRzQyRJN9*wXFd5%VVIWetQD5s_?rWI5{uBspso! z;N*MDZi|6|o6px4CvO1oWCfxx1N-JV&{Ds>fx9a3`!R5A-hNZh7ZU=r=z-v^eR~FI zXm_qM2HX{dA0=H0HUmEZb}V9`f3@*^2Jm_bep`UMfguI^9Rtj%fdSzyjPuJ$AEny1 z&Nf)+3w)Wd!NLf_nuMOfQo_Qhhk=JwHRhYHib=Cyk0-44IE;|C(U+dx=K>)5dhc%Sh5csejsRabTNkN*!{_%wnmT6&QH3jhEBNkvXX Hu0mjfBGxY5 diff --git a/docs/_static/zigzag_dependent_deselector.png b/docs/_static/zigzag_dependent_deselector.png new file mode 100644 index 0000000000000000000000000000000000000000..52cdbb71d6d2eabf69832446519708ebc0d79915 GIT binary patch literal 6492 zcmZ{JXEYpM(D$-fy+;>8tmwTHC94HNSee;cpY0DpgfK_@q7Z#x^0*Mja|j+uM% zOaK7GrY1z$FyQNMR^Vr7PaVAdeKRv2N}1LP-0>quqTcciPkQ zMWpwh>$Z6*o%87W&as^D+a+)0TVq#!DAO~@EDn9QmU|B0C!hz z`UzCSv4g>sxN`s(q`v_zq!|543J#h;N)9hsVR8m?9~@bLoQQ7=r9rz^zQJ!ws!gIe z&=5gPSb`Ey6`2XKJcwU!@>f4(76N6a&EYyQu$Icv`P_=Ggx!4H4L1#oMuTupjDQqC zb@eiTK$Ucu6+RtKv1(a^+`*fcyNt2shX~3-E9dj~dR#slE4i!|?A(xp5i?wh!W@74 zgTW}KS^FGO%~mK{hia3R@c@2=6(y18-y+DKYMm|(e}V4fF;sD#!8sv4%>9EyGB#pP zWI^fmteKCjmG}m1-@5wJW9{no!%xh(rpVhC9Z0^Dy^nSf zpqH+ac?mI-sUq=^b*SnBM#|jwpBYA`VV3lgma}eTEZb;7rEmPT z!7SJnc;^=@$L_Ep@}0l28ZclpR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u~8qQEOY?Eok zF}4V^^vI{riREn0VwpK@EYu=xzAV~a|#oi8bk*6Yl5*55u(!EMOY`)O(wZOZC= zilsbTm$+o6Q{(`w-Q>qK0D4OpuuwAt7nm!326YZox12ebw&50T@FO@U*clXDWL3H7 zSIX&4UX+Sb=a!oYmi`NRvX%bo)rT+NN_guiD)A5eNz|q(DQ1Z~l=td#8u0pZ1y4_` zJ}AJ?dMpFU`b)hNF1q--eV!XgTrqlBFpvpUNYNwGA{U9VEmbGI692%!hiyX91L{hB zsCD0wu5Ca|#)na;l0M>IvjP8Lo%Uo8S1r6;sv=OdS0vw!uuYsl6hzD{Uy4VzN1$C? z!1J*XT^S~+Fa9GagB!37+$hI=h>KDyJKsjWT9_oI-`lIFC?;H(U$x58D z&Sj_tv(sPT)e3LnV@(y_EVvqW=f6_7oeCoD40rv}Lz?e~XGM^$FE;yyDym<}nnjq! ypgltAML}MMA{UxY``?9(bp=u~BmVRsPVH$0Exh~H(*4f}KvVSvq(a5|!~Xy)(tAk& literal 0 HcmV?d00001 diff --git a/docs/gui-guide.md b/docs/gui-guide.md index fbb3f31..33c0adc 100644 --- a/docs/gui-guide.md +++ b/docs/gui-guide.md @@ -95,7 +95,7 @@ Type electrode ranges directly, e.g. `1-10,20-25`, to add them to the current se You can hover over any electrode to see its ID, shank, depth (Z position), and current status in a tooltip. Clicking a single electrode (de)selects it. -You can also drag boxes to (de)select ranges of electrodes with one of five box tools (select the active tool from the toolbar on the right of the probe plot): +You can also drag boxes to (de)select ranges of electrodes with one of six box tools (select the active tool from the toolbar on the right of the probe plot): ```{list-table} :widths: 12 88 @@ -120,6 +120,10 @@ You can also drag boxes to (de)select ranges of electrodes with one of five box :height: 40px ::: - **Deselect dependents** — drag over unavailable (black) electrodes to find the selected (red) electrodes that blocked them due to shared lines or ADCs, and deselect those selected electrodes, freeing the blocked electrodes and all their other dependents. +* - :::{image} _static/zigzag_dependent_deselector.png + :height: 40px + ::: + - **Zigzag-deselect dependents** — drag over blocked electrodes to free only the fixed zigzag-pattern sites by deselecting the red electrodes blocking them, wherever they sit (inside or outside the box). Only zigzag-pattern red electrodes can be blockers, so the complementary non-zigzag sites stay selected. This tool selects nothing. ``` ##### In which order are electrodes selected inside a box? diff --git a/pixelmap/gui/gui.py b/pixelmap/gui/gui.py index e617d87..3b4f12b 100644 --- a/pixelmap/gui/gui.py +++ b/pixelmap/gui/gui.py @@ -749,28 +749,10 @@ def on_electrode_selection(self, _, old, new): self.electrodes.select(Electrode(shank_id, electrode_id)) elif self.select_mode == "dependent_deselect": - # Find unavailable (black) electrodes in the box span, then deselect - # all selected electrodes whose wiring conflicts caused them to be unavailable. - print(f"Box deselect-dependents: {len(new)} electrodes in span") - unavailable_in_span = set() - for idx in new: - shank_id = self.electrode_source.data["shank_id"][idx] - electrode_id = self.electrode_source.data["electrode_id"][idx] - electrode = Electrode(shank_id, electrode_id) - if electrode in self.electrodes.unavailable: - unavailable_in_span.add(electrode) - - # For each unavailable electrode in the span, find which selected - # electrode(s) caused it to be unavailable (i.e. it is in their wiring map). - to_deselect = set() - for u in unavailable_in_span: - for s in self.electrodes.selected: - if u in self.electrodes.wiring_map[s]: - to_deselect.add(s) - - print(f" → deselecting {len(to_deselect)} responsible selected electrode(s)") - for s in to_deselect: - self.electrodes.deselect(s) + self._deselect_dependents(new) + + elif self.select_mode == "zigzag_dependent_deselect": + self._deselect_dependents(new, subset=self.get_zigzag_subset()) # Update electrode visualization self.update_electrode_colors() @@ -787,6 +769,33 @@ def on_electrode_selection(self, _, old, new): self.electrode_source.selected.indices = [] + def _deselect_dependents(self, indices, subset=None): + """Free blocked sites in the box, optionally restricted to electrode IDs. + + Collect blockers before mutating selection. Selected sites in the box + are not targets, and this operation never selects the freed sites. + The caller owns the gesture's undo snapshot and visualization refresh. + """ + subset = None if subset is None else set(subset) + unavailable_in_span = set() + for idx in indices: + shank_id = self.electrode_source.data["shank_id"][idx] + electrode_id = self.electrode_source.data["electrode_id"][idx] + if subset is not None and electrode_id not in subset: + continue + electrode = Electrode(shank_id, electrode_id) + if electrode in self.electrodes.unavailable: + unavailable_in_span.add(electrode) + + to_deselect = set() + for u in unavailable_in_span: + for s in self.electrodes.selected: + if u in self.electrodes.wiring_map[s]: + to_deselect.add(s) + + for s in to_deselect: + self.electrodes.deselect(s) + def get_zigzag_subset(self): N_per_shank = PROBE_FEATURES[self.probe_subtype]["n_sites_per_shank"] if self.probe_type == "1.0": @@ -2093,6 +2102,7 @@ def setup_bokeh_plot(self): zigzagselect_box_string = "Zigzag-select Electrodes" interleavedselect_box_string = "Interleaved-select Electrodes" dependentdeselect_box_string = "Deselect Dependents" + zigzagdependentdeselect_box_string = "Zigzag-deselect Dependents" self.box_select_tool = BoxSelectTool(description=select_box_string, icon=GUI_ASSETS_DIR / "selector.png") @@ -2112,6 +2122,11 @@ def setup_bokeh_plot(self): description=dependentdeselect_box_string, icon=GUI_ASSETS_DIR / "dependent_deselector.png" ) + self.box_zigzag_dependent_deselect_tool = BoxSelectTool( + description=zigzagdependentdeselect_box_string, + icon=GUI_ASSETS_DIR / "zigzag_dependent_deselector.png", + ) + # Always-on gesture tools — hidden from toolbar (visible=False). # Left-click drag = pan; scroll = zoom. # Note: right-click drag zoom is not supported by this Bokeh version. @@ -2143,6 +2158,7 @@ def setup_bokeh_plot(self): self.box_zigzagselect_tool, self.box_interleavedselect_tool, self.box_dependent_deselect_tool, + self.box_zigzag_dependent_deselect_tool, ] self.plot = figure( @@ -2204,7 +2220,11 @@ def setup_bokeh_plot(self): # Hidden data source for tool state communication and CustomJS to monitor tool changes self.tool_state_source = ColumnDataSource(data={"active_tool": [""]}) - self.setup_tool_monitoring(select_box_string, deselect_box_string, zigzagselect_box_string, interleavedselect_box_string, dependentdeselect_box_string) + self.setup_tool_monitoring( + select_box_string, deselect_box_string, zigzagselect_box_string, + interleavedselect_box_string, dependentdeselect_box_string, + zigzagdependentdeselect_box_string, + ) def setup_interactions(self): """Setup click and selection interactions""" @@ -2225,7 +2245,11 @@ def setup_interactions(self): "indices", guarded("electrode selection")(self.on_electrode_selection) ) - def setup_tool_monitoring(self, select_box_string, deselect_box_string, zigzagselect_box_string, interleavedselect_box_string, dependentdeselect_box_string): + def setup_tool_monitoring( + self, select_box_string, deselect_box_string, zigzagselect_box_string, + interleavedselect_box_string, dependentdeselect_box_string, + zigzagdependentdeselect_box_string, + ): """JS callback to expose active tools in toolbar""" # workaround https://stackoverflow.com/questions/58210752/how-to-get-currently-active-tool-in-bokeh-figure @@ -2240,26 +2264,30 @@ def setup_tool_monitoring(self, select_box_string, deselect_box_string, zigzagse let zigzagselect_tool = null; let interleavedselect_tool = null; let dependentdeselect_tool = null; + let zigzagdependentdeselect_tool = null; tools.forEach((tool, index) => { - if (tool.description === 'select_box_string') { + if (tool.description === select_box_string) { select_tool = tool; } - if (tool.description === 'deselect_box_string') { + if (tool.description === deselect_box_string) { deselect_tool = tool; } - if (tool.description === 'zigzagselect_box_string') { + if (tool.description === zigzagselect_box_string) { zigzagselect_tool = tool; } - if (tool.description === 'interleavedselect_box_string') { + if (tool.description === interleavedselect_box_string) { interleavedselect_tool = tool; } - if (tool.description === 'dependentdeselect_box_string') { + if (tool.description === dependentdeselect_box_string) { dependentdeselect_tool = tool; } + if (tool.description === zigzagdependentdeselect_box_string) { + zigzagdependentdeselect_tool = tool; + } }); - if (select_tool && deselect_tool && zigzagselect_tool && interleavedselect_tool && dependentdeselect_tool) { + if (select_tool && deselect_tool && zigzagselect_tool && interleavedselect_tool && dependentdeselect_tool && zigzagdependentdeselect_tool) { if (select_tool.active) { tools_info = 'select'; } else if (deselect_tool.active) { @@ -2270,6 +2298,8 @@ def setup_tool_monitoring(self, select_box_string, deselect_box_string, zigzagse tools_info = 'interleaved_select'; } else if (dependentdeselect_tool.active) { tools_info = 'dependent_deselect'; + } else if (zigzagdependentdeselect_tool.active) { + tools_info = 'zigzag_dependent_deselect'; } else { tools_info = 'neither_active'; } @@ -2280,13 +2310,17 @@ def setup_tool_monitoring(self, select_box_string, deselect_box_string, zigzagse tool_state.data = {active_tool: [tools_info]}; """ - js_code = js_code.replace("dependentdeselect_box_string", dependentdeselect_box_string) - js_code = js_code.replace("interleavedselect_box_string", interleavedselect_box_string) - js_code = js_code.replace("zigzagselect_box_string", zigzagselect_box_string) - js_code = js_code.replace("deselect_box_string", deselect_box_string) - js_code = js_code.replace("select_box_string", select_box_string) - - JS_selection_monitor = CustomJS(args={"tool_state": self.tool_state_source}, code=js_code) + # Pass descriptions as values so overlapping names cannot corrupt + # each other through order-dependent placeholder replacement. + JS_selection_monitor = CustomJS(args={ + "tool_state": self.tool_state_source, + "select_box_string": select_box_string, + "deselect_box_string": deselect_box_string, + "zigzagselect_box_string": zigzagselect_box_string, + "interleavedselect_box_string": interleavedselect_box_string, + "dependentdeselect_box_string": dependentdeselect_box_string, + "zigzagdependentdeselect_box_string": zigzagdependentdeselect_box_string, + }, code=js_code) # Hack - monitor random GUI events to trigger javascript fetch of selection box type self.plot.js_on_event("selectiongeometry", JS_selection_monitor) # Selection events @@ -2317,6 +2351,9 @@ def on_tool_state_change(self, attr, old, new): elif active_tool == "dependent_deselect": self.select_mode = "dependent_deselect" print("→ DESELECT-DEPENDENTS box activated") + elif active_tool == "zigzag_dependent_deselect": + self.select_mode = "zigzag_dependent_deselect" + print("→ ZIGZAG-DESELECT-DEPENDENTS box activated") else: self.select_mode = "select" print(f"→ Unexpected result: {active_tool}, defaulting to SELECT box") @@ -2824,10 +2861,20 @@ def get_download_buttons(self): "The black electrodes inside your box turn grey and become " "selectable."), ), + ( + "zigzag_dependent_deselector.png", + "Zigzag-deselect dependents", + ("Frees only the fixed zigzag-pattern black electrodes inside the box " + "by deselecting the red electrodes blocking them, wherever they " + "sit (inside or outside the box). Only zigzag-pattern red " + "electrodes can be blockers, so the complementary non-zigzag " + "sites stay selected. Selects nothing; use Zigzag-select next " + "to select the freed sites."), + ), ) def _selection_tools_help_html(self) -> str: - """In-GUI reference for the five drag-box tools in the plot toolbar. + """In-GUI reference for the six drag-box tools in the plot toolbar. Most users never open the online docs, so the tools — "deselect dependents" above all, whose target is *outside* the box you drag — @@ -2848,7 +2895,7 @@ def _selection_tools_help_html(self) -> str: return ( '

' "Click any electrode to toggle it on or off. To edit many at once, " - "pick one of the five drag-box tools in the toolbar to the right of " + "pick one of the six drag-box tools in the toolbar to the right of " "the probe plot (only one is active at a time) and drag a rectangle " "over the probe:
" '' @@ -2902,7 +2949,7 @@ def create_layout(self): You can mix and match four selection methods:
• Presets: Pre-configured channelmaps that respect wiring constraints
• Textual selection: Type electrode ranges (e.g., "1-10,20-25") to add to the current selection
- • Interactive: Click electrodes directly or drag boxes (selection, deselection, zigzag/interleaved selection, or "deselect dependents") to manually select multiple sites
+ • Interactive: Click electrodes directly or drag boxes (selection, deselection, zigzag/interleaved selection, "deselect dependents", or "zigzag-deselect dependents") to manually select multiple sites
• Selection from pre-existing IMRO file: you can pre-load an IMRO file as a starting point before doing any of the above.

Once you reach the target number of electrodes for the selected probe type (384 or 1536), you can download your channelmap as an IMRO file alongside a PDF rendering to easily remember what your channelmap looks like. Use this IMRO file in SpikeGLX to record from the selected channels, and then use the Kilosort .json file to spikesort your data accordingly.

diff --git a/tests/test_zigzag_dependent_deselect.py b/tests/test_zigzag_dependent_deselect.py new file mode 100644 index 0000000..c5ff319 --- /dev/null +++ b/tests/test_zigzag_dependent_deselect.py @@ -0,0 +1,170 @@ +"""Regression coverage for freeing only zigzag-pattern wiring dependents.""" + +import pytest +from bokeh.models import BoxSelectTool + +from pixelmap.gui.gui import ChannelmapGUI +from pixelmap.types import Electrode + + +@pytest.fixture(scope="module") +def gui(): + return ChannelmapGUI() + + +@pytest.fixture(autouse=True) +def clean_selection(gui): + gui.probe_type = "1.0" + gui.electrodes.clear_selection() + gui.electrodes._undo_stack.clear() + gui.electrodes._redo_stack.clear() + gui.select_mode = "zigzag_dependent_deselect" + yield + gui.electrodes.clear_selection() + + +def _sites(gui): + data = gui.electrode_source.data + return [Electrode(s, e) for s, e in zip(data["shank_id"], data["electrode_id"])] + + +def _indices(gui, electrodes): + return [i for i, e in enumerate(_sites(gui)) if e in electrodes] + + +def _dense_source(gui): + """Select bank 0 and box the matching bank-1 range on shank 0.""" + source = {Electrode(0, e) for e in range(384)} + chunk = {Electrode(0, e) for e in range(384, 768)} + for e in sorted(source, key=lambda e: e.electrode_id): + gui.electrodes.select(e) + assert gui.electrodes.selected == source + assert chunk <= gui.electrodes.unavailable + return source, chunk + + +@pytest.mark.parametrize("probe_type", ["1.0", "2.0-1shank", "2.0-4shanks", "QuadBase"]) +def test_zigzag_wiring_closure(gui, probe_type): + gui.probe_type = probe_type + subset = set(gui.get_zigzag_subset()) + zigzag = {e for e in gui.electrodes.wiring_map if e.electrode_id in subset} + assert zigzag + for e in zigzag: + assert gui.electrodes.wiring_map[e] <= zigzag, (probe_type, e) + + +@pytest.mark.parametrize("probe_type", ["1.0", "2.0-1shank"]) +def test_dense_source_keeps_complement_and_frees_only_zigzag(gui, probe_type): + gui.probe_type = probe_type + gui.select_mode = "zigzag_dependent_deselect" + source, chunk = _dense_source(gui) + subset = set(gui.get_zigzag_subset()) + zigzag_chunk = {e for e in chunk if e.electrode_id in subset} + assert len(zigzag_chunk) == len(chunk) // 2 + + gui.on_electrode_selection(None, [], _indices(gui, chunk)) + + assert gui.electrodes.selected == {e for e in source if e.electrode_id not in subset} + assert zigzag_chunk <= gui.electrodes.available + assert chunk - zigzag_chunk <= gui.electrodes.unavailable + assert not chunk & gui.electrodes.selected + + +def test_no_unavailable_electrodes_is_noop(gui): + gui.electrodes.select(Electrode(0, 0)) + before = gui.electrodes.selected.copy() + gui.on_electrode_selection(None, [], _indices(gui, {Electrode(0, 2), Electrode(0, 4)})) + assert gui.electrodes.selected == before + + +def test_only_non_zigzag_unavailable_is_noop(gui): + source, chunk = _dense_source(gui) + subset = set(gui.get_zigzag_subset()) + targets = {e for e in chunk if e.electrode_id not in subset} + gui.on_electrode_selection(None, [], _indices(gui, targets)) + assert gui.electrodes.selected == source + assert chunk <= gui.electrodes.unavailable + + +def test_selected_electrodes_in_box_stay_selected(gui): + source, chunk = _dense_source(gui) + # These red sites have different wiring from the blocked sites in the box. + red = {Electrode(0, 0), Electrode(0, 1)} + targets = red | {Electrode(0, 386), Electrode(0, 387)} + gui.on_electrode_selection(None, [], _indices(gui, targets)) + assert red <= gui.electrodes.selected + assert Electrode(0, 2) not in gui.electrodes.selected + assert Electrode(0, 3) in gui.electrodes.selected + assert gui.electrodes.selected <= source + assert not chunk & gui.electrodes.selected + + +def test_red_blocker_inside_box_is_deselected(gui): + """Red sites in the box are not targets, but they are still deselected + when they block a targeted black zigzag site in the same box.""" + _dense_source(gui) + # 1.0: 2 blocks 386 (both zigzag); 3 blocks 387 (both non-zigzag). + targets = {Electrode(0, 2), Electrode(0, 3), Electrode(0, 386), Electrode(0, 387)} + gui.on_electrode_selection(None, [], _indices(gui, targets)) + assert Electrode(0, 2) not in gui.electrodes.selected + assert Electrode(0, 386) in gui.electrodes.available + assert Electrode(0, 3) in gui.electrodes.selected + assert Electrode(0, 387) in gui.electrodes.unavailable + + +def test_empty_selection_is_noop(gui): + gui.on_electrode_selection(None, [], []) + assert gui.electrodes.selected == set() + assert not gui.electrodes.can_undo() + + +def test_single_electrode_still_toggles(gui): + target = _sites(gui)[0] + gui.on_electrode_selection(None, [], [0]) + assert gui.electrodes.selected == {target} + gui.on_electrode_selection(None, [], [0]) + assert gui.electrodes.selected == set() + + +def test_drag_is_one_undo_step(gui): + source, chunk = _dense_source(gui) + unavailable = gui.electrodes.unavailable.copy() + gui.on_electrode_selection(None, [], _indices(gui, chunk)) + assert gui.electrodes.selected != source + assert gui.electrodes.undo() is True + assert gui.electrodes.selected == source + assert gui.electrodes.unavailable == unavailable + assert gui.electrodes.undo() is False + + +def test_existing_dependent_deselect_frees_whole_chunk(gui): + _, chunk = _dense_source(gui) + gui.select_mode = "dependent_deselect" + gui.on_electrode_selection(None, [], _indices(gui, chunk)) + assert gui.electrodes.selected == set() + assert chunk <= gui.electrodes.available + + +def test_tool_state_maps_new_mode(gui): + gui.select_mode = "select" + gui.on_tool_state_change(None, {}, {"active_tool": ["zigzag_dependent_deselect"]}) + assert gui.select_mode == "zigzag_dependent_deselect" + + +def test_toolbar_and_monitor_include_sixth_tool(gui): + boxes = [tool for tool in gui.plot.toolbar.tools if isinstance(tool, BoxSelectTool)] + assert len(boxes) == 6 + assert boxes[-1].description == "Zigzag-deselect Dependents" + monitor = gui.plot.js_event_callbacks["selectiongeometry"][0] + assert "Zigzag-deselect Dependents" in monitor.args.values() + assert "zigzag_dependent_deselect" in monitor.code + + +def test_side_panel_help_documents_every_box_tool(gui): + """Every toolbar box tool has an entry with an embedded icon in the help.""" + boxes = [tool for tool in gui.plot.toolbar.tools if isinstance(tool, BoxSelectTool)] + assert len(gui._SELECTION_TOOL_DOCS) == len(boxes) + html = gui._selection_tools_help_html() + assert html.count('src="data:image/png;base64,') == len(boxes) + assert "Zigzag-deselect dependents" in html +