deepof.utils.count_transitions

deepof.utils.count_transitions(tab_dict: deepof_table_dict, exp_conditions: dict, bin_info: dict | None = None, animals_in_roi: list | None = None, delta_T: float = 0.5, frame_rate: float = 1, silence_diagonal: bool = False, aggregate: str = True, normalize: str = True, diagonal_behavior_counting: str = 'Transitions')

Count transitions between successive behaviors for all experiments in tab_dict.

Parameters:
  • tab_dict (table_dict) – Dictionary with behavior data (supervised or unsupervised soft_counts)

  • exp_conditions (dict) – Dictionary containg the experiment conditions for each experiment.

  • bin_info (dict) – dictionary containing indices to plot for all experiments

  • animals_in_roi (list) – List of ids of the animals that need to be inside of the active ROI. All frames in which any of the given animals are not inside of the ROI get excluded

  • delta_T – Time after the offset of one behavior during which the onset of the next behavior counts as a transition

  • frame_rate (float) – Frame rate of the corresponding project

  • silence_diagonal (bool) – If True, diagonals are set to zero.

  • aggregate (bool) – If True, sums matrices per experimental condition; else per experiment.

  • normalize (bool) – Row-normalizes transition probabilities if True. Default=True.

  • diagonal_behavior_counting (str) – How to count diagonals (self-transitions). Options: - “Frames”: Total frames where behavior is active (after extension) - “Time”: Total time where behavior is active - “Events”: number of instances of the behavior occuring - “Transitions”: number of frame-wise internal behavior transitions e.g. A behavior of 4 frames in length would have 3 transitions.

Returns:

Dictionary of transition matrices. Keys:
  • If aggregate=True: Condition labels (e.g., {‘control’: array(…)})

  • If aggregate=False: Experiment IDs (e.g., {‘exp1’: array(…)})

columns (list): Behavior names (columns after dropping non-binary features). combined_columns (list): All possible behavior transition pairs (e.g., [‘BehaviorA-x-BehaviorB’, …]).

Return type:

transitions_dict (dict)