deepof.utils

Functions and general utilities for the deepof package.

Functions

align_trajectories(data[, mode])

Remove rotational variance on the trajectories.

angle(bpart_array)

Return a numpy.ndarray with the angles between the provided instances.

arena_parameter_extraction(frame, arena_type)

Return x,y position of the center, the lengths of the major and minor axes, and the angle of the recognised arena.

automatically_recognize_arena(coordinates, ...)

Return numpy.ndarray with information about the arena recognised from the first frames of the video.

bp2polar(tab)

Return the DataFrame in polar coordinates.

bpart_distance(dataframe[, arena_abs, arena_rel])

Return a pandas.DataFrame with the scaled distances between all pairs of body parts.

closest_side(polygon, reference_side)

Find the closest side in other polygons to a reference side in the first polygon.

cluster_transition_matrix(cluster_sequence, ...)

Compute the transition matrix between clusters and the autocorrelation in the sequence.

compute_animal_presence_mask(quality[, ...])

Compute a mask of the animal presence in the video.

compute_areas(coords[, animal_id])

Compute relevant areas (head, torso, back, full) for the provided coordinates.

compute_dist(pair_array[, arena_abs, arena_rel])

Return a pandas.DataFrame with the scaled distances between a pair of body parts.

connect_mouse([animal_ids, ...])

Create a nx.Graph object with the connectivity of the bodyparts in the DLC topview model for a single mouse.

edges_to_weighted_adj(adj, edges)

Convert an edge feature matrix to a weighted adjacency matrix.

enumerate_all_bridges(G)

Enumerate all 3-node connected sequences in the given graph.

extract_polygonal_arena_coordinates(...)

Read a random frame from the selected video, and opens an interactive GUI to let the user delineate the arena manually.

filter_columns(columns, selected_id)

Given a set of TableDict columns, returns those that correspond to a given animal, specified in selected_id.

filter_short_bouts(cluster_assignments, ...)

Filter out cluster assignment bouts shorter than min_bout_duration.

fit_ellipse_to_polygon(polygon)

Fit an ellipse to the provided polygon.

full_outlier_mask(experiment, likelihood, ...)

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.

get_arenas(coordinates, tables, arena, ...)

Extract arena parameters from a project or coordinates object.

gmm_compute(x, n_components, cv_type)

Fit a Gaussian Mixture Model to the provided data and returns evaluation metrics.

gmm_model_selection(x, n_components_range, ...)

Run GMM clustering model selection on the specified X dataframe.

interpolate_outliers(experiment, likelihood, ...)

Mark all outliers in experiment and replaces them using a uni-variate linear interpolation approach.

iterative_imputation(project, tab_dict, lik_dict)

Perform iterative imputation on occluded body parts.

kleinberg(offsets[, s, gamma, n, T, k])

Apply Kleinberg's algorithm (described in 'Bursty and Hierarchical Structure in Streams').

load_segmentation_model(path)

load_table(tab, table_path, table_format[, ...])

Loads a table into a structured pandas data frame.

mask_outliers(time_series, likelihood, ...)

Return a mask over the bivariate trajectory of a body part, identifying as True all detected outliers.

moving_average(time_series[, lag])

Fast implementation of a moving average function.

rename_track_bps(loaded_tab, ...)

Renames all body parts in the provided dataframe.

retrieve_corners_from_image(frame, ...)

Open a window and waits for the user to click on all corners of the polygonal arena.

rolling_speed(dframe[, window, rounds, ...])

Return the average speed over n frames in pixels per frame.

rolling_window(a, window_size, window_step)

Return a 3D numpy.array with a sliding-window extra dimension.

rotate(p, angles[, origin])

Return a 2D numpy.ndarray with the initial values rotated by angles radians.

rupture_per_experiment(table_dict, ...[, ...])

Apply the rupture method independently to each experiment, and concatenate into a single dataset at the end.

scale_animal(feature_array, scale)

Scales features in the provided array.

scale_table(coordinates, feature_array, scale)

Scales features in a table controlling for both individual body size and interanimal variability.

set_missing_animals(coordinates, tab_dict, ...)

Set the coordinates of the missing animals to NaN.

simplify_polygon(polygon[, relative_tolerance])

Simplify a polygon using the Ramer-Douglas-Peucker algorithm.

smooth_boolean_array(a[, scale])

Return a boolean array in which isolated appearances of a feature are smoothed.

smooth_mult_trajectory(series[, alpha, w_length])

Return a smoothed a trajectory using a Savitzky-Golay 1D filter.

split_with_breakpoints(a, breakpoints)

Split a numpy.ndarray at the given breakpoints.

str2bool(v)

Return the passed string as a boolean.

tab2polar(cartesian_df)

Return a pandas.DataFrame in which all the coordinates are polar.