| Reference | Downloads | Github

Correct answer comparison between two consecutive routines with separate loops


I am trying to put together an experiment where participants will be shown two images (that is one set), side by side for 5 secs. These sets of images will be drawn from a condition file containing 14 such sets where images that are to appear on the left and right hand side have been specified. I’ve created a routine called ‘setPresent’ & put a loop around it called ‘Present_Loop’. I have a bit of code in place to ensure only 1 set is drawn at a time. After 3 (out of 5 secs) the image on the right will disappear. Participant’s task is to identify the missing image amongst images that will be presented in a quick succession in the second routine.

The second routine is called ‘targetSearch’. This routine contains one image component & a keyboard component. The image component is linked to the condition file (same as above) from which it will pull images (it’s pulling them from one column only ($pic_perf)) at a pace 0.5sec. Participant’s task is to press ‘spacebar’ when they think they’ve seen the missing image.

If they press the key while the correct image is on the screen, a message should appear ( i.e.‘correct’) and the outerLoop should bring them back to the ‘Present_Loop’ when another image set (from the stimuli sheet) will be presented and the whole thing will be repeated.

If they press the key while an incorrect image is on the screen, a message should appear (i.e. ‘incorrect’) and they would keep going until they hit the bar when the correct image has been presented.

My problem is this: to my knowledge I have no way of defining what the correct answer is in the stimuli sheet and I don’t know how to go about creating a list of images which appear and then disappear in the first routine. As far as I know I can’t include such variable in my only stimuli sheet as we normally would (and call it ‘corrAns’ or something along those lines) because the sets in the ‘Present_Loop’ are presented in random order and the order of presentation does not carry into the next loop ‘Response_Loop’. So I thing my solution here would be to create a list with code of those items as they appear in code…

I have tried to adjust the solution mentioned here:

but I keep encountering the same issue i.e. whatever my loop name is, it will always back as not defined.

I’ve tried a lot of different names and had no luck - always comes back as not defined.

I’ve read in:

… that .thisN is no longer supported by the new PsychoPy version (I’m using the most recent one so likely to be affected by it also). I’ve tried to replace .thisN with loopN but again no luck.

I’ve tried moving the position of my ‘code_present’ element to the very top of that routine and re-arranging the order of commands in the ‘Begin Experiment’ tab. I also tried moving the ‘if’ statement to the ‘Begin Routine’ tab - no luck.

I am attaching a couple of screenshots from my exp builder. Perhaps someone can help me figure how to create a list of (missing) images in the first routine against which participants’ answers in the second routine can be rated as (in)correct.

*each image is set to ‘set every repeat’ & $pic_left or $pic_right pointing to the condition file.

*code element here is: $correct_answers[Response_Loop.thisN]

Code snippet: re: random row selection

Stimuli file called ‘aspectPresent.xlsx’

Many thanks!

I’m afraid I haven’t read your post in detail but the way I deal with this kind of issue is I append to a new array during the first loop which I shuffle and use as conditions in the second loop.