psychopy.org | Reference | Downloads | Github

Order of autodraw stimuli

Hi all,

I am designing an experiment in which a fixation dot is always being presented. Then, during the experiment, stimuli are flashed at a certain rate on and off. For both fixation dot as well as stimuli, I use the autoDraw option, because I am drawing everything on individual frame flips for the most accurate timing. I am experiencing that the stimuli are always drawn over the fixation dot, so that it appears that the fixation dot also follows an on/off process. Specifically, now, either fixation dot is drawn, or the stimulus. What I actually want, is the fixation dot is always drawn (over the stimulus).

Is there a way to change the order of autoDraw stimuli?

In pseudo code, to illustrate the routine, my experiment is as follows:

window = visual.Window()

fixdot = visual.GratingStim()
stimulus = visual.ImageStim()

fixdot.autoDraw = True
for i_frame in range(n_frames):
    if i_frame % (on_frames + off_frames) == 0:
          stimulus.autoDraw = True
    elif i_frame % (on_frames + off_frames) == on_frames:
         stimulus.autoDraw = False
    window.flip()
fixdot.autoDraw = False

window.close()

No, we don’t currently have a mechanism for autodraw order. You’ll just have to use draw() for your stimulus and autodraw for the fixation (autodraw is always done last)

1 Like

Thanks for your reply! Is there not anything that this order is dependent on? I tried for instance playing with how or in what order I add objects (visual.GratingStim or visual.ImageStim) to the window (visual.Window), but that seems not to matter. Is there any hacky way to manipulate the order? If not, I might have to go back to building the stimuli first, make a ‘screenshot’, and use ImageStim always.

I wouldn’t fixate on using autoDraw: it’s only there for convenience, but in your case, the code would be much shorter and more readable if you don’t use it at all.

window = visual.Window()

fixdot = visual.GratingStim()
stimulus = visual.ImageStim()

for i_frame in range(n_frames):
    if i_frame % (on_frames + off_frames) == 0:
        stimulus.draw() # conditional drawing
    fix dot.draw() # unconditional drawing
    window.flip() # show whatever was drawn

window.close()
1 Like