| Reference | Downloads | Github

Making Conditional Borders in the Coder


I have a behavioral paradigm in which we have different cues that are matched to stimulus presentations (pictures) within blocks. We would like to draw colored borders around the cue and picture, so that the participant can use these to remember what condition they are in.

Hence, the first question I have is whether you have a coder example of how would one draw identical borders around a visual.TextStim element and a visual.ImageStim element that were both being pulled from the same row of a conditions file. Hence, the cue and picture pairings are fixed, but I can set their paired presentation to be randomized.

Also, while the cue and pictures are paired, there are three different pairings, so the code would have to be able to draw the appropriate border on each cue and picture pair. Do you have any idea how to do this? Any and all advice would be appreciated.


Hi Craig, your question is a bit too conceptual to be answered. Yes, what you want could certainly be done, but you need to provide more specific detail for us to tell you how. Think what you would need to describe in the methods section of a paper, and then add a bit more…

Also, show the variables you will have in your conditions file and what they contain.

Hi Michael, thanks for the reply, and sorry for being vague. I’ve uploaded one of the condition files which shows that, for Block 1, there are 24 images in 3 conditions “Watch”, “Rethink”, and “Distract”. These conditions are coded in the “task” column #4. All 8 images associated with each of these conditions would have the same specific border, for instance green vs. red. vs. blue. Each image would also be preceded by a ‘Cue’ screen, which would alert the participant to which condition they were in (Watch, Rethink, or Distract). What I’m looking for is a way to put a border around the edges of the screen when the cue slide is on screen, and then an identical border around the edges of the picture screen. That way the participant has a visual reminder of which condition they are in.

Hence, in terms of coding, I’m thinking that there must be a way to feed in a border color variable, in much the same way that you would pass “setText” to a visual.TextStim component or setImage to a or visual.ImageStim component. I’ve seen some posts about trying to create a border using ShapeStim, so maybe I could feed the variable for the condition color into setColor. However, I’m still not sure how to get ShapeStim to work to give me a border in the first place.

Here are snippets of the cue and image code blocks taken from the initialization and within the “TrialHandler” loop, respectively:

RegulationCue = visual.TextStim(win=win, name='RegulationCue',
    text='default text',
    pos=(0, 0), height=0.1, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1,
image = visual.ImageStim(
    win=win, name='image',units='norm', 
    image='sin', mask=None,
    ori=0, pos=(0, 0), size=(2,2),
    color=[1,1,1], colorSpace='rgb', opacity=1,
    flipHoriz=False, flipVert=False,
    texRes=128, interpolate=True, depth=-1.0)


Any thoughts? Please let me know if you need any more details.

group1_block1_list.csv (865 Bytes)

In the Coder view menu bard, go to Demos -> stimuli ->

Run the demo. There are a couple of examples there of rectangles. Yes, you can change their colour property as required.