ethograph.labels.tsv_store#

TSV-based label storage for EthoGraph.

File format:

trial - trial identifier individual - individual performing the behaviour (actor) individual_rec - recipient of a dyadic behaviour (”” if none) labels - integer label class ID onset_s - start time in seconds (trial-relative) offset_s - end time in seconds (trial-relative) confidence - 1.0 for a human label, the model’s own score for

a predicted one

labeling_method - per label: “manual” | “automated” | “curated”

(see ethograph.labels.curation)

n_samples - per-trial sample count for dense conversion (int, 0 if unknown) changepoint_corrected - per-trial flag (0/1), repeated per row prediction_source - path to prediction file that produced this label (empty if human)

A human_verified column in an older file is carried along untouched and never read: whether a trial is reviewed is a question answered per label by labeling_method now.

Label names are managed centrally in mapping.txt.

Functions

labels_tsv_path

Derive the labels TSV path from the .nc file path.

validate_labels_tsv

Validate that a labels DataFrame has all required columns and values.

load_labels_tsv

Load labels from a TSV file.

save_labels_tsv

Save labels DataFrame to TSV.

get_trial_from_tsv

Extract all rows for a single trial from the all-labels DataFrame.

set_trial_in_tsv

Replace all rows for a trial in the all-labels DataFrame.

get_trial_meta

Read per-trial metadata from columns.

set_trial_meta_attr

Set a per-trial metadata column value for all rows of a trial.

init_empty_labels

Create empty labels DataFrame.

Constants

ethograph.labels.tsv_store.REQUIRED_COLUMNS = {'individual', 'labels', 'offset_s', 'onset_s', 'trial'}#

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

ethograph.labels.tsv_store.TSV_COLUMNS = ['trial', 'individual', 'individual_rec', 'labels', 'onset_s', 'offset_s', 'event_type', 'confidence', 'labeling_method', 'changepoint_corrected', 'prediction_source', 'n_samples']#

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

ethograph.labels.tsv_store.TRIAL_META_COLUMNS = ['changepoint_corrected', 'prediction_source', 'n_samples']#

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

ethograph.labels.tsv_store.TRIAL_META_DEFAULTS = {'changepoint_corrected': 0, 'n_samples': 0, 'prediction_source': ''}#

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)