I am drawing images from an excel spreadsheet. I have 18 total image stimuli, 9 exponential graphs, and 9 reciprocal graphs. Each trial, the participant will see 8 total graph images. I want the order of exponential and reciprocal stimuli to be random, but I only want four exponential and four reciprocal graphs shown for each subject. How do I implement this? I was thinking a for loop that somehow says that if 4 stimuli in the first 9 rows are chosen move on to the other rows? But I do not know what the code should look like or where in the experiment it should go.

What I would do in this circumstance is ditch the Excel file and start with two arrays, e.g.

```
exponential=[['graph1.png','e'],['graph2.png','e'],['graph3.png','e'],['graph4.png','e'],['graph5.png','e'],['graph6.png','e'],['graph7.png','e'],['graph8.png','e'],['graph9.png','e']]
reciprocal=[['graph10.png','r'],['graph11.png','r'],['graph12.png','r'],['graph13.png','r'],['graph14.png','r'],['graph15.png','r'],['graph16.png','r'],['graph17.png','r'],['graph18.png','r']]
shuffle(exponential)
shuffle(reciprocal)
graphs=[]
for Idx in range(4):
graphs.append(exponential[Idx])
graphs.append(reciprocal[Idx])
shuffle(graphs)
```

Then have a trials loop with no conditions file and nReps=8 where your image file is graphs[trials.thisN][0] and your answer is graphs[trials.thisN][1]

However, you will also need to save the data by adding the following to your main trial or feedback routine.

thisExp.addData(‘Graph’,graphs[trials.thisN][0])

thisExp.addData(‘Answer’,graphs[trials.thisN][1])

For more conditions (like a word list) I use a pretrials loop to append the data into the array instead of adding the information into the code component itself.

Best wishes,

Wakefield

Thanks so much! I understand your code until you say the image file is graphs[trials.thisN][0] and your answer is graphs[trials.thisN][1]. Am I supposed to indicate the answer somewhere? When I put this into the image it says no image has been found at that path.

If you have any further guidance on how to fix this please let me know.

It was also not liking the addData function when I tried it.

Thanks again!

Sorry. One more thing. A problem I am having is that it won’t let me cast a list of images into an array. Is that something that is possible in psychopy?

The array should be the file names.

You need a before graphs in your image component The answer goes in the keyboard component (again with a )

I have the array as the file names. I tried putting ‘a’ and ‘$’ in front of the name in the image component and I keep getting the error that ‘graphs’ is undefined, even though it is defined in the code that I have thanks to you. Is there something else I’m missing?

What does the error message look like when you have a $ in front of graphs?

This is what the error looks like now. I also included the keyboard response section to make sure I am filling that out correctly.

Thanks again!!!

Did you create a loop called trials around your Routine?

Ok got it!! Can’t thank you enough for this seriously!!!