merge_changepoints#

ethograph.features.changepoints.merge_changepoints(ds, vars=None, keep_dims=None)[source]#

Merge changepoint variables in a dataset into a single boolean mask.

Combines every raw changepoint mask (attrs["changepoint_mask"]; see ethograph.io.schema.is_changepoint()) using logical OR across all non-time dimensions — the smooth expansions of a mask are ordinary features and are not merged. All masks must share the same target_feature attribute.

Parameters:
  • ds (xr.Dataset) – Dataset containing one or more changepoint variables.

  • vars (sequence of str, optional) – Which changepoint masks to merge; default merges every one changepoint_vars() finds. Naming a variable that is not a changepoint mask is an error.

  • keep_dims (sequence of str, optional) – Dims to leave standing instead of ORing across — typically the individual dim, so one animal’s changepoints do not leak into another’s. Default collapses every non-time dim.

Returns:

  • ds (xr.Dataset) – Copy of the input with a new "changepoints" DataArray (float 0/1) replacing the merged changepoint variables.

  • target_feature (str) – The shared target_feature attribute from the input variables.

Raises:

ValueError – If changepoint variables reference different target features.