The most common way to present visual stimuli is using the sketchpad item, or, for non-time-critical stimuli, the feedback item.
- Using the sketchpad and feedback items
- Using show-if expressions
- The difference between sketchpad and feedback items
- Presenting visual stimuli in Python inline script
Using the sketchpad and feedback items
The sketchpad and feedback item offer basic what-you-see-is-what-you get drawing tools (Figure 1).
Using show-if expressions
You can use show-if expressions to determine whether or not a particular element should be shown. For example, if you have an image of a happy face that should be shown only when the variable
valence has the value 'positive', then you can set the show-if expression for the corresponding image element to:
valence == 'positive'
If you leave a show-if expression empty or enter
True, element will always be shown. Show-if expressions use the same syntax as other conditional expressions. For more information, see:
Show-if expressions are evaluated at the moment that the display is prepared. This means that for sketchpad items, they are evaluated during the prepare phase, whereas for feedback items, they are evaluated during the run phase (see also the section below).
The difference between sketchpad and feedback items
The sketchpad and feedback items are identical in most ways, except for two important differences.
Sketchpad items are prepared in advance, feedback items are not
The contents of a sketchpad are prepared during the prepare phase of the sequence that it is part of. This is necessary to ensure accurate timing: It allows the sketchpad to be shown right away during the run phase, without any delays due to stimulus preparation. However, the downside of this is that the contents of a sketchpad cannot depend on what happens during the sequence that it is part of. For example, you cannot use a sketchpad to provide immediate feedback on the response time collected by a keyboard_response item (assuming that the sketchpad and keyboard_response are part of the same sequence.)
In contrast, the contents of a feedback item are only prepared when they are actually shown, that is, during the run phase of the sequence that it is part of. This makes it possible to provide feedback on things that just happened--hence the name. However, the feedback item should not be used to present time-critical stimuli, because it suffers from delays due to stimulus preparation.
For more information about the prepare-run strategy, see:
Feedback variables are (by default) reset by feedback items
The feedback item has an option 'Reset feedback variables'. When this option is enabled (it is by default), feedback variables are reset when the feedback item is shown.
For more information about feedback variables, see:
Presenting visual stimuli in Python inline script
Accessing a sketchpad in Python
You can access the
Canvas object for a sketchpad as the items
canvas property. For example, say that your sketchpad is called my_sketchpad, and contains an image elements with the name 'my_image'. You could then have this image rotate with the following script:
my_canvas = items['my_sketchpad'].canvas for angle in range(360): my_canvas['my_image'].rotation = angle my_canvas.show()
Creating a Canvas in Python
You can use the
Canvas object to present visual stimuli in Python: