| Reference | Downloads | Github

distractor.setPos(disposition) NameError: name 'disposition' is not defined when I add code snippet

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): win10
PsychoPy version (e.g. 1.84.x): 2021.2.2
Standard Standalone? (y) If not then what?:
What are you trying to achieve?: I try to create random circles around fixation located on the center of the screen. The independent variable is eccentricity with 2 levels, 6 and 9. I make my circles appear randomly around the fixation point around the imaginary 6deg and 9deg orbit. There are 60 trials in a block with half-half eccentricity as IV randomly.

What did you try to make it work?:
I create a cvs file with an “ecc” header, then my 60 eccentricities(6,9) in random order.
Then in the builder-stimulus-layout-position[x,y] I typed “$disposition”.
Then in the customize section, I create a code snippet to specify “$disposition” based on my ecc.cvs file.
In code–begin routine
, I put
ecc = open(“ecc.csv”)
for line in ecc:
line = line.strip()
if line == “6”:
x = 6float("{:0.3f}".format(cos(360random())))
y = (36 - x
disposition = ([x,randchoice([-1,1])y])
if line != “6”:
x = 9
y = (81 - x
disposition = ([x,randchoice([-1,1])*y])

What specifically went wrong when you tried that?:
If I only put my code snippet in the begin routine*, the error message is
NameError: name ‘disposition’ is not defined

If I put the snippet in begin experiment*, the position of my circle will only be a certain place without changing.

If I put the snippet in both begin experiment* and begin routine*, the position of my circle varies by only 9 eccentricity but there is no 6 eccentricity.

I checked my python code, but it seems to work in IDLE, generating 60 random positions for me according to eccentricity.

Thank you!

Hi There,

Is there a component called distractor and if so does it’s position field “set every repeat” or is it set to constant?

Hi Becca! There is a component called distractor in the experiment routine, and I set the position as $disposition and it was “set every repeat”.

Best, Diana

Try having two columns in your CSV, disposx and disposy and then set the position as $[disposx,disposy]

1 Like