How to randomly select 'target' rectangle from xy_circle
For an experiment, I want create a canvas which shows rectangles around a central fixation dot. After showing this canvas to the participant, I want to show the canvas again, but in some cases with the 'target' rectangle in a different orientation. As you can see below, I have now used the xy_circle function to create the rectangles around the fixation dot. But I don't know how to randomly select a target, and change its orientation. Does anybody have any tips for me to do this? Or is it better to use a function other than xy_circle?
Thank you for your help!
my_canvas4 = canvas()
my_canvas4.fixdot()
for x, y in xy_circle(8, 200):
my_canvas4.rect(x-20, y-45, 40, 90, fill=True, color=u'red')
Comments
Hi Minne,
There are a few ways in which you could do this, but here's one: shuffle the order of the list of positions, and then just use the first position from the list as the target. This will make the target appear at a random location.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Thank you very much for your help.
If you don't mind I have another question. After I have implemented your suggestions, it seems the target rectangle is somehow always 90 degrees rotated. For that reason I want to rotate the target 270 degrees further to get it back in line with the other rectangles, but I'm not sure how to do this. It seems changing orientation is not one of the **style_args for the canvas.rect() function?
Your help is greatly appreciated!
Minne
Hi Minne,
The target is drawn like this, with a width of 90 and a height of 40:
Whereas the distractors are drawn like this, with a width of 40 and a height of 90:
So there's no rotation as such, just different widths and heights, which I used so that you'd be able to tell the target apart from the distractors.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!