Skip to content

Merge dev into main: PySide6, multi-animal identity, image lane - #259

Merged
gbradham merged 54 commits into
mainfrom
dev
Nov 29, 2026
Merged

gbradham merged 54 commits into
mainfrom
dev

Conversation

@gbradham

@gbradham gbradham commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Brings dev up to main, following CONTRIBUTING's rule that dev merges into main at release time. main has no commits that dev lacks.

What lands on main

Testing

After merging

Existing installs need to re-run the installer, or uv sync --extra pc; on the Pi, re-run install.sh or the update script, because Qt now comes from pip.

gbradham and others added 30 commits November 5, 2026 11:19
Adds an optional image lane beside the keypoint features: a causal crop
around the animal, a YOLO segmentation mask, mask-shape descriptors, masked
DINOv2 ViT-S/14 and the mmv2 pose-model neck, reduced by a PCA fitted on the
training sessions only and windowed past-only (value, mean, std, diff).

- image_lane.py: config, crop tracker, encoder, per-session raw cache,
  PCA artifact stored in the model bundle, one window function shared by
  training, offline scoring and the live stream.
- Wired into training, cross-validation, batch scoring and the live
  pipeline (image_lane=True); lane columns are NaN-tolerant, so a missed
  mask leaves the keypoint features usable.
- Live display now draws its overlay on a copy of the frame, so stages
  that read pixels downstream no longer see it.

Reproduces the research pipeline: PyMouse leave-one-mouse-out 0.776
centred / 0.768 live (research 0.778 / 0.768); Blast leave-one-session-out
0.834 -> 0.842 with the lane.
Flow timing part B. With timing.flow_loop_thread on (or GLIDER_FLOW_THREAD=1),
FlowEngine, HardwareManager and every board and device coroutine run on one
daemon thread with its own asyncio loop, so paint, frames and widget work stop
delaying flow steps. Off by default until it is proven on every board.

- core/flow_loop.py: the thread, @on_flow_loop (hops a coroutine there and
  awaits it; straight through when off or already there), call_on_gui,
  post_to_loop, and estop_entry, which pings the flow loop and runs the stop
  on the caller's loop if it does not answer in 250 ms.
- BaseBoard/BaseDevice wrap every public coroutine method, plugins included,
  since the GUI awaits device methods directly in many places.
- Risk sites: Telemetrix is_connected posts its link-loss repair to the
  board's loop; zone/behavior nodes post outputs from the vision thread;
  VideoPlayback builds its window on the GUI thread; session-change reaches
  the GUI through a queued signal.

Benchmark (GUI busy 12 ms of every 16, 20 ms flow-clock waits): p95 lateness
12.6 ms -> 0.15 ms when the GUI work is native; no gain when it is pure
Python, which holds the GIL.
… current

The board-drop dialog ran dialog.exec() inside an asyncio task step, so
asyncio refused to step every other task (flow, pause, recorder) and the
app froze. Open it with open() instead.

The link supervisor now polls boards too and starts on every connect, so
an unplugged Arduino reads Disconnected on an idle rig. Board state
changes repaint device rows, including the run panel. GenericSerialDevice
owns its link and notices its USB port disappearing.
…e-persistence-156bdf

fix(hardware): survive Arduino unplug mid-run; accurate device link status
The engine reports (node_id, active) from when execution reaches a node
until it fires an exec output or returns; the canvas lights that node's
border green, lingering 400 ms so instant nodes still visibly flash.
# Conflicts:
#	src/glider/core/hardware_manager.py
…ht-0ba7b7

Highlight the active node while a flow runs
…-app training

- Add Images / Videos: copy image files in as they are (grouped by folder,
  original file name kept in FrameRecord.source) alongside video extraction
- Grid: search box (file, video, frame number); split shown as a coloured dot;
  stat tiles no longer draw dark label backgrounds
- Drop the one-video leak notice (nothing to act on); keep the per-video one
- Tool rail: each tool named under its glyph, with a TOOL heading
- Train Model: exports, then trains YOLO in a child QProcess with a live log,
  epoch progress and Stop; runs land in <project>/runs/
- Fix: Add dialog OK stayed disabled after picking files
Right-click a tile (Open, Move to split, Skip/Unskip, Delete), the selection
bar's Delete button, or the Delete/Backspace key. Confirms first, naming how
many are annotated; removes the image and label files and clears undo.
StudioProject.remove_frames forgets an image folder left empty.
…tabs

Numbered badge (tick when done), title, blue underline on the current step,
full-width bar. Replaces the rounded StepChip look so every step-by-step tool
reads the same.
…ose subtitle

macOS drew Behavior Analysis's tab bar base natively (grey bar, raised
selected tab), so it never matched Batch Pose's step strip. Turn the base off
and paint the bar from tools.qss with the strip's colour and bottom line.
Batch Pose's header loses its subtitle, like Behavior Analysis's.
The identity assigner now takes the frame timestamp and allows
max_travel_px per elapsed camera frame (at fps), so a CV pipeline that
drops frames no longer loses a fast-moving animal's name. The relabel
window spans camera frames by time too. Without timestamps each update
still counts as one frame.
…on clear

An appearance-mode slot never observed was reported at (0,0) and could
occupy a zone; ZoneTracker now skips hidden objects with age 0.
clear_identity also resets attached per-animal behaviour classifiers.
The export indexed rows by the logger's frame counter, which drifts from
the video when the logger starts first or frames go unlogged. Each row
now lands on video frame round((timestamp - t0) * fps), with t0 the
recorder's first written frame and fps its measured rate (new public
first_frame_timestamp / fps properties). With identity on, frames the CV
queue supersedes still get an empty log row. The export runs in a worker
thread at Stop.
gbradham and others added 24 commits November 23, 2026 17:04
The camera settings dialog now warns and saves nothing when two animals
share a name or Name at start has no animals. CVSettings.from_dict drops
animals with no name.
… time

A mid-run Pause leaves a gap in the raw video that t0 + i/fps cannot see, so
every row after it was shifted (or dropped past the end). The recorder now
keeps each written frame's capture timestamp; rows go to the nearest frame
within half a frame interval, and rows logged while paused are dropped.
Firing an exec output cleared the source's highlight, but a Loop keeps
running after it fires body. Nodes list such outputs in STAYS_ACTIVE_ON
and clear when execute returns instead. Fixes LL-37.
Resolve conflicts with the Train tab's Options sections and the live
pipeline's frame consumers: the Image lane checkbox joins main's Extra
features row and summary, and the pipeline keeps both the lane worker and
the frame consumers.
test_radius_scale accepts a scale token, a line marked geometric, or a bare
0; 0px is none of those, so the suite failed on tools.qss:671.
test_radius_scale accepts a scale token, a line marked geometric, or a bare
0; 0px is none of those, so the suite failed on tools.qss:671.
Keep a running Loop lit through its body and waits
…er-680163

feat(behavior): image-embedding lane for the behaviour classifier
Live multi-animal identity for closed-loop flows
PySide6 is LGPL where PyQt6 is GPL, which keeps a closed-source GLIDER
possible. Imports move to PySide6, pyqtSignal/pyqtSlot become
Signal/Slot, sip.isdeleted becomes shiboken6.isValid, and
QWIDGETSIZE_MAX (not exported by PySide6) is defined locally.

glider/__init__ sets QT_API and PYQTGRAPH_QT_LIB so pyqtgraph,
matplotlib and qasync cannot pick up a leftover PyQt6. The pc and rpi
extras depend on PySide6-Essentials>=6.8.0.2, the newest with a wheel
for Raspberry Pi OS Bookworm; the Pi installer, image and update script
install the rpi extra and libxcb-cursor0 instead of apt's python3-pyqt6.
pytest-qt runs with qt_api = pyside6.
Commit the file (it was gitignored) so cloud sessions, which clone fresh,
follow the rule too.
PyQt6 accepted drawPolygon/drawPolyline with the points as separate
arguments; PySide6 takes a single polygon and raised mid-paint, which
left the canvas half-drawn and later crashed pyqtgraph during garbage
collection.
PySide6 ignores QMenu.exec patched onto the class (exec has static and
instance overloads, and an instance call bypasses the class attribute),
so the real modal menu opened and the hardware-panel test hung. The new
capture_menu_exec fixture swaps the module's QMenu for a subclass whose
exec does the capturing.
- QPen takes no cap=/join= keywords: build round pens with setters.
- The camera panel's status message goes to the window's own status bar;
  findChild returned a replaced bar not yet deleted.
- Tests: QTest's modifier is positional (PySide6 calls it stateKey),
  QAction.disconnect() needs a signal, QImage.bits() is a sized
  memoryview, font().family() is the requested face (use fontInfo), and
  waitSignal on a worker's signal returns before the main-thread slot runs.
Under PySide6 a lambda, closure or partial connected to a signal emitted
on a worker thread runs on that thread, even with QueuedConnection; only
a bound method of a GUI-thread QObject is queued to the GUI thread.
PyQt6 queued lambdas too, so these were safe before and are not now:

- Behavior Analysis Apply: finished/failed tore the thread down, updated
  widgets and started the next video from the worker thread.
- Behavior Analysis cohort speed: progress bar, message box and buttons.
- The annotator's speed-worker bookkeeping raced its stop path.
- retire_thread's release runs on the finishing thread; guard its list.
- The flow engine's node-active callback goes through a signal, since it
  fires on the flow loop thread when that setting is on.

Also corrects the flow_loop docstring, and makes a qthreads test wait for
its worker to start and not time out while the GUI thread is busy.
Switch the Qt binding from PyQt6 to PySide6
@gbradham
gbradham marked this pull request as ready for review November 29, 2026 19:46
@gbradham
gbradham merged commit f68bb38 into main Nov 29, 2026
8 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.

1 participant