If this template helps then use it. If not then just delete and start from scratch.
OS (e.g. Win7): PsychoPy version (e.g. 1.83.0):
**Standard Standalone What are you trying to achieve?:
I have a very simple presentation of images in my experiment. I have set it up using condition file called ‘cond_train.xlsx’. Now I selected the ‘LoopType’ to be random so the rows are already randomly presented.
What I want is, when ever I have ‘R.bmp’ in the ‘cond_train.xlsx’, I want the program to pick any one of the 24 items (contains 24 images) in the folder ‘R’. Is it possible?
The ‘loc_2’ is the header for the column in which I have R.bmp’s . It seems to have problem in locating the folder in which the pictures are. Folder ‘PicFolder’ has R1.bmp,R2.bmp,R3.bmp.
If your images are stored in a folder called PicFolder/, that folder name needs to be in quotes with each filename. At the moment, you have it outside the quotes, which means that Python will try to interpret PicFolder as a variable (which doesn’t exist) and also get confused by the special character /
I think it is because it is looking for ‘R.bmp’ image, which is not there. It should rather go in to the condition file and look for ‘R.bmp’ and if it finds one it should then locate the folder and pick one of the three images from the folder randomly. Could you fix this problem?
I wanted to go beyond the problem, so I I just created a file R.bmp to temporarily get around this) and see what the program does. It now throws this error
Sorry for the delay in getting back. My problem was I wanted to select one of the images randomly from a folder named ‘rand’, if the condition file had ‘R’.
My condition file looks like this
I have created this under ‘Begin Experiment’ of my code component as per suggestions
ImageList=['rand\R1.png','rand\R2.png']
and, under ‘Each Frame’
if item2=='R':#item2 is the column header in condition file
ThisImage=np.random.choice(ImageList)
else:
ThisImage=item2