OS (e.g. Win10): mac OS Ventura 13.2.1
PsychoPy version (e.g. 1.84.x): 2023.1.0
**Standard Standalone? yes
What are you trying to achieve?:
I am trying to give 1 random image as feedback from a pool, both for correct (4 possible happy pictures) and incorrect answers (4 possible sad pictures).
What did you try to make it work?:
0) First, I created a simple trial task routine with 2 possible key options (e.g. “yes”/“no” answers with “y”/“n” keys). This task detects correct and incorrect answers.
- Then, I created two feedback routines, after the trial routine. One for correct feedback, and another one for incorrect feedback.
- For each feedback routine, I created a loop around it and gave an excel file as condition to recall the image lists. The excel file has column names (e.g. “happy faces”, “sad faces”), and below them, the image directory (e.g. “feedback/happy1”, “feedback/happy2”, etc.)
- Inside each feedback routine, I added an image (with condition $happy faces or $sad faces). Also, I added a short custom code>Begin Routine to “continueRoutine=True/False” when detecting key_resp.corr == 1, 0 or None. This works so far and it detects when to run the correct feedback routine or the incorrect feedback routine.
**What specifically went wrong when you tried that?:
- Instead of giving a single random image from the pool, it presents all of them one after the other randomly (all the correct images together, or all the incorrect images together, respectively).
I have checked several posts here and tutorials, but I didn’t find any solution so far.
Thanks in advance!
I assume that Selected rows should do the trick.
Best wishes Jens
Thanks for your reply.
Could you please give me more details how to do it? I have started learning psychopy 1 week ago and there are lots of things I still do not know.
in this case, you might want to have a look at
Peirce, J. W., Hirst, R. J. & MacAskill, M. R. (2022). Building Experiments in PsychoPy. 2nd Edn London: Sage.
Your library might have it.
Anyway, the option Selected rows is a parameter of the loop and specifies which rows of your Excel-file are read. So, if you specify to read just one row, only one image will be presented, otherwise the loop loops through all rows of your Excel-file.
Best wishes Jens
Thanks, I will take a look!
useRow = randint(0,17)
useRows = str(useRow)+":"+str(useRow+1)
For some reason I do not understand, instead of presenting single random pictures from a list, I always get the same picture. Then, if I change the number 17 to a different one, it changes the picture.
I have 4 different pictures per condition, but I replicated up to 16 pictures in the spreadsheet since it is the number of times they might appear. Not sure if it is needed.
Based on what you’ve said, it looks like the issue is with randint rather than useRows.
Try adding the following code after the code you’d used to set useRow and useRows, which might help identify the error.
It appears the following on the runner, but no errors:
useRow 14 useRows 14:15
useRow 8 useRows 8:9
I use useRow for both correct and incorrect feedback. I guess the 1rst line is for correct feedback and the 2nd one for incorrect feedback.
Here I add the current design on the Builder, the code of one of them, and the loop properties:
you want to set the loop-type from random to sequential. You set useRows in the Beginning of the experiment. Do you ever update it? Otherwise useRows will have the same random value in the experiment. Notice that you have to update useRows outside of the relevant loop.
In case you want to present just one picture
useRow = str(randint(0,17))
should do the trick as well.
Best wishes Jens