TrajectoryTracker class

Track mouse/finger trajectory and save results to a CSV file.

To use this class:

Methods and properties:

class trajtracker.movement.TrajectoryTracker(filename=None, enabled=False, track_if_no_movement=False)
__init__(filename=None, enabled=False, track_if_no_movement=False)

Constructor - invoked when you create a new object by writing TrajectoryTracker()

Parameters:
  • filename – The file to which the trajectory information will be saved (CSV).
  • enabled – See enabled
  • track_if_no_movement – See track_if_no_movement
disable_event

The event on which the object should be disabled. This will work only when the object is registered to an EventManager

Type:Event
enable_event

The event on which the object should be enabled. This will work only when the object is registered to an EventManager

Type:Event
enabled

Whether the object is currently functioning or disabled

Type:bool
get_xyt()

Get a list of (x,y,time) tuples - one per tracked point

init_output_file(filename=None, xy_precision=5, time_precision=3)

Initialize a new CSV output file for saving the results

Parameters:
  • filename – Full path
  • xy_precision – Precision of x,y coordinates (default: 5)
  • time_precision – Precision of time (default: 3)
log_level

Logging level of this object: trajtracker.log_none, log_error (default), log_warn, log_info, log_debug, log_trace

reset(time0=None)

Forget any previously-tracked points.

Parameters:time0 – ignored
save_to_file(trial_num)

Save the tracked trajectory (ever since the last reset() call) to a CSV file

Parameters:trial_num
Returns:The number of rows printed to the file
track_if_no_movement

Whether to record x,y,t if the coordinates did not change

update_xyt(position, time_in_trial, time_in_session=None)

Track a point. If tracking is currently inactive, this function will do nothing.

Parameters:time_in_session – ignored