Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
826d129
fix: colour only forbidden (shank, electrode) pairs in multi-shank PDFs
tabedzki Oct 30, 2026
1e5fb1b
refactor: return (0, 2) from find_forbidden_electrodes when empty
tabedzki Oct 30, 2026
c2fe0c2
Merge pull request #87 from tabedzki/tabedzki/fix/pdf-forbidden-mask
m-beau Oct 30, 2026
9abfc40
feat: zigzag dependent deselectior SVG icon
m-beau Nov 2, 2026
c0d1372
feat: add zigzag-deselect dependents box tool
tabedzki Nov 2, 2026
37e93c4
docs: fix "elese" typo in the GUI guide tip
tabedzki Nov 2, 2026
697dbdd
Merge pull request #89 from tabedzki/tabedzki/docs/fix-else-typo
tabedzki Nov 2, 2026
f3e0c69
Merge pull request #88 from tabedzki/tabedzki/feat/zigzag-deselect
m-beau Nov 2, 2026
0bc388c
fix: download cold atlases off the event loop on atlas switch
tabedzki Oct 30, 2026
d685694
fix: run every anatomy overlay compute off the event loop
tabedzki Oct 30, 2026
7504f2b
refactor: simplify off-loop anatomy pipeline after review
tabedzki Oct 30, 2026
bd3b26c
refactor: simplify code changed since v1.4.1
tabedzki Oct 30, 2026
faf32d9
Merge pull request #91 from tabedzki/tabedzki/fix/overlay-off-event-loop
tabedzki Nov 7, 2026
f523d80
fix: warm the first session before the server accepts connections
tabedzki Nov 7, 2026
15635de
test: tighten warmup coverage and correct its docs
tabedzki Nov 7, 2026
2b6ce90
perf: shrink the document every session builds on the event loop
tabedzki Nov 7, 2026
401bc57
Add CODEOWNERS for backend, GUI, documentation, and deployment
tabedzki Nov 7, 2026
a97fcf7
Merge pull request #94 from m-beau/t3/configure-codeowners
tabedzki Nov 7, 2026
e961d2e
Merge pull request #92 from tabedzki/tabedzki/fix/first-session-off-loop
tabedzki Nov 11, 2026
64afc5d
Merge pull request #93 from tabedzki/tabedzki/perf/session-build
tabedzki Nov 11, 2026
4854eff
chore: bump version to 1.5.1
tabedzki Nov 16, 2026
5552be0
Merge pull request #96 from m-beau/chore/release-1.5.1
tabedzki Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# GitHub uses the last matching rule for each file.
# Deployment, operations, and anything not assigned below.
* @tabedzki

# Backend: public API, channel-map generation, probe definitions, and wiring.
/pixelmap/__init__.py @m-beau
/pixelmap/backend.py @m-beau
/pixelmap/constants.py @m-beau
/pixelmap/types.py @m-beau
/pixelmap/wiring_maps/ @m-beau
/pixelmap/utils/imro.py @m-beau
/pixelmap/utils/probe_features.py @m-beau
/pixelmap/utils/survey.py @m-beau
/pixelmap/anatomy/ @m-beau
/scripts/refresh_registry_snapshot.py @m-beau
/generate_channel_maps.ipynb @m-beau

# Tests and reference data for backend behavior.
/tests/test_backend.py @m-beau
/tests/test_core_functionality.py @m-beau
/tests/test_public_api.py @m-beau
/tests/test_imro*.py @m-beau
/tests/test_wiring*.py @m-beau
/tests/test_survey.py @m-beau
/tests/test_anatomy*.py @m-beau
/tests/generate_imro_reference.py @m-beau
/tests/fixtures/ @m-beau

# Documentation, paper, and example layouts.
*.md @m-beau
*.rst @m-beau
/docs/ @m-beau
/paper/ @m-beau
/example*/ @m-beau
/CITATION.cff @m-beau

# GUI changes request review from both maintainers.
/pixelmap/gui/ @tabedzki @m-beau
/tests/test_gui*.py @tabedzki @m-beau

# Documentation build infrastructure remains part of deployment.
/docs/conf.py @tabedzki
/.readthedocs.yaml @tabedzki
Binary file modified docs/_static/dependent_deselector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/zigzag_dependent_deselector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions docs/gui-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand All @@ -131,7 +135,7 @@ The order is invisible most of the time, because every electrode in the box ends
The same first-come-first-served rule applies to textual selection (electrode IDs are consumed in the order you write them).

:::{tip}
The zigzag and interleaved selector always select the same preset of electrodes independently from where you start dragging the box (e.g. the interleaved selector will always select sites 1-2, 5-6, 9-10, never 3-4, 7-8, 11-12...). If you want to select the complementary channels of a range (e.g. not 1-2, 5-6, 9-10 but instead 3-4, 7-8, 11-12...), you can either use the textual selection box, or you can first make (1-2, 5-6, 9-10) unavailable through zigzag/interleaved-selecting associated electrodes somewhere elese on the probe then use the regular selection box to select the remaining available electrodes (your target).
The zigzag and interleaved selector always select the same preset of electrodes independently from where you start dragging the box (e.g. the interleaved selector will always select sites 1-2, 5-6, 9-10, never 3-4, 7-8, 11-12...). If you want to select the complementary channels of a range (e.g. not 1-2, 5-6, 9-10 but instead 3-4, 7-8, 11-12...), you can either use the textual selection box, or you can first make (1-2, 5-6, 9-10) unavailable through zigzag/interleaved-selecting associated electrodes somewhere else on the probe then use the regular selection box to select the remaining available electrodes (your target).
:::


Expand Down
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ log "NUM_PROCS $NUM_PROCS"
#
# --mem-log-frequency periodically logs RSS (via psutil) so an OOM kill
# (SIGKILL, exit 137) leaves a trail in the logs instead of nothing.
#
# --setup warms what the first session would otherwise load on the event loop,
# freezing every session and /liveness (see scripts/warm_first_session.py).
exec "$PYTHON_BIN" -m panel serve ./app.py \
--setup ./scripts/warm_first_session.py \
--address "$ADDRESS" \
--port "$INTERNAL_PORT" \
--allow-websocket-origin "$ALLOW_WEBSOCKET_ORIGIN" \
Expand Down
2 changes: 1 addition & 1 deletion pixelmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@
"save_to_imro_file",
]

__version__ = "1.5.0"
__version__ = "1.5.1"
__author__ = "Maxime Beau"
__email__ = "maxime@princeton.edu"
42 changes: 41 additions & 1 deletion pixelmap/anatomy/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,54 @@ def landmark_policy(name: str) -> str | None:
return None


@functools.lru_cache(maxsize=8)
#: Memo for :func:`derive_origin_from_ac`. A plain dict rather than
#: ``lru_cache`` because :func:`peek_origin_from_ac` needs to ask "is this one
#: known?" without computing it. Unbounded: one three-float entry per atlas.
_ac_origin_memo: dict[str, tuple[float, float, float] | None] = {}
#: One lock per atlas name, so concurrent callers (several sessions, or a quick
#: A→B→A switch) wait for the scan already running instead of starting another.
_ac_origin_locks: dict[str, threading.Lock] = {}
_ac_origin_locks_guard = threading.Lock()


def derive_origin_from_ac(name: str) -> tuple[float, float, float] | None:
"""Origin at the anterior-commissure decussation, from the annotation.

Returns canonical ``(AP, ML, DV)`` µm, or ``None`` if the atlas delineates
no anterior commissure. Same recipe used (and validated) for the WHS rat:
the AC's midline-crossing centroid. Requires the atlas (downloads if absent).

Slow the first time: it scans every voxel of the annotation (0.8 s for a
25 µm atlas, ~8 s at 10 µm), so the GUI only ever calls it from a worker
thread and uses :func:`peek_origin_from_ac` on the event loop. Memoised
per atlas and single-flight per name; exceptions are not cached, so a
failed lookup is retried.
"""
if name in _ac_origin_memo:
return _ac_origin_memo[name]
with _ac_origin_locks_guard:
lock = _ac_origin_locks.setdefault(name, threading.Lock())
with lock:
if name not in _ac_origin_memo: # else a concurrent caller's scan won
_ac_origin_memo[name] = _derive_origin_from_ac(name)
return _ac_origin_memo[name]


derive_origin_from_ac.cache_clear = _ac_origin_memo.clear


def peek_origin_from_ac(name: str) -> tuple[bool, tuple[float, float, float] | None]:
"""``(known, origin)`` for :func:`derive_origin_from_ac`, without computing it.

``known`` is False until something has derived this atlas's origin.
Instant and touches no atlas data, so it is safe on the event loop.
"""
if name in _ac_origin_memo:
return True, _ac_origin_memo[name]
return False, None


def _derive_origin_from_ac(name: str) -> tuple[float, float, float] | None:
atlas = get_atlas(name)
ac_ids = [int(s["id"]) for s in atlas.structures.values()
if "anterior" in s["name"].lower() and "commis" in s["name"].lower()]
Expand Down
21 changes: 13 additions & 8 deletions pixelmap/anatomy/schematic.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,21 @@ def _region_rgb(atlas, region_id: int) -> tuple[int, int, int]:


def _region_fill_rgba(label_img: np.ndarray, atlas) -> np.ndarray:
"""Map a 2D label slice to an RGBA image colored by atlas region."""
rgba = np.zeros((*label_img.shape, 4), dtype=float)
for region_id in np.unique(label_img):
if region_id == 0: # outside-brain / undefined
"""Map a 2D label slice to an RGBA image colored by atlas region.

One color per *distinct* region, then a single gather through the inverse
index. Masking the slice once per region instead (the obvious loop) costs
a full pass per region — 2.4 s of a 3.5 s render on a 10 µm atlas, whose
slices hold hundreds of regions.
"""
region_ids, inverse = np.unique(label_img, return_inverse=True)
palette = np.zeros((len(region_ids), 4), dtype=float)
for i, region_id in enumerate(region_ids):
if region_id == 0: # outside-brain / undefined: stays transparent
continue
r, g, b = _region_rgb(atlas, int(region_id))
mask = label_img == region_id
rgba[mask, :3] = (r / 255.0, g / 255.0, b / 255.0)
rgba[mask, 3] = _REGION_ALPHA
return rgba
palette[i] = (r / 255.0, g / 255.0, b / 255.0, _REGION_ALPHA)
return palette[inverse.reshape(label_img.shape)]


def _outline_rgba(label_img: np.ndarray) -> np.ndarray:
Expand Down
Loading
Loading