StimulusSelector class¶
This object keeps several expyriment stimuli, and can define one of them as active.
You can then handle the active stimulus: present it, modify its position.
Using this class¶
This class is useful when you have a stimulus that can change during a trial, and you want to change the stimulus independently of presenting and moving it. For example, suppose a moving rectangle should repeatedly changes its color between red and green according to some logic. You can:
- Define two rectangles with the same size, one red and one green (this is better than repeatedly changing the color of a single rectangle: replotting the stimulus on every frame would be time-consuming)
- Create a StimulusSelector
- Add the two rectangles to the selector using
StimulusSelector.add_stimulus
- To move the rectangle, change
StimulusSelector.position
. - To change the rectangle color, use
StimulusSelector.activate
.
Methods and properties:¶
-
class
trajtracker.stimuli.
StimulusSelector
(stimuli=())¶ -
__init__
(stimuli=())¶ Constructor - invoked when you create a new object by writing ChangingStimulus()
Parameters: stimuli – A list of stimuli to add. Each entry in the list is a (key, stimulus) pair - see add_stimulus()
-
activate
(key)¶ Set one of the stimuli as the active one.
Parameters: key – The key of the stimulus, as set in add_stimulus()
-
active_stimulus
¶ Get the expyriment stimulus currently active
-
add_stimulus
(key, stim)¶ Add a stimulus
Parameters: - key – Identifier (logical name) for this stimulus
- stim – The actual expyriment stimulus
-
log_level
¶ Logging level of this object: trajtracker.log_none, log_error (default), log_warn, log_info, log_debug, log_trace
-
offset_event
¶ The time when the object should disappear from screen.
Type: Event
, or None to avoid automatic offset.
-
onset_event
¶ The time when the object should appear on screen.
Type: Event
, or None to avoid automatic onset.
-
position
¶ The position of the active stimulus. When you update this, positions of all stimuli will be updated.
-
present
(clear=True, update=True)¶ present the active stimulus :return: The function’s running time
-