Hi Chris,
Is it feasible to use a python script to generate a specific filename (via a regular expression), and then find the matching index of that filename in a stimulus group? I ask because we have images that differ among several dimensions, and need to select among the various dimensions for a discrimination task. For example, we may fix the value of dimension1, and dimension2 of the images, and ask how they discriminate images from category 3 from one another. Right now I just nest stimulus groups, keep track of the numbers, and then select from that list of numbers using lists defined in the program. However I wonder whether there is a more clever way to load the image files and select them.
Manu
Hi Manu,
If you’re willing to load and unload images while your experiment is running, you can use Python code to select the filename of each image, using any scheme you want.
I’ve attached a simple experiment that demonstrates this. Each time the block runs, the Python function select_next_image()
sets the MWorks variable image_path
to the desired filename. My implementation just chooses randomly from all available images, but the function could do anything you want (e.g. read other MWorks variables to determine the correct image for the trial).
The biggest potential downside to this approach is that image loading can be slow, relatively speaking – potentially 10’s to 100’s of milliseconds, depending on image size. Depending on your protocol, this may not matter, or you may be able to do the loading while something else is happening (e.g. you’re waiting for the subject to fixate). But you should be aware that it’s a potential issue.
If you can’t load/unload images at runtime, then your current technique is probably as good a solution as any.
Cheers,
Chris
python_image_selection.zip (57.7 KB)