twoD/preprocess
Functions specifically related to preprocessing of 2D recordings
get_preprocessing_relevant_marker_ids
get_preprocessing_relevant_marker_ids (df:pandas.core.frame.DataFrame, marker_ids_to_exclude:Optional[Lis t[str]]=None)
Type | Default | Details | |
---|---|---|---|
df | DataFrame | DataFrame with x, y, and likelihood for tracked marker_ids | |
marker_ids_to_exclude | typing.Optional[typing.List[str]] | None | list of marker_ids to exclude; optional default None |
Returns | typing.List[str] |
get_all_unique_marker_ids
get_all_unique_marker_ids (df:pandas.core.frame.DataFrame)
smooth_tracked_coords_and_likelihood
smooth_tracked_coords_and_likelihood (df:pandas.core.frame.DataFrame, window_length:int, marker_ids:List[str]=['all'], polyorder:int=3)
Smoothes the DataFrame basically using the implementation from DLC2kinematics: https://github.com/AdaptiveMotorControlLab/DLC2Kinematics/blob/82e7e60e00e0efb3c51e024c05a5640c91032026/src/dlc2kinematics/preprocess.py#L64 However, with one key change: likelihoods will also be smoothed. In addition, we will not smooth the columns for the tracked LEDs and the MazeCorners.
Note: window_length has to be an odd integer!
Type | Default | Details | |
---|---|---|---|
df | DataFrame | DataFrame to smooth | |
window_length | int | Odd integer (!) of sliding window size in frames to consider for smoothing | |
marker_ids | typing.List[str] | [‘all’] | List of markers that will be smoothed; optional default [‘all’] to smooth all marker_ids |
polyorder | int | 3 | Order of the polynom used for the savgol filter |
Returns | DataFrame |
interpolate_low_likelihood_intervals
interpolate_low_likelihood_intervals (df:pandas.core.frame.DataFrame, marker_ids:List[str], max_interval_length:int, framerate:float)
get_low_likelihood_interval_border_idxs
get_low_likelihood_interval_border_idxs (likelihood_series:pandas.core.s eries.Series, framerate:float, max_interval_length:int, min_lik elihood_threshold:float=0.5)
add_new_marker_derived_from_existing_markers
add_new_marker_derived_from_existing_markers (df:pandas.core.frame.DataF rame, existing_markers:List[str], new_marker_id:str, likeliho od_threshold:float=0.5)
get_corner_coords_with_likelihoods
get_corner_coords_with_likelihoods (df:pandas.core.frame.DataFrame)
get_most_reliable_marker_position_with_likelihood
get_most_reliable_marker_position_with_likelihood (df:pandas.core.frame. DataFrame, marker_id:str, percent ile:float=99.95)
get_translation_vector
get_translation_vector (coords_to_become_origin:numpy.ndarray)
evaluate_maze_shape_using_open_corners
evaluate_maze_shape_using_open_corners (corners_and_likelihoods:Dict, tolerance:float)
compute_error_proportion
compute_error_proportion (query_value:float, target_value:float)
compute_angle_error
compute_angle_error (a:numpy.ndarray, b:numpy.ndarray, c:numpy.ndarray)
compute_distance_ratio_error
compute_distance_ratio_error (corners_and_likelihoods:Dict, open_corner_marker_id:str, side_id:str)
get_distance_between_two_points
get_distance_between_two_points (coords_point_a:numpy.ndarray, coords_point_b:numpy.ndarray)
get_conversion_factor_px_to_cm
get_conversion_factor_px_to_cm (coords_point_a:numpy.ndarray, coords_point_b:numpy.ndarray, distance_in_cm:float)
get_rotation_angle_with_open_corner
get_rotation_angle_with_open_corner (corners:Dict, side_id:str, translation_vector:numpy.ndarray, conversion_factor:float)
Function, that calculates the rotation angle of the maze considering the best matching open corner and the corresponding closed corner on the same side.
Returns: float: angle in radians
get_rotation_angle_with_closed_corners_only
get_rotation_angle_with_closed_corners_only (corners:Dict, translation_vector:numpy.nda rray, conversion_factor:float)
normalize_df
normalize_df (df:pandas.core.frame.DataFrame, normalization_parameters)
translate_df
translate_df (df:pandas.core.frame.DataFrame, translation_vector:<built- infunctionarray>)
rotate_df
rotate_df (df:pandas.core.frame.DataFrame, rotation_angle:float)
Type | Details | |
---|---|---|
df | DataFrame | DataFrame with 2D coordinates to be rotated |
rotation_angle | float | rotation angle in radians |
Returns | DataFrame |
convert_df_to_cm
convert_df_to_cm (df:pandas.core.frame.DataFrame, conversion_factor:float)
create_bodypart_objects
create_bodypart_objects (normalized_df:pandas.core.frame.DataFrame, fps:int)