Millisecond Forums

Setitem from list on each trial

https://forums.millisecond.com/Topic18445.aspx

By Lizzy - 2/28/2016

I'm trying to program a task where on each trial, two stimuli are presented, drawn from two of four possible lists (32 male angry faces, 32 male happy,32 female angry, 32 female happy). I need to ensure that across 64 trials, each item in each list is presented exactly once, and that all 16 combination pairs (FH left - FH right, FH left - FA right, FH left - MA right, FH left - MH right, FA left - FH right, FA left - FA right, FA left - MA right, FA left - MH right, ....) are each presented 4 times.

I'm creating 16 different trials for these 16 combination pairs, and within these trials, want to choose the lists that I draw from to select the pictures.
The problem occurs when I try to set the item in my picture element. I want to overwrite whatever is in there with a new list item that I draw from the appropriate list on each trial, but that doesn't seem to be working.

Here's the relevant script:
<list VSListFH>
/ items = ("HF1.bmp", "HF2.bmp", "HF3.bmp", "HF4.bmp", "HF5.bmp", "HF6.bmp", "HF7.bmp", "HF8.bmp", "HF9.bmp", "HF10.bmp", "HF11.bmp", "HF12.bmp", "HF13.bmp", "HF14.bmp", "HF15.bmp", "HF16.bmp", "HF17.bmp", "HF18.bmp", "HF19.bmp", "HF20.bmp", "HF21.bmp", "HF22.bmp", "HF23.bmp", "HF24.bmp", "HF25.bmp", "HF26.bmp", "HF27.bmp", "HF28.bmp", "HF29.bmp", "HF30.bmp", "HF31.bmp", "HF32.bmp")
/ replace = false
/ selectionrate = always
</list>

<list VSListFA>
/ items = ("AF1.bmp", "AF2.bmp", "AF3.bmp", "AF4.bmp", "AF5.bmp", "AF6.bmp", "AF7.bmp", "AF8.bmp", "AF9.bmp", "AF10.bmp", "AF11.bmp", "AF12.bmp", "AF13.bmp", "AF14.bmp", "AF15.bmp", "AF16.bmp",
"AF17.bmp", "AF18.bmp", "AF19.bmp", "AF20.bmp", "AF21.bmp", "AF22.bmp", "AF23.bmp", "AF24.bmp", "AF25.bmp", "AF26.bmp", "AF27.bmp", "AF28.bmp", "AF29.bmp", "AF30.bmp", "AF31.bmp", "AF32.bmp")
/ replace = false
/ selectionrate = always
</list>

<list VSListMH>
/ items = ("HM1.bmp", "HM2.bmp", "HM3.bmp", "HM4.bmp", "HM5.bmp", "HM6.bmp", "HM7.bmp", "HM8.bmp", "HM9.bmp", "HM10.bmp", "HM11.bmp", "HM12.bmp", "HM13.bmp", "HM14.bmp", "HM15.bmp", "HM16.bmp", "HM17.bmp", "HM18.bmp", "HM19.bmp", "HM20.bmp", "HM21.bmp", "HM22.bmp", "HM23.bmp", "HM24.bmp", "HM25.bmp", "HM26.bmp", "HM27.bmp", "HM28.bmp", "HM29.bmp", "HM30.bmp", "HM31.bmp", "HM32.bmp")
/ replace = false
/ selectionrate = always
</list>

<list VSListMA>
/ items = ("AM1.bmp", "AM2.bmp", "AM3.bmp", "AM4.bmp", "AM5.bmp", "AM6.bmp", "AM7.bmp", "AM8.bmp", "AM9.bmp", "AM10.bmp", "AM11.bmp", "AM12.bmp", "AM13.bmp", "AM14.bmp", "AM15.bmp", "AM16.bmp",
"AM17.bmp", "AM18.bmp", "AM19.bmp", "AM20.bmp", "AM21.bmp", "AM22.bmp", "AM23.bmp", "AM24.bmp", "AM25.bmp", "AM26.bmp", "AM27.bmp", "AM28.bmp", "AM29.bmp", "AM30.bmp", "AM31.bmp", "AM32.bmp")
/ replace = false
/ selectionrate = always
</list>

<picture VSPicLeft>
/position = (40%,50%)
/items = ("Template.bmp")
</picture>

<picture VSPicRight>
/position = (60%,50%)
/items = ("Template.bmp")
</picture>

<trial VS_FHFA>
/ontrialbegin = [picture.VSPicLeft.setitem(list.VSListFH.nextvalue, 1)]
/ontrialbegin = [picture.VSPicRight.setitem(list.VSListFA.nextvalue, 1)]
/stimulustimes = [1 = Fix; 500 = VSPicleft, VSPicRight]
/inputdevice = keyboard
/validresponse = ("m","x")
/correctresponse = ("x")
/errormessage = true(Incorrect, 1000)
</trial>

<trial VS_FHMA>
/ontrialbegin = [picture.VSPicLeft.setitem(list.VSListFH.nextvalue, 1)]
/ontrialbegin = [picture.VSPicRight.setitem(list.VSListMA.nextvalue, 1)]
/stimulustimes = [1 = Fix; 500 = VSPicleft, VSPicRight]
/inputdevice = keyboard
/validresponse = ("m","x")
/correctresponse = ("x")
/errormessage = true(Incorrect, 1000)
</trial>

(and a bunch more trials)


From the debug Window I can see there is a list item selected in 'nextvalue', but it is not being set to the picture. When I try to run the script I get the error: "picture.VSPicLeft: Unable to initialize <picture VSPicLeft> item number 1. Verify the item exists and is correctly defined."

Any idea where I'm going wrong?
By Dave - 2/28/2016

I cannot tell you where exactly you are going wrong without the actual image files. However, this is not a good way to go about this anyway for performance reasons alone. You should instead set up an <item> element that contains all images

<item allpics>
/ 1 = "HF1.bmp"
...
/ 33 = "AF1.bmp"
...
/ 65 = "HM1.bmp"
...
/ 97 = "AM1.bmp"
...
</item>

reference that <item> element in your <picture> elements

<picture VSPicLeft>
/position = (40%,50%)
/items = allitems
/ select = values.leftpic
</picture>

<picture VSPicRight>
/position = (60%,50%)
/ items = allitems
/select= values.rightpic
</picture>

with

<values>
/ leftpic = 1
/ rightpic = 1
...
</values>

and then merely draw the proper *item numbers* from your various <list>s and store them in the above <values>:

* FH item numbers are 1 to 32*
<list VSListFH>
/ items = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32)
...
</list>

*FA item numbers are 33 to 64*
<list VSListFA>
/ items = (33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64)
...
</list>
...

with


<trial VS_FHFA>
/ontrialbegin = [values.leftpic = list.VSListFH.nextvalue ]
/ontrialbegin = [values.rightpic = list.VSListFA.nextvalue ]

/stimulustimes = [1 = Fix; 500 = VSPicleft, VSPicRight]
/inputdevice = keyboard
/validresponse = ("m","x")
/correctresponse = ("x")
/errormessage = true(Incorrect, 1000)
</trial>
By Lizzy - 2/29/2016

Thanks Dave for that solution. Works like a charm!