dispel.providers.generic.tasks.draw.shapes module#
A module dedicated to format user and reference trajectories.
- dispel.providers.generic.tasks.draw.shapes.AREA_RADIUS = 40#
The radius of a circle centered in the first reference point of a drawing shape that define the valid starting area.
- dispel.providers.generic.tasks.draw.shapes.CTR = (319, 639)#
Corner definitions, i.e. CTL for Corner Top Left, …
- dispel.providers.generic.tasks.draw.shapes.HALF_SCREEN_X = 187.5#
Define the half of the x axis of the screen.
- dispel.providers.generic.tasks.draw.shapes.HALF_SCREEN_Y = 406#
Define the half of the y axis of the screen.
- dispel.providers.generic.tasks.draw.shapes.SHAPE_BOUNDARIES = ((56, 319), (123, 639))#
Define boundaries of a square-like shape in order to detect if a user point is inside or outside the shape in the screen x and y axes coordinates.
- dispel.providers.generic.tasks.draw.shapes.SHAPE_SIZE = {'ADS': {'infinity': 1000, 'spiral': 779, 'square_clock': 1038, 'square_counter_clock': 1038}, 'BDH': {'infinity': 641, 'spiral': 607, 'square_clock': 124, 'square_counter_clock': 124}}#
Define the number of points of the reference shape.
- dispel.providers.generic.tasks.draw.shapes.bottom_left(data)[source]#
Return the bottom left part of a square-like shape (user/reference).
- Parameters:
data (DataFrame) – A pandas data frame containing at least a trajectory (x and y coordinates) of a square-like shape.
- Returns:
The bottom left part of the square-like shape given as input.
- Return type:
- dispel.providers.generic.tasks.draw.shapes.bottom_right(data)[source]#
Return the bottom right part of a square-like shape (user/reference).
- Parameters:
data (DataFrame) – A pandas data frame containing at least a trajectory (x and y coordinates) of a square-like shape.
- Returns:
The bottom right part of the square-like shape given as input.
- Return type:
- dispel.providers.generic.tasks.draw.shapes.check_is_in_area(ser, x_ref, y_ref)[source]#
Return if the user points are within a specific area.
The area is considered as the circle of 40 pts radius with x_ref and y_ref as its center.
- Parameters:
- Returns:
Whether the point is in the starting area or not.
- Return type:
- dispel.providers.generic.tasks.draw.shapes.extract_distance_axis_sc(data, ref)[source]#
Extract the distance between draws and reference perpendicular axes.
This function is specific to the square_clock shapes.
This distance is defined as follow: the distance between a user trajectory and an encountered perpendicular axis corresponding to a 90° trajectory change of the square-like shape. If the user overshoots (goes outside the square) the 90° trajectory change, the distance will be the perpendicular projection of the most distant user point to the axis and the axis itself. If the user never overshoot (stay within the square) the axis, the considered distance will be the perpendicular projection of the closest user point of the axis and the axis itself.
- Parameters:
- Returns:
A tuple composed of the extracted aforementioned distances (for the 3 axes).
- Return type:
- dispel.providers.generic.tasks.draw.shapes.extract_distance_axis_scc(data, ref)[source]#
Extract the distance between draws and reference perpendicular axes.
This function is specific to the square_counter_clock shapes.
This distance is defined as follow: the distance between a user trajectory and an encountered perpendicular axis corresponding to a 90° trajectory change of the square-like shape. If the user overshoots (goes outside the square) the 90° trajectory change, the distance will be the perpendicular projection of the most distant user point to the axis and the axis itself. If the user never overshoot (stay within the square) the axis, the considered distance will be the perpendicular projection of the closest user point of the axis and the axis itself.
- Parameters:
- Returns:
A tuple composed of the extracted aforementioned distances (for the 3 axes).
- Return type:
- dispel.providers.generic.tasks.draw.shapes.flag_valid_area(user, reference)[source]#
Add a series named isValidArea to determine if a point is valid.
e.g. if a point or a Series of point belongs to a draw which has triggered the starting area condition.
- Parameters:
- Returns:
The same pandas data frame given as input plus a pandas Series isValidArea.
- Return type:
- Raises:
ValueError – If no down touch action is detected.
- dispel.providers.generic.tasks.draw.shapes.generate_infinity()[source]#
Generate the ‘infinity’ level (shape).
- dispel.providers.generic.tasks.draw.shapes.generate_model_coordinates(level_name)[source]#
Generate the model coordinates for a given level name.
- Parameters:
level_name – The name of the desired level.
- Returns:
The 2 dimension numpy array corresponding to the desired level (shape).
- Return type:
Dict[str, numpy.ndarray]
- Raises:
ValueError – If the given level name is unrecognized.
- dispel.providers.generic.tasks.draw.shapes.generate_spiral()[source]#
Generate the ‘spiral’ level (shape).
- dispel.providers.generic.tasks.draw.shapes.generate_square_clock()[source]#
Generate the ‘squareClock’ level (shape).
- dispel.providers.generic.tasks.draw.shapes.generate_square_counter_clock()[source]#
Generate the ‘squareCounterClock’ level (shape).
- dispel.providers.generic.tasks.draw.shapes.get_max_dist_corner(user, attrib, ref, corner)[source]#
Retrieve the Fréchet distance within a corner zone.
The Fréchet distance is the maximum of the minimum distance between the user and the reference trajectories based on the dynamic time warping attributions.
- Parameters:
user (DataFrame) – The user trajectory user for computing the DTW attributions.
attrib (DataFrame) – The related dynamic time warping attributions for the considered reference trajectory with the user trajectory of interest.
ref (DataFrame) – The reference trajectory
corner (Tuple[int, int]) – The corner zone of the reference trajectory to consider.
- Returns:
The maximum of the minimum distances from DTW attributions within the considered corner zone.
- Return type:
- dispel.providers.generic.tasks.draw.shapes.get_proper_level_to_model(level_id)[source]#
Extract the correct camel type key to explore the ‘screen’ data set.
- dispel.providers.generic.tasks.draw.shapes.get_reference_path(level, height)[source]#
Extract the reference trajectory x and y coordinates.
- Parameters:
- Returns:
A pandas data frame composed of the reference trajectory x and y coordinates.
- Return type:
- dispel.providers.generic.tasks.draw.shapes.get_segment_deceleration(level_id)[source]#
Retrieve the segment of the deceleration profile of a given shape.
The aim of that is to compute intentional tremors for square-like shapes. Segments on which to compute intentional tremors have been determined by capturing the velocity profile of each shape against 50 Healthy Control Participants evaluations. For each shape, the segment is defined as model points where the mean velocity is comprised between 50% and 20% of the maximum of the velocity profile.
- dispel.providers.generic.tasks.draw.shapes.get_user_path(data, reference, height)[source]#
Extract user path coordinates, timestamps and touch actions.
- Parameters:
- Returns:
A pandas data frame composed of user path coordinates, timestamps, touch actions and the valid or non valid flag.
- Return type:
- dispel.providers.generic.tasks.draw.shapes.get_valid_path(data)[source]#
Keep only the valid trajectory of the user.
- dispel.providers.generic.tasks.draw.shapes.get_valid_up_sampled_path(data)[source]#
Extract an up sampled user trajectory.
It starts by filtering and keeping only the valid trajectory, then remove x and y potential duplicates (needed for the interpolation), and then apply the interpolation. It only returns a pandas data frame composed of x and y up sampled user coordinates, namely
x
andy
.
- dispel.providers.generic.tasks.draw.shapes.remove_overshoots(data, reference)[source]#
Format data to remove overshoots from user trajectory.
Set the first user point as the closest point from the head of the reference trajectory and set the last user point as the closest point from the tail of the reference trajectory.
- Parameters:
- Returns:
The user data without overshoots (head and tail).
- Return type:
- dispel.providers.generic.tasks.draw.shapes.remove_reference_head(data, reference)[source]#
Remove the reference head if the first user point doesn’t match.
The function removes the reference head when the reference point that is the closest to the first user point is different from the first reference point.
- Parameters:
- Returns:
The reference trajectory without the head if needed.
- Return type:
- dispel.providers.generic.tasks.draw.shapes.sc_corners_max_dist(user, ref, attrib)[source]#
Compute maximum distance per corner zones.
For square clock shapes.
- Parameters:
- Return type:
- ref
A pandas data frame composed of at least the reference trajectory.
- attrib
The related dynamic time warping attributions for the considered reference trajectory with the user trajectory of interest.
- dispel.providers.generic.tasks.draw.shapes.scc_corners_max_dist(user, ref, attrib)[source]#
Compute maximum distance per corner zones.
For square counter clock shapes.
- Parameters:
user (DataFrame) – A pandas data frame composed of at least the user trajectory used for computing DTW attributions.
ref (DataFrame) – A pandas data frame composed of at least the reference trajectory.
attrib (DataFrame) – The related dynamic time warping attributions for the considered reference trajectory with the user trajectory of interest.
- Returns:
A tuple composed of the extracted aforementioned distances (for the 3 related corners).
- Return type:
- dispel.providers.generic.tasks.draw.shapes.top_left(data)[source]#
Return the top left part of a square-like shape (user/reference).
- Parameters:
data (DataFrame) – A pandas data frame containing at least a trajectory (x and y coordinates) of a square-like shape.
- Returns:
The top left part of the square-like shape given as input.
- Return type:
- dispel.providers.generic.tasks.draw.shapes.top_right(data)[source]#
Return the top right part of a square-like shape (user/reference).
- Parameters:
data (DataFrame) – A pandas data frame containing at least a trajectory (x and y coordinates) of a square-like shape.
- Returns:
The top right part of the square-like shape given as input.
- Return type: