Accessing loop parameters from code

Hi, new to PsychoPy and I’m assuming there’s an obvious fix to this I just can’t figure it out.

I’ve built a conditions file to loop over that contains 2 parameters: number_of_choices and background_image.

background_image contains a list of image files I want to loop over (each one corresponds to a different trial condition) and number_of_choices is a variable that corresponds to each image/trial condition.

Basically, I want to be able to use the variable number_of_choices in my code, but I get the following error message:

Traceback (most recent call last):
File “/Users/xiao/Documents/Blaisdell Lab/pigeon study/Hicks Pigeon ONE ROUTINE CODE.py”, line 357, in
i = randint(1,number_of_choices)
File “mtrand.pyx”, line 993, in mtrand.RandomState.randint
ValueError: low >= high

I know parameters in conditions files can be accessed through components in builder with $, but I’m not sure how to refer to the parameters in my code. Or maybe I shouldn’t be putting variables as parameters in my conditions file and there’s another way to do this?

Your variable is being accessed OK, but the error message tells us that it just doesn’t contain a value in the required range (> 0). Here is the documentation for the numpy.randint() function, where you can see the interplay between the low and high arguments to that function:

https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.random.randint.html

Got it! Thanks!