Behavior clustering¶
Behavior clustering builds one vocabulary of behaviors across a selection of recordings, with
no labels and nothing to point at. Two methods do the grouping. The default, codebook_viterbi,
clusters a sample of frames into a codebook and decodes every frame against it, so its cost grows
in proportion to the video you pool. dtw_finch cuts each subject's trajectory into bouts at
the moments the pose changes, compares every pair of bouts, and groups them; it draws slightly
better boundaries but its cost grows with the square of the bout count, so it suits short studies.
Either way the result is a vocabulary you look at and name.
It answers "what does this animal do?": a cluster is a stretch of movement, and an instance is one performance of it with a real start and end.
What the hierarchy is built on. The clusters form a hierarchy, a nested series of
groupings from many small ones to a few large ones, and you label its nodes. It is derived from distance and nothing else: for dtw_finch, the
distance between bouts, compared with a warp tolerance so that a slow and a fast performance of the
same behavior can still match; for codebook_viterbi, the distance between the frames grouped into
its codewords. It is not derived from how often a behavior occurs, when in the recording it
happens, where in the arena it happens, or any label you have given it. dtw_finch's levels need
no threshold and no target count: it links each bout to its single nearest neighbour, takes the
connected groups of that graph, and repeats on the groups, so the levels are a consequence of the
data rather than a number anyone chose. There is no setting for how many clusters there are: a
label on a coarse node covers everything under it, a label on a finer node inside it is more
specific, and the rest stays unlabelled.
The fit is one job, and it leaves the run open rather than complete: a vocabulary is not a
result until somebody has looked at it. Labelling the clusters that deserve a name, anywhere in
the tree the fit found, is quick and reversible, and is done in the GUI's interpretation workspace
or from the CLI with analysis temporal-interpret.
For dtw_finch, the comparison is the cost, and it grows with the square of the bout count. Comparing every
pair is what lets a slow and a fast performance of the same behavior match, and it is why a fit
over a long study is expensive. Max bouts bounds it by evenly sampling the bouts the comparison
sees.
A cap changes what the vocabulary is learned from, not what gets labeled. Every remaining bout is matched to the nearest cluster afterwards, so the output still carries one instance per bout however low you set it. That distinction is the point of the module: bounding what it learns from is a quality trade, while bounding what it labels would just be missing data, and finding every occurrence is the job. The interpretation screen states which happened, since a capped fit is otherwise indistinguishable from a full one.
What a cap does cost is what a clustered bout has and an assigned one does not: a say in what the clusters are. So a node's most and least typical clips are ranked from clustered bouts only, and the run records both counts.
Coverage is partial, and that is correct. Bouts, and the codebook's runs, do not tile a recording: stretches shorter than the minimum bout length (or the codebook's minimum run) are dropped, and gaps in tracking are not bouts. A run reporting that its instances cover half the observed time is telling you how much of the recording the vocabulary actually accounts for, not reporting a fault.
Parameters¶
Recordings¶
source_recording_ids · array
Recordings to fit the vocabulary on. Every recording's bouts are pooled into one vocabulary, so a cluster common in one treatment and absent in another is directly comparable.
Embedding run¶
embed_run_id · string
Embedding run to read pose trajectories from, by id (e.g. emb_02): that id in every selected recording. Left unset, each recording's own run with the one set of embedding settings they all have is used, whatever its id, and the choice is refused when they share several: a vocabulary silently fitted on whichever sorted first would score differently tomorrow.
Track¶
track_id · integer · default 0 · range ≥ 0
Track (subject) to cluster, in each recording.
Method¶
method · string · default codebook_viterbi
Clustering method. codebook_viterbi builds a codebook of poses from a sample of each recording and decodes the whole trajectory against it; its cost grows in proportion to the video pooled. dtw_finch cuts each trajectory into bouts, compares every pair with banded DTW and groups them with FINCH; it draws slightly better boundaries, but its cost grows with the square of the bout count. The two tie on vocabulary quality. A registry key rather than a hardcoded call, so a further method needs no change here.