StimulusAnimator class¶
Move a stimulus in a predefined visual trajectory.
The trajectory is defined by a separate class, a “trajectory generator”, which defines where the stimulus should appear in each time point. The trajectory generator should have a get_traj_point() method, which gets a time point (a number, specifying seconds) and returns a dict with the trajectory info at that time point (‘x’, ‘y’, and ‘visible’ entries, all optional).
See CircularTrajectoryGenerator
for an example trajectory generator.
Methods and properties:¶
-
class
trajtracker.movement.
StimulusAnimator
(animated_object=None, trajectory_generator=None, position_shift=None)¶ -
__init__
(animated_object=None, trajectory_generator=None, position_shift=None)¶ Constructor - invoked when you create a new object by writing StimulusAnimator()
Parameters: - animated_object (Expyriment stimulus) – See
animated_object
- trajectory_generator – See
trajectory_generator
- position_shift (tuple) – See
position_shift
- animated_object (Expyriment stimulus) – See
-
animated_object
¶ The object being moved by this animator. The object should be an Expyriment visual stimulus - i.e., with a present(clear,update) method and a “position” property
-
do_clear_screen
¶ If true, the screen will be cleared on each frame by calling animated_object.present(clear=True)
-
do_update_screen
¶ If true, the screen will be updated on each frame by calling animated_object.present(update=True)
-
log_level
¶ Logging level of this object: trajtracker.log_none, log_error (default), log_warn, log_info, log_debug, log_trace
-
position_shift
¶ (x,y) coordinates. The coordinates generated by the
trajectory_generator
will be shifted by this amount before updatinganimated_object
This property can be set to x,y tuple/list or to an expyriment.geometry.XYPoint
-
reset
(time0=0)¶ Reset the movement. This does not move the object, it just resets the time
Parameters: time0 – The time that counts as zero (when calling the position-generator)
-
trajectory_generator
¶ An object that generates, per time point, the x,y coordinates where the animated object should be moved to
-
update
(time)¶ Call this function on each frame where you want the animated object to move.
Parameters: time – The time (typically - time from start of trial)
-