geometries#
- prey_capture_python.analysis.geometries.azimuth_from_center(mouse_xy, headbase_xy, cricket_xy, start, end)#
Function to calculate the angle between the mouse and the cricket, azimuth, using the center of mass of the mouse. This is based on the Matlab code used to calculate geometries for the HMM (ConvertDLCtoGeometry.m in Prey-Capture-SSM). :param mouse_xy: an n x 2 array of coordinates over time :type mouse_xy:
numpy.ndarray
:param cricket_xy: an n x 2 array of coordinates over time :type cricket_xy:numpy.ndarray
:param headbase_xy: an n x 2 array of coordinates over time :type headbase_xy:numpy.ndarray
- Returns
an array containing azimuth values over time
- Return type
az (
numpy.ndarray
)
- prey_capture_python.analysis.geometries.azimuth_from_ears(mouse_xy, cricket_xy, rear_xy, lear_xy, start, end)#
Function used to calculate angle between mouse and the cricket, azimuth, using the ears and center of the head. Based on calculations used for azimuth in the Niell Lab. :param mouse_xy: an n x 2 array of coordinates over time :type mouse_xy:
numpy.ndarray
:param cricket_xy: an n x 2 array of coordinates over time :type cricket_xy:numpy.ndarray
:param headbase_xy: an n x 2 array of coordinates over time :type headbase_xy:numpy.ndarray
- Returns
an array containing azimuth values over time
- Return type
az (
numpy.ndarray
)
- prey_capture_python.analysis.geometries.distance(xy1, xy2, start, end)#
Function used to calculate speeds during the prey capture trial. Can be used for either mouse or cricket speeds. :param xy1: an n x 2 array of coordinates over time :type xy1:
numpy.ndarray
:param xy2: an n x 2 array of coordinates over time :type xy2:numpy.ndarray
- Returns
- an array containing distance between two
objects over time
- Return type
dist (
numpy.ndarray
)
- prey_capture_python.analysis.geometries.geometries(cricket_xy, mouse_xy, rear_xy, lear_xy, headbase_xy, cricket_p, cricket_front, cricket_back, fr=200)#
function to calculate geometric variables from DLC points these geometries can then be used for metrics such as time to capture potential to be adapted to calculate all geometries needed for HMM run extract_points before running this to get needed coordinates
- Parameters
cricket_xy (
numpy.ndarray
) – thresholded cricket xy coordinatescricket_p (
numpy.ndarray
) – cricket probability valuesmouse_xy (
numpy.ndarray
) – mouse xy coordinatesrear_xy (
numpy.ndarray
) – xy coordinates of right ear, needed for azimuth calclear_xy (
numpy.ndarray
) – xy coordinates of left ear, needed for azimuth calcfr (int) – framerate of videos, default=200
- Returns
distance between mouse and cricket mouse_spd (
numpy.ndarray
): mouse speed cricket_spd (numpy.ndarray
): cricket speed az (numpy.ndarray
): azimuth (angle of mouse head to cricket)- Return type
range (
numpy.ndarray
)
- prey_capture_python.analysis.geometries.length(cricket_front, cricket_back)#
- prey_capture_python.analysis.geometries.relentless_positivity(df: pandas.core.frame.DataFrame, column: str, window: int = 20, threshold: float = 0.95, tolist: bool = True) Union[List[List[int]], numpy.ndarray] #
Find ranges where column is above threshold for #window number of rows
- Returns
List of Lists indicating the start and end of positive ranges
- prey_capture_python.analysis.geometries.speed(xy, start, end, win: int = 12, fr: int = 200)#
Function used to calculate speeds during the prey capture trial. Can be used for either mouse or cricket speeds. :param xy: an n x 2 array of coordinates over time :type xy:
numpy.ndarray
:param win: smoothing window :type win: int :param fr: framerate of video :type fr: int- Returns
an array containing speed values over time
- Return type
speed (
numpy.ndarray
)