For loop indexes the same value for every condition: can I get sequential trials without conditions files?

My experiment involves creating a variable for the stimulus position and instead of using a conditions file I am aiming to loop through a list of x positions (for all positions y =0). Therefore creating a new x position on every trial.

I have a function in my code element at the start of my experiment (before experiment) that creates the list of x positions (using random.gauss because I want to positions to be drawn from a gaussian distribution). I can post this if necessary but the syntax is fine as the loops work exactly as they should when using Python alone.

Is the process of getting Psychopy to know I want a new value from the list on each trial that I am unsure of.

I have heard the .pop() might help me but is it correct that you have to reset the list after using it?

In begin routine I have the following for loop:

for i in range(len(target_list)): #for the target position list create loop
      target_coin_position = target_list[i]

for i in range(len(cue_list)): #for the cue position list create loop
      cue_coin_position = cue_list[i]

Your for loop is going through all its iterations at the beginning of the trial(s), which means you end up using the last value from each list.
What you can do is insert a loop around your routine, specifying nReps as your number of trials, and then change your Begin Routine code to use the index of the current trial:

target_coin_position = target_list[trials.thisRepN]
cue_coin_position = cue_list[trials.thisRepN]

Where ‘trials’ is the name of your loop.

If you were to randomize the order, you may have to do that at the beginning of the experiment/block, but since you’re using random gaussian samples I imagine you don’t need to shuffle the lists.

Hope that is useful!

That sounds really helpful, thanks! I will let you know how I get on (and yes I don’t need to shuffle)

That works great now. Thank you :slight_smile: