Annotation views¶
Figures that know about annotations: filmstrip, concordance, tier map, structure map.
Every other way this toolbox has of looking at a long recording is about the signal.
Hierarchy and the ELAN exporter sit on the other side of a gap almost nothing crosses, and
for somebody annotating hours of video that crossing is the tool.
tier_map—where is there anything to look at¶

Every tier as a density band across the recording. Brightness is the fraction of each column covered. Empty tiers are drawn as empty bands rather than omitted, because noticing what has not been annotated is half of what the view is for.
concordance—every instance of one category, side by side¶

The linguist's concordance applied to video. Coding 183 proposals one at a time, hours apart, is how a category drifts; seeing them together is how it does not. What the cap left out is stated on the figure, never silently.
filmstrip—what is actually happening here¶

Keyframes on the time axis with the annotation tiers beneath them, pinned to the same x-limits so a frame is never drawn above a span it does not belong to.
structure_map—where a recording repeats itself¶

A self-similarity matrix with somebody's coding drawn on it. Read its warning before using it: its defaults are measured, not assumed, and video features failed on the corpus it was written for.
Figures that know about annotations, which none of the toolbox's others do.
MGT already has a rich battery of ways to look at a long recording --- motiongrams,
videograms, self-similarity, tempograms, contact sheets, heatmaps, stroboscopes --- and
every one of them is about the signal. Hierarchy and the ELAN exporter live on the other
side of a gap that almost nothing crosses. For somebody annotating two and a half hours,
that crossing is the tool, and these are the four views that make it.
They correspond to what the three fields that use this material actually do:
filmstrip--- keyframes laid along the time axis under the annotation tiers. Human movement science reduces the spatial dimension so time becomes visible; this reduces it the other way, keeping enough picture to answer "what is happening here" without scrubbing.concordance--- every instance of one category side by side. This is the linguist's concordance applied to video, and it is what makes 183 laughter proposals codable consistently rather than one at a time, hours apart.tier_map--- every tier as a density band over the whole session. The "where is there anything to look at" view, and the one that shows which tiers are still empty.structure_map--- a self-similarity matrix with the annotation boundaries drawn on it. Music and movement structure analysis uses SSMs to find repeated material; drawing someone's coding on top asks whether their boundaries and the repetition agree. Read its warning before using it: it did not work on the corpus it was written for.
Split the way _voice is split. The parts with a right answer --- which frames to sample,
how a grid is shaped, how full a tier is, where a time falls in a matrix --- are the
functions below and are tested. Rendering is a thin layer over them.
sample_times ¶
sample_times(start_s, end_s, n)
n times spread across a span, kept strictly inside it.
Inside, not on the edges: a frame at exactly the end of a clip may not exist, and one
just inside always does. With n = 1 the time is the middle, which is the frame a
person would pick to represent a span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_s
|
float
|
Start of the span. |
required |
end_s
|
float
|
End of the span. May equal |
required |
n
|
int
|
How many times to return. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list[float]
|
The times, ascending. Empty when |
Source code in musicalgestures/_views.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
grid_shape ¶
grid_shape(n_items, n_cols=None)
Rows and columns for a grid of n_items.
Without a column count, as square as it can be and never taller than wide: a concordance is read across, and a tall narrow grid puts the instances a reader is comparing far apart on the page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_items
|
int
|
How many cells are needed. |
required |
n_cols
|
int
|
Columns to use, or None to choose. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[int, int]
|
(rows, columns). The last row may be partial; nothing is dropped. |
Source code in musicalgestures/_views.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
tier_density ¶
tier_density(spans, duration_s, n_bins)
What fraction of each time bin a tier covers.
Overlapping spans are merged first, so a bin cannot be more than full. Detectors emit touching and overlapping spans routinely, and a density above 1 is not a stronger signal, it is a broken one.
An empty tier returns zeros rather than an empty array, because an empty tier still has to be drawn: seeing which tiers are not yet filled is half of what this view is for.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spans
|
Actions, in any order. |
required | |
duration_s
|
float
|
Length of the recording. |
required |
n_bins
|
int
|
How many bins to divide it into. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: One fraction in [0, 1] per bin. |
Source code in musicalgestures/_views.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
time_to_index ¶
time_to_index(t, duration_s, n)
Where a time falls in an n-element series over duration_s.
Clamped, never wrapped. Annotations shifted from another recording's clock can land outside this one, and a wrapped index puts a boundary at the start of the session where it looks entirely plausible. Clamping puts it at the edge, where it looks wrong.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
The time, in seconds. |
required |
duration_s
|
float
|
Length the series covers. |
required |
n
|
int
|
Number of elements. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
An index in [0, n-1]. |
Source code in musicalgestures/_views.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
filmstrip ¶
filmstrip(video, start_s, end_s, n=12, hierarchy=None, levels=(), out=None, height=180, title=None)
Keyframes along the time axis, with the annotation tiers beneath them.
Answers "what is actually happening here" without scrubbing. The frames are sampled strictly inside the span and their exact times go in the sidecar, so a picture can always be traced back to a moment in the recording.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video
|
Path to the video. |
required | |
start_s
|
float), end_s (float
|
The span to cover. |
required |
n
|
int
|
How many frames. Defaults to 12. |
12
|
hierarchy
|
A |
None
|
|
levels
|
tuple
|
Which levels to draw. Empty means all of them. |
()
|
out
|
Output path. |
None
|
|
height
|
int
|
Frame height in pixels. Defaults to 180. |
180
|
title
|
Figure title. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
The image written. |
Source code in musicalgestures/_views.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
concordance ¶
concordance(video, spans, out, n_cols=None, label_key=None, height=150, title=None, max_items=60)
Every instance of one category, side by side.
The linguist's concordance applied to video. Coding 183 laughter proposals one at a time, hours apart, is how a category drifts; seeing them together is how it does not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video
|
Path to the video. |
required | |
spans
|
The Actions to show, in any order; they are sorted by time. |
required | |
out
|
Output path. |
required | |
n_cols
|
int
|
Columns, or None to choose a near-square layout. |
None
|
label_key
|
str
|
Which label to print under each frame, or None for the time. |
None
|
height
|
int
|
Frame height in pixels. |
150
|
title
|
Figure title. |
None
|
|
max_items
|
int
|
Cap, so a category with thousands of instances does not silently produce an unreadable figure. What was dropped is stated on the figure and in the sidecar, never silently. |
60
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
The image written. |
Source code in musicalgestures/_views.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
tier_map ¶
tier_map(hierarchy, duration_s, out, n_bins=600, title=None)
Every tier as a density band over the whole recording.
The "where is there anything to look at" view, and the one that shows which tiers are still empty --- an empty tier is drawn as an empty band rather than omitted, because noticing what has not been annotated is half of what this is for.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hierarchy
|
The levels to draw. |
required | |
duration_s
|
float
|
Length of the recording. |
required |
out
|
Output path. |
required | |
n_bins
|
int
|
Horizontal resolution. Defaults to 600. |
600
|
title
|
Figure title. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
The image written. |
Source code in musicalgestures/_views.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
structure_map ¶
structure_map(analysis_dir, duration_s, out, hierarchy=None, levels=(), max_columns=700, which='videogram_v', title=None, embed=None, smooth=None, features='audio', audio=None, n_mfcc=20)
A self-similarity matrix with somebody's annotation boundaries drawn on it.
Music and movement structure analysis uses self-similarity to find repeated material. Drawing a coding on top asks whether the boundaries somebody marked and the repetition the signal shows agree.
Use audio features unless you have a reason not to. That is the default, and the reason is measured. On this toolbox's dance corpus, where one session contains three performances of the same devised material, a usable feature should make those three resemble each other more than they resemble the rehearsal. Mean cosine separation:
=========================== ========== feature separation =========================== ========== chroma +0.252 spectral contrast +0.242 MFCC +0.234 videogram columns +0.029 hand-built activity profile -0.007 =========================== ==========
.. warning::
The video features did not work on the corpus this was written for, and the failure is in the features rather than in the drawing. A known-answer test is available there: one session contains three performances of the same devised material, so any usable feature should make those three resemble each other more than they resemble the rehearsal. Two were tried at 400 columns over 2 h 38 m. Videogram columns separated them by +0.029 in mean cosine similarity, which is nothing; a hand-built activity profile --- level, spread, burstiness and the envelope's own spectrum per block --- separated them by -0.007, the wrong way.
The reason is visible once stated: a videogram column encodes where in the frame the motion was, and over hours that mostly tracks where the dancers are standing. It is a position signal, and smoothing and time-delay embedding do not turn a position signal into a structure signal.
So features="videogram" is kept for material where the frame does carry
structure, and it is not the default. Whichever you use, check it against something
you already know before believing a figure: a self-similarity matrix always produces
a plausible-looking picture, which is exactly what makes it dangerous.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
analysis_dir
|
Directory holding the cached pyramid. |
required | |
duration_s
|
float
|
Length of the recording. |
required |
out
|
Output path. |
required | |
hierarchy
|
A |
None
|
|
levels
|
tuple
|
Which levels to draw. Empty means all. |
()
|
max_columns
|
int
|
Resolution of the matrix. Defaults to 700. |
700
|
which
|
str
|
Which pyramid to read. Defaults to |
'videogram_v'
|
title
|
Figure title. |
None
|
|
embed
|
int
|
Time-delay embedding: how many consecutive columns are stacked into each feature vector, so a vector describes a short passage rather than an instant. Defaults depend on the feature, because what rescues one handicaps the other. Videogram columns need it badly --- without it the matrix is one broad diagonal with no blocks --- so the default there is 12. MFCCs already describe a window's spectral envelope, and stacking dilutes them: on the corpus this was written for, embedding and smoothing cut the measured separation from +0.259 to +0.142. So the audio default is 1, meaning none. |
None
|
smooth
|
int
|
Columns to average before embedding. 9 for videogram; 3 for audio, which is the knee of a two-criterion sweep --- it keeps essentially all of the discrimination (+0.257 of a possible +0.259) while raising local coherence from 0.48 to 0.76, which is the difference between a readable figure and a mess of stripes. |
None
|
features
|
str
|
|
'audio'
|
audio
|
Path to a WAV for |
None
|
|
n_mfcc
|
int
|
How many MFCCs. Defaults to 20. |
20
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
The image written. |
Source code in musicalgestures/_views.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |