
This is just to provide some sort of placeholder so that the trial will last exactly 0.5 seconds. In the trial routine, insert a static period set to have a duration of 30 frames (or any other stimulus you might need). Images.append(visual.ImageStim(win=win, image=file)) # create an image stimulus from each file, and store in the list: Images = # need to start with an empty list # get the list of filenames with the relevant extension:įilenames = glob.glob(os.path.join('images', '*.jpg')) # assuming all your image files are in a subfolder called 'images', Import glob # a module that allows you to access filenames from a folder In its "Begin experiment" tab, put something like this (untested, so you will need to debug):
#Psychopy coder tutorial code#
Insert a code component in your trial routine. If you use shuffle(), open a code component in your first routine and add this code to theBEFORE EXPERIMENT tab after you have selected code type: Both. That is, it will take 0.5 seconds to present all the 30 images.Can you tell me how can I implement it? t = 0 when all the images are loaded in the memory and ready to present), and 2) then show one image in one frame (1/60 second). > Here is want I want to do: 1) preload all the images before the experiment start (e.g. You'll need to test whether your graphics card hardware can handle holding all of them in memory at once. You'll need to insert some code to handle pre-loading all of the stimuli. You can still run this experiment in Builder, but: You definitely don't want any images that need to be scaled down: those extra pixels will chew through memory.Ĭome back to us if you want to proceed this way. But before getting that underway, you'll need to check that the actual image files themselves are 1920 × 1080. But in your case, you will have to trade memory for speed. The constraint then becomes how much memory your graphics card can hold, because it needs to have all 30 images in memory simultaneously (Builder normally updates each image stimulus on every trial as required, so the graphics card only has to hold one at a time in memory. Actually displaying images takes no time at all, it is the initial creation of them that imposes delays.

#Psychopy coder tutorial serial#
Realistically for rapid serial presentation tasks like this, you are going to need to load all 30 images before the trial starts and create a separate image stimulus for each. It is a race to get it done within a single frame interval (16.7 ms in your case), and in Builder, it isn't really possible to use an ISI period here since you are displaying images for only one frame each, immediately in succession.

To load and decompress an image from disk takes a finite amount of time. Oil's advice is the standard one and usually the way to go, but I suspect that it won't work in your case.
