Stimuli presentation from lists (within lists?)
Hey guys,
I would like to run a study I am programming in OS at the moment and I am struggling with the last part of it .
So, to give you a quick background...
I have 20 pictures I am pairing with other pictures this way:
- 10 pictures with positive stimuli
- 10 pictures with negative stimuli
Then, in the next part of the procedure, I am showing all the 20 pictures in 4 within participants variants where:
condition 1 (showing a picture with a positive stimulus it was paired with earlier)
CS_rating_list1 = CS_pos[0:5]
US_pos_list1 = US_pos[0:5]
US_neg_list1 = US_neg[5:10]
condition 2 (showing a picture with one of the positive stimuli, but not the one it was paired with)
CS_rating_list2 = CS_pos[5:10]
US_pos_list2 = US_pos[0:5]
US_neg_list2 = US_neg[5:10]
condition 3 (showing a picture with a negative stimulus it was paired with earlier)
CS_rating_list3 = CS_neg[0:5]
US_pos_list3 = US_pos[5:10]
US_neg_list3 = US_neg[0:5]
condition 4 (showing a picture with one of the negative stimuli, but not the one it was paired with)
CS_rating_list4 = CS_neg[5:10]
US_pos_list4 = US_pos[5:10]
US_neg_list4 = US_neg[0:5]
So, above I created conditions and zipped them below into lists which I was planning to use in the rating phase later:
pairing_real_pos = zip(CS_rating_list1, US_pos_list1, US_neg_list1)
pairing_real_neg= zip(CS_rating_list3, US_pos_list3, US_neg_list3)
pairing_fake_pos = zip(CS_rating_list2, US_pos_list2, US_neg_list2)
pairing_fake_neg= zip(CS_rating_list4, US_pos_list4, US_neg_list4)
Then, during the rating phase I want to present the pictures in all the four within participant variants and thought I could do it this way with a variable "condition" (from 1 to 4, analogical to four lists I created above) and a variable "position" (left or right side on the computer screen just to counterbalance the presentation):
if var.condition==1:
var.CS_rating = pairing_real_pos[0] #the first element is the CS
if var.position=="left":
var.left_US= pairing_real_pos[1] #the second element is the US
var.right_US=pairing_real_pos[2] #the third element is the US
elif var.position=="right":
var.left_US= pairing_real_pos[2] #the second element is the US
var.right_US=pairing_real_pos[1] #the third element is the US
elif var.condition==2:
var.CS_rating = pairing_fake_pos[0] #the first element is the CS
if var.position=="left":
var.left_US= pairing_fake_pos[1] #the second element is the US
var.right_US=pairing_fake_pos[2] #the third element is the US
elif var.position=="right":
var.left_US= pairing_fake_pos[2] #the second element is the US
var.right_US=pairing_fake_pos[1] #the third element is the US
elif var.condition==3:
var.CS_rating = pairing_real_neg[0] #the first element is the CS
if var.position=="left":
var.left_US= pairing_real_neg[1] #the second element is the US
var.right_US=pairing_real_neg[2] #the third element is the US
elif var.position=="right":
var.left_US= pairing_real_neg[2] #the second element is the US
var.right_US=pairing_real_neg[1] #the third element is the US
elif var.condition==4:
var.CS_rating = pairing_fake_neg[0] #the first element is the CS
if var.position=="left":
var.left_US= pairing_fake_neg[1] #the second element is the US
var.right_US=pairing_fake_neg[2] #the third element is the US
elif var.position=="right":
var.left_US= pairing_fake_neg[2] #the second element is the US
var.right_US=pairing_fake_neg[1] #the third element is the US
And then just write on a sketchpad “CS_rating”, “left_US” and “right_US”, but OS keeps giving me this error which I guess means it treats my lists nested within lists as one element, not three separate elements…
If you have an idea how to fix this issue and help me out on it would be extremely grateful!
Thanks a lot in advance and have a good day everyone.
Cheers,
Bori
Comments
You are right, your lists are nested.
Option 1:
Write the list unnested: pairing_real_pos = [x, y, z, ...] #all items as one
Option 2:
Draw from the nested list like this
if var.condition==1:
var.CS_rating = pairing_real_pos[0][0] #the first is your first list, the second your first picture in the first list
Example:
seq=[[1,2],[3,4]]
print seq[0][1] # prints 2
Thanks a lot, managed to do it with the latter solution!