deepof.annotation_utils.detect_activity
- deepof.annotation_utils.detect_activity(speed_dframe: DataFrame, likelihood_dframe: DataFrame, tol_speed: float, tol_likelihood: float, min_length: int, center_name: str = 'Center', animal_id: str = '')
Return true when the mouse is either moving (moving), standing still and either moving (active) or not moving (passive).
- Design considerations:
Detecting immobility and activity is relatively straightforward by mostly just checking speed thresholds on bodyparts. The main problem arises from getting a lot of “flickering” out of the detections, as bodyparts from frame to frame may be just above or below that threshold. Respectively most of the detect_activity algorithm is a series of filtering steps to alternatingly smooth the predictions and sharpening the edges of predicted behavior.
- Parameters:
speed_dframe (pandas.DataFrame) – speed of body parts over time
likelihood_dframe (pandas.DataFrame) – likelihood of body part tracker over time, as directly obtained from DeepLabCut
tol_speed (float) – Maximum tolerated speed for the center of the mouse
tol_likelihood (float) – Maximum tolerated likelihood for the nose.
min_length (int) – minimum length that True segments need to have to not get filtered out.
center_name (str) – Body part to center coordinates on. “Center” by default.
animal_id (str) – ID of the current animal.
- Returns:
True if the animal is standing still and is active, False otherwise stationary_passive (np.array): True if the animal is standing still and is passive, False otherwise mobile (np.array): True if the animal is not standing still, False otherwise
- Return type:
stationary_active (np.array)