ethograph.labels.ml.get_labels_start_end_indices#
- ethograph.labels.ml.get_labels_start_end_indices(col, bg_class=0)[source]#
Return segment boundaries as sample indices (exclusive end).
Useful for slicing dense arrays or computing segment-level metrics.
- Parameters:
col (array-like) – 1-D dense label array.
bg_class (int) – Background class to ignore (default 0).
- Returns:
labels (list[int]) – Label class for each segment.
starts (list[int]) – Start index (inclusive) of each segment.
ends (list[int]) – End index (exclusive) — use
array[start:end]to slice.
Examples
>>> from ethograph.labels.ml import get_labels_start_end_indices >>> labels, starts, ends = get_labels_start_end_indices([0,1,1,1,0,2,2]) >>> labels [1, 2] >>> starts [1, 5] >>> ends [4, 7] >>> # To extract the first segment from a feature array: >>> # segment_features = features[starts[0]:ends[0], :]