deepof.utils
Functions and general utilities for the deepof package.
Functions
|
Remove rotational variance on the trajectories. |
|
Return a numpy.ndarray with the angles between the provided instances. |
|
will applay a moving median like filter on a binary signal, i.e. if a window of size lag has more 1s than 0s set the frame to 1 for that window, set it to 0 otherwise. |
|
Return the DataFrame in polar coordinates. |
|
Return a pandas.DataFrame with the scaled distances between all pairs of body parts. |
|
Compute the transition matrix between clusters and the autocorrelation in the sequence. |
|
Compute a mask of the animal presence in the video. |
|
Compute polygon areas for the provided stack of sets of data point-xy coordinates. |
|
Compute polygon areas for the provided stack of sets of data point-xy coordinates. |
|
Return a pandas.DataFrame with the scaled distances between a pair of body parts. |
|
Create a nx.Graph object with the connectivity of the bodyparts in the DLC topview model for a single mouse. |
|
Counts the number of continuous blocks of 1s in a binary behavior vector in different ways |
|
Count transitions between successive behaviors for all experiments in tab_dict. |
|
Convert an edge feature matrix to a weighted adjacency matrix. |
|
Adjusts the positions of body parts in each frame to ensure that the distances between connected parts adhere to predefined skeleton constraints within a specified tolerance. |
Enumerate all 3-node connected sequences in the given graph. |
|
|
Takes a booelan array of behavior detections and extends each behavior detection by delta_T. |
|
Apply the rupture method independently to each experiment, and concatenate into a single dataset at the end. |
|
Filter a DataFrame to keep only those columns related to the selected id. |
|
Given a set of TableDict columns, returns those that correspond to a given animal, specified in selected_id. |
|
Filter out cluster assignment bouts shorter than min_bout_duration. |
|
Filters out sahort "True" sections from boolean array "array" |
|
Filters out sahort "True" sections from boolean array "array" |
|
Iterate over all body parts of experiment, and outputs a dataframe where all x, y positions are replaced by a boolean mask, where True indicates an outlier. |
|
Generates a boolean mask and a confidence dataframe for given behaviors. |
|
Calculates array of distances between 2D points and a polygon (roi) |
|
|
|
Get the number of all frames in all videos listed in the input dictionary |
|
Fit a Gaussian Mixture Model to the provided data and returns evaluation metrics. |
|
Run GMM clustering model selection on the specified X dataframe. |
|
mouse_pts: (N, 3, 2) or (3, 2), order [left_ear, nose, right_ear] Returns float array of shape (N,): 1.0 -> ROI intersects FOV 0.0 -> ROI does not intersect FOV np.nan -> cannot be calculated (invalid/degenerate geometry or non-finite points) Apex of FOV triangle is midpoint between ears. |
|
Numba version of in_field_of_view (no plotting, no shapely). |
Identify coord, speed, distance, and angle columns from a pose table. |
|
|
Perform iterative imputation on occluded body parts. |
|
Apply Kleinberg's algorithm (described in 'Bursty and Hierarchical Structure in Streams'). |
|
Computation intensive core part of Kleinberg's algorithm (described in 'Bursty and Hierarchical Structure in Streams'). |
|
Loads model for automatic arena segmentation |
|
Loads a table into a structured pandas data frame. |
|
Return a mask over the bivariate trajectory of a body part, identifying as True all detected outliers. |
|
Checks if a given animal for a given table is in a given roi by given criterion. |
|
Fast implementation of a moving average function. |
|
This filtering approach will first gradually merge together very close behavioral instances (how close is regulated by min_length), then filter out remaining short instances. |
|
Check if a set of points is inside a polygon. |
|
This function was generated by Perplexity.ai Check if a set of points is inside a polygon. |
|
Calculate the area of a single polygon given its vertices. |
|
Mark all outliers in experiment and replaces them using a uni-variate linear interpolation approach. |
|
Renames all body parts in the provided dataframe. |
|
Return the average speed over n frames in millimeters per second. |
|
Return a 3D numpy.array with a sliding-window extra dimension. |
|
Return a 2D numpy.ndarray with the initial values rotated by angles radians. |
|
Rotates Return a 2D numpy.ndarray with the initial values rotated by angles radians. |
|
Return a 2D numpy.ndarray with the initial values rotated by angles radians. |
|
argmax per row, ignoring NaNs. |
|
Implements the Rauch-Tung-Striebel (RTS) smoother for state estimation. |
|
|
|
Set the coordinates of the missing animals to NaN. |
|
Return a numpy.ndarray with the signed angles between the provided instances. |
|
LEGACY FILTER FOR BEHAVIORAL ANALYSIS. |
|
Return a smoothed a trajectory using a Savitzky-Golay 1D filter. |
|
Return the passed string as a boolean. |
|
Return a pandas.DataFrame in which all the coordinates are polar. |
|
A generic helper to validate a single parameter against a list of valid options. |
Classes
|
A class for imputing and processing mouse tracking data. |