Event class

This class defines an event that occurred during the experiment. Several TrajTracker objects can define things that should happen when an event occurs, or some time later. For example, stimuli can appear or disappear at certain times.

Defining an event:

number_line = trajtracker.stimuli.NumberLine()
number_line.onset = Event("SessionStarts")
number_line.offset = Event("SessionStarts")

Defining stimulus behavior via events requires that you use EventManager in your program.

TrajTracker also has some Pre-defined Events.

Advanced: Event Hierarchy

You can group several events into a hierarchy of “is a” relation. Event A is saied to extend event B if A is a subtype of B. For example, trajtracker defines TRIAL_SUCCEEDED and TRIAL_ERROR events, both of which extend the TRIAL_ENDED event, because these are two subtypes of the “end of trial” situation.

The advantage of creating such hierarchies is that when the program dispatches a TRIAL_SUCCEEDED or a TRIAL_ERROR event, any operation registered to run on TRIAL_ENDED would be invoked too.

To define hierarchies in your custom events, use the “extends” argument when creating the Event object:

TRIAL_ENDED = Event("TRIAL_ENDED")
TRIAL_SUCCEEDED = Event("TRIAL_SUCCEEDED", TRIAL_ENDED)
TRIAL_ERROR = Event("TRIAL_ERROR", TRIAL_ENDED)

Methods and properties:

class trajtracker.events.Event(event_id, extends=None)
__init__(event_id, extends=None)

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

Parameters:
event_hierarchy

The present event, and all the events it extends

event_id

The ID of this event (string)

extends

The event that the present event extends (or None)

log_level

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

offset

An offset (in seconds) relatively to the time the event occurred

static parse(text)

Parse a string into an event object. “None” is acceptable.