Pseudo-randomize stimuli based on trial number

OS : Win10
PsychoPy version: 3.8.10
Standard Standalone? (y/n) If not then what?: Yes

What are you trying to achieve?: I want to fix when specific stimuli will appear on screen but have all other stimuli show up randomized within a loop

Hello I hope someone is able to help. I am very new at PsychoPy and python but I am trying to create an experiment with 2 conditions, one condition that is shown stimuli in a sequential order and one that is shown in a random order. To create my conditions I have a branching code in the beginning of the experiment to skip a loop (or not) based on participant number.

image

That said, for my random condition I am trying to hold some trials constant. For example, I want a specific image showing up on trial 4 for everyone. Does anyone know the best way to go about this? I was originally trying to work in the gui and have my loop type be random and just make some code to (theoretically) say “if trialnumber == 4 then show PMimage1. elif continueRoutine = True”. However, I am having a very difficult time actually making something like this work because I do not know how to specify the image shown from the excel file and then I want the loop then needs to pick up where it left off on trial 5 and not restart my count

What did you try to make it work?: I was originally hoping to use Dr. Ozubko’s YouTube tutorial on how to use code to randomize two lists of stimuli within a single loop but the code he uses requires you to load in the excel sheets and randomize the items at the beginning of the experiment. Since I am already branching at the beginning of the experiment to keep one of the conditions to be sequential, this code does not work. I did try to move this back to be at the beginning of the routine in the random condition routine loop. This then caused the error that it could not open the excel sheet by the time the routine was starting. I tried to add in a buffer slide to fix this but this did not do anything.

Andy advice on how to call in these specific images after a specific trial number is very much appreciated! Thank you in advance

Let’s assume you have a column in your conditions file called, say image_file. That will have a value on each trial, and all you have to do is override it on trial 4 (3, counting from 0). e.g. on the relevant routine, put code like this in the “begin routine” tab of a code component:

# override the image name on trial 4:
if your_loop_name.thisN == 3:
    image_file = 'funny_cat_pic.png`

In your image component, you would just put $image_file in the “image” field. It will get the randomised value on every trial but the fourth.