Psuedorandom order for stimulus

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

OS (e.g. Win10): macOS Mojave 10.14.16
PsychoPy version (e.g. 1.84.x): v3.1.5
Standard Standalone? (y/n) yes
What are you trying to achieve?:
My temporal discounting task is based off the Airplane Task by A. Scheres et al., 2010.

Two airplane images appear on L/R sides of screen:
Each airplane carries a certain amount of coins. The “larger later” (LL) plane carries 10 coins that are rewarded after a delay. The “smaller sooner” (SS) plane either carries 2,4,6, or 8 coins that are rewarded immediately.
Participants use L or R arrow to select which coin reward they want.

Their response either activates the LL or SS “dummy loop”. This is the code I used:

codeSSorLL

Begin experiment *

doLL = 0
doSS = 0

Begin Routine *

if key_resp.corr == 1:
    doLL = 1
    doSS = 0
else:
    doLL = 0
    doSS = 1

Here is a visual of my experiment’s flow:

This is what my stimulus file looks like:


I have added this piece of code for the LL delay:

codeDelayTime

Begin Routine *

if LLDummyLoop.thisN == 0: # only on the first trial
    jitters = [5, 10, 20, 30, 60] # create the list
    shuffle(jitters) # randomise its order

current_jitter = jitters.pop() # extract one entry on each trial
thisExp.addData('jitter', current_jitter) # record in the data for this trial 

My current experiment works well and the scoring totals work, as well.

However, I need to make these TWO adjustments:

  • I need the height of the LL plane during choice presentation to correspond with the later delay time. (ie. higher the plane, longer the delay time).

  • I need the trials administered in the same pseudorandom order to all participants.
    (They are currently run through the 8 image combinations in the stimulus file randomly (image setting is “set every repeat”) and repeat this 5 times via a random loop.)

Any advice is very appreciated. I have built my entire experiment so far from the answers given to others on this forum and from youtube tutorials.

In the “begin experiment” tab of code component, put something like this:

np.random.seed(90210) # choose any number here

i.e. this sets the “seed” of the random generator so that the output will be the same on all runs of the study. NB this assumes that exactly the same sequence of random numbers will be required on each run. If, for example, a person can exit a loop early, then the same sequence of numbers will be generated, but they will get produced at different points in the study.

You’ll need to describe the requirements a little more precisely for us.

Hi Michael,

Thanks for your help!
Your code worked very well. I just realized that it also would work to add a random seed in my loop properties in Builder.

For my second question, I have now added two more conditions to my stimulus file:

  • delay time
  • image height

and it seems to be working when I draw from those conditions in my routines.

Hi Michelle,

Would you be willing to share your code with adjustments for the Airplane Task?