GlobalSpeedValidator class¶
Validate minimal movement speed.
The validation is of the average speed per trial. The validator can also interpolate the speed limit, i.e., impose the limit on the average speed from time=0 until any time point during the trial.
Methods and properties:¶
-
class
trajtracker.validators.
GlobalSpeedValidator
(enabled=True, origin_coord=None, end_coord=None, axis=<ValidationAxis.y: 2>, grace_period=None, max_movement_time=None, milestones=None, show_guide=False)¶ -
__init__
(enabled=True, origin_coord=None, end_coord=None, axis=<ValidationAxis.y: 2>, grace_period=None, max_movement_time=None, milestones=None, show_guide=False)¶ Constructor - invoked when you create a new object by writing GlobalSpeedValidator()
Parameters: - enabled (bool) – See
enabled
- origin_coord (int) – See
origin_coord
- end_coord (int) – See
end_coord
- axis (trajtracker.validators.ValidationAxis) – See
axis
- grace_period (number) – See
grace_period
- max_movement_time (number) – See
max_movement_time
- milestones (list) – See
milestones
- show_guide (bool) – See
show_guide
- enabled (bool) – See
-
axis
¶ The ValidationAxis on which speed is validated
- ValidationAxis.x or ValidationAxis.y: limit the speed in the relevant axis.
- ValidationAxis.xy: limit the diagonal speed
-
disable_event
¶ The event on which the object should be disabled. This will work only when the object is registered to an
EventManager
Note: This property is deprecated, use disable_events instead
Type: Event
-
disable_events
¶ The events on which the object should be disabled. This will work only when the object is registered to an
EventManager
Type: collection of Event objects
-
enable_event
¶ The event on which the object should be enabled. This will work only when the object is registered to an
EventManager
Note: This property is deprecated, use enable_events instead
Type: Event
-
enable_events
¶ The events on which the object should be enabled. This will work only when the object is registered to an
EventManager
Type: collection of Event objects
-
enabled
¶ Whether the object is currently functioning or disabled
Type: bool
-
end_coord
¶ The coordinate (x or y) in which the speed validation end (i.e., end-of-trial coordinate) The value of this attribute is a single number
-
get_expected_coord_at_time
(time)¶ Return the minimnal coordinate (x or y, depending on axis) that should be obtained in a given time
-
grace_period
¶ The grace period in the beginning of each trial, during which speed is not validated (in seconds).
-
guide
¶ An object (trajtracker.validators.GlobalSpeedGuide) that takes care of showing a visual guide for the speed limit (read-only property)
-
guide_line_length
¶ The length of the speed guide line (int)
-
guide_warning_time_delta
¶ If the time difference between the mouse/finger current coordinate and the required coordinate is less than this value, the visual line guide will change its color.
-
log_level
¶ Logging level of this object: trajtracker.log_none, log_error (default), log_warn, log_info, log_debug, log_trace
-
max_movement_time
¶ The maximal duration of a trial (in seconds).
-
milestones
¶ This attribute indicates how the overall speed limit (
max_movement_time
) should be interpolated.By default, the interpolation is linear. But you can define several milestones - e.g., “mouse/finger must complete X% of the way within Y% of the trial’s total duration”. The milestones split the trials into sections and define the speed goal per section. Within each section, the interpolation is linear.
Each milestone is defined by the duration and distance of the relevant section, specified as the percentage out of the total trial duration / total movement distance. The durations and distances of all milestones must sum to 1.0 (= 100%).
This property is an array of milestones. Each of them is a GlobalSpeedValidator.Milestone object (but when setting the property value, you can use a (time, distance) tuple/list instead).
-
movement_started
(time)¶ Called when the finger/mouse starts moving
-
origin_coord
¶ The coordinate (x or y) in which the speed validation starts The value of this attribute is a single number
-
reset
(time0=None)¶ Called when a trial starts - reset any previous movement
-
show_guide
¶ Whether to visualize the speed limit as a moving line (bool).
Note: Even when this is TRUE, you need to present() the guide line (validator.guide.stimulus) yourself by putting it in a
StimulusContainer
-
update_xyt
(position, time_in_trial, time_in_session=None)¶ Validate movement.
Parameters: - time_in_trial – Time from start of trial
- time_in_session – ignored
Returns: None if all OK; ExperimentError object if error
-