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) - individual identifier event_type (str) - “state” (interval) or “point” (instantaneous)
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 individual. |
|
Drop interval by DataFrame index. |
|
Return DataFrame index of state interval containing time_s for individual. |
|
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. |