| Reference | Downloads | Github

Selecting subset of image stimuli based on video previously presented for fMRI experiment

I’m new to PsychoPy and fMRI experiment design, so I’ll need some help selecting randomized and corresponding stimuli
OS (e.g. Win10): macOS Mojave 10.14.3
PsychoPy version: 3.0.3
Standard Standalone? y

  1. How do I have PsychoPy randomly select a video and also select the correct subset of images?
    1a) How can I tell PsychoPy to pick 15 images out of the 112 possible?
  2. How do I tell PsychoPy to display the stimuli for 12 seconds even if the participant responds during that time window?
    This experiment is for fMRI, so everything must be displayed on schedule.

In my experiment, I will show my participants a video of a city and afterwards they will see images of the city. There are three different cities (with 3 videos of each city), so there are 3 different types of stimulus sets. One block/one run in the scanner = 1 city video + 1 subset of stimuli. In total, I will have 9 blocks. Here’s the set up of my current flow.

Under the loop “chooseCityVids”, I have a .xlsx file listing the 9 different city video files:


Under the loop “chooseCityImages”, I have a .xlsx file listing other .xlsx files. Each excel file listed here contains the path to each image to be displayed in each block.


Here is an example of one of these excel files:


Under the “imageResponses” loop, I put $cityImages in the “properties” field, which corresponds to the “'chooseCityImages” loop.

What did you try to make it work?:
So far, my videos and images show up and are randomized. However, the subset of images do not correspond with the video. I realize I’ll probably have to add some code to tailor the experiment to my specifications.

Hi, can you be a bit more concrete in your description of your requirements? Think about how you would need to describe this design and procedure in the methods section of a paper or thesis.

i.e. at the moment, you provide more detail on your current attempt at implementation rather than what you actually need in terms of your procedure.

Hi Michael,

I have three videos of each of the 3 cities (9 videos total) which contain 6 stores in each environment. City 1 and city 3 have different stores inside the environment. City 2 has the same stores as city 1, but the stores swap positions in the environment (I call this city1swap in some of my excel files).

At the beginning of each block, the participant will watch one of the videos in the scanner. Afterwards, the scan will start and the participant will be presented with images of the stores (1image = 1 trial). Like this one for example:

Each image contains 3 stores from the video arranged in a triangle. The cue store is placed at the top of the image. The participants must choose which one of the stores on the bottom (bottom left or right of the image) was closest to the cue store in the video presented at the beginning of the block.

So, what’s the problem?
In my current flow, PsychoPy will call any random video and present any random image. For example, PsychoPy will present one of the videos from city 2, but then present images from city 1. I would like PsychoPy to present any random video, and then choose 15 of the correct corresponding set of images (i.e., present a video from city 1 and present images from city 1 excel file). I have 112 possible images to present for each city, so I would like PsychoPy to only select 15 images for each city.

Since this experiment will be in the scanner, I need the image stimuli to remain on the screen for 12 seconds, even if the participant has already responded.

Update: I figured out how to keep the images on the screen after the participant responds (unchecked “force end of routine”). I’ve left details about my remaining question down above.

In case anyone had similar issues, all I had to do was combine the .xlsx files (first two excel files shown above) from the outer and middle loop into a new .xlsx file and attach this new .xlsx file to the outer loop(so columns A and B headers are now named $cityVideo and &cityImages respectively. Then, delete the middle loop. PsychoPy will automatically pick the same row. For example, if PsychoPy randomly picks the video in the 4th row from $cityVideo, it will also read the .xlsx file listed in the 4th row from $cityImages.