ethograph.labels.intervals#
Interval-based label representation and core primitives for EthoGraph.
- Labels are stored as a pandas DataFrame with columns:
onset_s (float64) - start time in seconds offset_s (float64) - end time in seconds (NaN for point events) labels (int32) - label class ID (nonzero) individual (str) - the individual performing the behaviour (actor) individual_rec (str) - the recipient of a dyadic behaviour, “” if none event_type (str) - “state” (interval) or “point” (instantaneous) confidence (float64) - how sure the label is: 1.0 for a human label,
the model’s own score for a predicted one
- labeling_method (str) - who vouches for the label: “manual” (placed or
edited by hand), “automated” (a model’s output nobody has looked at) or “curated” (automated, then approved by a human) — the vocabulary of ndx-ethogram
individual and individual_rec together are the subject of a label:
each (actor, recipient) pair is its own independent track, exactly as each
individual was on its own before recipients existed. NO_RECIPIENT (“”)
means a solo behaviour — the default, and what every pre-recipient file reads
back as.
Use split_by_kind(df) at the top of every interval operation so points
pass through untouched. states_only(df) / points_only(df) are for
read-only consumers (dense conversion, plot rendering).
Functions
Create an empty intervals DataFrame with the correct columns and dtypes. |
|
Load a class-name ↔ index mapping file. |
|
Load a label mapping with colors for visualization. |
|
Write a label mapping back to disk, preserving branch and event_type. |
|
Add an interval, resolving overlaps for the same subject. |
|
Drop interval by DataFrame index. |
|
Return DataFrame index of state interval containing time_s for one subject. |
|
Return |
|
Drop intervals shorter than a threshold. |
|
Merge adjacent same-label intervals where gap <= max_gap_s. |
|
Snap interval onset/offset to nearest changepoint times. |