Data output help

I am brand new to Psychopy and coding in general–I am actually taking over an experiment that someone else coded. This is a memory task, and I need to add a column in my data output that specifies whether the image seen was studied or unstudied. The person who wrote the code has created these groups “animate_unstudied_chosen” and “animate_studied_chosen.” I was hoping I could use these to make an if/else statement to specify that if the image is studied it gets labeled with a 1 and a 2 if it has not been studied, but I am not sure how to do this with the correct syntax. I then want to be able to use thisExp.addData to have it print this column of information. Please help! Thank you!


could you please show us your stimulus-file? It is probably unnecessary to use a if/else-statement. It might be sufficient to add a column to your stimulus-file. I assume that your stimulus-file contains animate_unstudied and animate_studied items.

Best wishes Jens

Thank you for trying to help me! The stimuli set up is a bit complicated. We have images of objects and scenes broken down into 4 categories-animate, inanimate, indoor, outdoor. Blocks 1 and 3 handle objects and 2 and 4 handle scenes. We further broke down the stimuli based on semantic and visual similarity data that we gathered on the images–so each category is separated further into twelve folders with five images each that are highly similar. The experiment should be set up to randomize the image presentation such that it pulls one image from each group at a time. The animate_unstudied and animate_studied groups are not from the stimulus file but are two of many groups that the previous coder set up in the experiment (she also has “block1_ani_test_studied” etc) and I am having trouble deciphering what is what.

For the test phase the images seen are actually small apertures of the original study images–which is also why I am having a tough time with the studied/unstudied bit.

I tried adding this if/else statement in the code for the first test block:

#set current image
current_test_image = ‘apertures/’+str(block1_test[imglist_test[test_trial_1]])+’_Aperture.jpg’
current_test_group = block1_test_group[imglist_test[test_trial_1]]

#store data
thisExp.addData(‘Image’, current_test_image)
thisExp.addData(‘Group’, current_test_group)
if current_test_image in animate_unstudied_chosen or inanimate_unstudied_chosen:
old_new = ‘2’
old_new = ‘1’
thisExp.addData(‘old_new’, old_new)

–what actually happened is I generated all 2’s in the data–which does not make sense to me. All of the apertures were positively not all unstudied. It was an experiment to try “or”–but if I don’t add “or” I would be stuck with “if in animate 2, else 1” and then the inanimate images would all get lumped as the else condition…any advice? Thank you!

I figured it out.

  1. I needed to use “+” instead of OR
  2. I needed to use “str(block1_test[imglist_test[test_trial_1]])” instead of current_test_image