deepof.utils module

deepof.utils

Functions and general utilities for the deepof package.

deepof.utils.align_trajectories(data[, mode])

Remove rotational variance on the trajectories.

deepof.utils.angle(bpart_array)

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

deepof.utils.arena_parameter_extraction(...)

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

deepof.utils.automatically_recognize_arena(...)

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

deepof.utils.bp2polar(tab)

Return the DataFrame in polar coordinates.

deepof.utils.bpart_distance(dataframe[, ...])

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

deepof.utils.closest_side(polygon, ...)

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

deepof.utils.cluster_transition_matrix(...)

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

deepof.utils.compute_animal_presence_mask(quality)

Compute a mask of the animal presence in the video.

deepof.utils.compute_areas(coords[, animal_id])

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

deepof.utils.compute_dist(pair_array[, ...])

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

deepof.utils.connect_mouse([animal_ids, ...])

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

deepof.utils.edges_to_weighted_adj(adj, edges)

Convert an edge feature matrix to a weighted adjacency matrix.

deepof.utils.enumerate_all_bridges(G)

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

deepof.utils.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.

deepof.utils.filter_columns(columns, selected_id)

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

deepof.utils.filter_short_bouts(...[, ...])

Filter out cluster assignment bouts shorter than min_bout_duration.

deepof.utils.fit_ellipse_to_polygon(polygon)

Fit an ellipse to the provided polygon.

deepof.utils.full_outlier_mask(experiment, ...)

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.

deepof.utils.get_arenas(coordinates, tables, ...)

Extract arena parameters from a project or coordinates object.

deepof.utils.gmm_compute(x, n_components, ...)

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

deepof.utils.gmm_model_selection(x, ...[, ...])

Run GMM clustering model selection on the specified X dataframe.

deepof.utils.interpolate_outliers(...[, ...])

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

deepof.utils.iterative_imputation(project, ...)

Perform iterative imputation on occluded body parts.

deepof.utils.kleinberg(offsets[, s, gamma, ...])

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

deepof.utils.load_segmentation_model(path)

deepof.utils.load_table(tab, table_path, ...)

Loads a table into a structured pandas data frame.

deepof.utils.mask_outliers(time_series, ...)

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

deepof.utils.moving_average(time_series[, lag])

Fast implementation of a moving average function.

deepof.utils.rename_track_bps(loaded_tab, ...)

Renames all body parts in the provided dataframe.

deepof.utils.retrieve_corners_from_image(...)

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

deepof.utils.rolling_speed(dframe[, window, ...])

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

deepof.utils.rolling_window(a, window_size, ...)

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

deepof.utils.rotate(p, angles[, origin])

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

deepof.utils.rupture_per_experiment(...[, ...])

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

deepof.utils.scale_animal(feature_array, scale)

Scales features in the provided array.

deepof.utils.scale_table(coordinates, ...[, ...])

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

deepof.utils.set_missing_animals(...[, ...])

Set the coordinates of the missing animals to NaN.

deepof.utils.simplify_polygon(polygon[, ...])

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

deepof.utils.smooth_boolean_array(a[, scale])

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

deepof.utils.smooth_mult_trajectory(series)

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

deepof.utils.split_with_breakpoints(a, ...)

Split a numpy.ndarray at the given breakpoints.

deepof.utils.str2bool(v)

Return the passed string as a boolean.

deepof.utils.tab2polar(cartesian_df)

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