issue with randomization


Author
Message
jl_4105
jl_4105
Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)
Group: Forum Members
Posts: 2, Visits: 8
Hello,

I am writing a script which asks trials pull images and instruction cues randomly from an item list. Overall this is the goal layout of the script:
-randomly display 4 different types of blocks throughout a total of 36 blocks, with no back-to-back repeats of block type: high, medium, low, and neutral
-each block is composed of a fixation cross, an instruction cue (one of 3: reappraise, suppress, respond naturally), and 3 images presented from a pool of images (there are 27 high, 27 medium, 27 low, and 27 neutral images in four separate item lists, each matching their respective trials and blocks). Finally there is an affect rating using the likert element.
***so as an example, the high blocks follow this pattern: + (4000 ms) > 1 of 3 instruction cues displayed (2000 ms) > + (4000 ms) > high_image (6000 ms) > high_image (6000 ms) > high_image (6000 ms) > affect rating (4000 ms) and then repeat, moving onto the next block type randomly.
-due to different timing-lengths of instruction and image presentations, I have created separate trials for each of the block components listed above. 

Since the blocks are pulled randomly, I need to make sure that instruction cues and images are selected only once throughout the entire experiment, and that the pairing of instruction and image presentation is completely random. For example, there are 36 blocks throughout the experiment and 9 of them will be "high" blocks. Each of those high blocks will have a trial displaying 1 of 3 instruction cues, so essentially I should see 3 high blocks paired with each instruction cue (3 high blocks with "reappraise" instruction, 3  with "suppress" instruction, and 3 with "respond naturally"). Each of the high blocks should also display 3 randomly selected images from the high picture list, and there should be no repeats. This is the same pattern for medium, low, and neutral blocks, and the manner in which different instruction cues are paired with different images should be entirely random.

I have fixed the issue of only using instructions and images once with the following expression (example from one of my high picture trials):  / ontrialend = [picture.high.removeitem(picture.high.currentindex)].

However, I have two problems that remain:
1. The random pulling of images and instruction cues over the course of the experiment does not appear to be random at all. For example, when I go through the task, I consistently see the same 3 high images grouped together, the same 3 medium, etc, although their overall place in the experiment in terms of block number may be different. I have tried using both the "noreplace" and "noreplacenorepeat" selection types and this does not fix the problem. I should also mentioned that I tried using a counter (from another discussion I saw) in order to achieve random selection. Unfortunately, my script routinely crashed throughout piloting while using the counter, with a message that stated that it could not locate image ##. This "missing" image number changed across different pilots, but I have checked and all images are correctly loaded into the same file as the script.

2. When I review the data file that is created, the last few trials are missing information, specifically the instruction cue and image file names in the stimulusitem column. When I go through the task, the last few trials are visually complete, and when manually keeping track of images and instruction cues, all images and instruction cues are used evenly. So even though the data file says it's missing information, the actual presentation is not. So what's alarming is the error in my data file, and what's even more alarming is that the image (in stimulusitem column) listed in the data file seems incorrect. For example, it tells me that in the last block, I only showed 2 images instead of 3, and the image that is missing (when referencing the entire image list) is 1234.jpg. However, I know that image 1234.jpg was actually displayed during the second block of the experiment. As you might imagine, this is throwing into question the accuracy of my data file, which is very unsettling.

I am pasting a portion of my script below, in hopes that you might be able to see what I'm doing wrong. Any help you could provide would be greatly appreciated!

JL








***********************************************************************************************************
******************************************************BUILDING IMAGE TRIALS********************************
***********************************************************************************************************

<picture high>
/items = ("h3350.jpg", "h6210.jpg", "h1040.jpg", "h9500.jpg", "h6410.jpg", "h6230.jpg", "h6190.jpg", "h9050.jpg", "h9622.jpg", "h9571.jpg", "h6200.jpg", "h9570.jpg", "h1220.jpg", "h9921.jpg", "h9911.jpg", "h2730.jpg", "h9040.jpg", "h9300.jpg", "h2710.jpg", "h9400.jpg", "h2800.jpg", "h6831.jpg", "h3071.jpg", "h9180.jpg", "h6212.jpg", "h9250.jpg" , "h9181.jpg")
/position = (50,50)
/select = noreplacenorepeat(high)
/resetinterval = 0
/selectionrate = always
</picture>
<trial high>
/ recorddata = true
/ stimulusframes = [1=noreplacenorepeat(high)]
/ timeout = 6000
/ ontrialend = [picture.high.removeitem(picture.high.currentindex)]
</trial>

<picture med>
/items = ("m9530.jpg", "m6610.jpg", "m5940.jpg", "m6260.jpg", "m9600.jpg", "m9920.jpg", "m9440.jpg", "m9432.jpg", "m1240.jpg", "m9910.jpg", "m1230.jpg", "m9415.jpg", "m3550.jpg", "m9320.jpg", "m9611.jpg", "m9800.jpg", "m6300.jpg", "m9160.jpg", "m9110.jpg", "m2053.jpg", "m9140.jpg", "m1030.jpg", "m7360.jpg", "m9120.jpg", "m2110.jpg", "m7380.jpg", "m6570.jpg")
/position = (50,50)
/select = noreplacenorepeat(med)
/resetinterval = 0
/selectionrate = always
</picture>
<trial med>
/ recorddata = true
/ stimulusframes = [1=noreplacenorepeat(med)]
/ timeout = 6000
/ ontrialend = [picture.med.removeitem(picture.med.currentindex)]
</trial>

<picture low>
/items = ("l1110.jpg", "l9470.jpg", "l9520.jpg", "l1274.jpg", "l9010.jpg", "l2130.jpg", "l9190.jpg", "l6000.jpg", "l9090.jpg", "l9001.jpg", "l9560.jpg", "l1112.jpg", "l2520.jpg", "l9830.jpg", "l3300.jpg", "l2220.jpg", "l9330.jpg", "l9000.jpg", "l6930.jpg", "l1301.jpg", "l9404.jpg", "l7920.jpg", "l2490.jpg", "l9421.jpg", "l9230.jpg", "l9270.jpg", "l1270.jpg")
/position = (50,50)
/select = noreplacenorepeat(low)
/resetinterval = 0
/selectionrate = always
</picture>
<trial low>
/ recorddata = true
/ stimulusframes = [1=noreplacenorepeat(low)]
/ timeout = 6000
/ ontrialend = [picture.low.removeitem(picture.low.currentindex)]
</trial>

<picture neu>
/items = ("n7352.jpg", "n7190.jpg", "n5731.jpg", "n7040.jpg", "n7009.jpg", "n7150.jpg", "n7233.jpg", "n7100.jpg", "n7820.jpg", "n7025.jpg", "n5530.jpg", "n7490.jpg", "n7285.jpg", "n7140.jpg", "n5250.jpg", "n7080.jpg", "n5001.jpg", "n7006.jpg", "n7035.jpg", "n7130.jpg", "n7050.jpg", "n7550.jpg", "n7500.jpg", "n7090.jpg", "n7235.jpg", "n5800.jpg", "n7000.jpg")
/position = (50,50)
/select = noreplacenorepeat(neu)
/resetinterval = 0
/selectionrate = always
</picture>
<trial neu>
/ recorddata = true
/ stimulusframes = [1=noreplacenorepeat(neu)]
/ timeout = 6000
/ ontrialend = [picture.neu.removeitem(picture.neu.currentindex)]
</trial>

****************************************************************************************************
**********************************************BUILDING INSTRUCTION TRIALS***************************
****************************************************************************************************

********************* INSTRUCTIONS- HIGH IMAGES (1/3 of TRIALS SHOULD RECEIVE EACH CUE)***********************
<text instructionH>
/ items = ("REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY", "REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY", "REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY")
/ position = (50,50)
/ select = noreplacenorepeat(instructionH)
/ resetinterval = 36
/ selectionrate = always
/ txcolor = (0,0,0)
/ txbgcolor = (transparent)
/ fontstyle = ("Arial", 25pt)
</text>
<trial instructionH>
/ recorddata = true
/ stimulusframes = [1=noreplacenorepeat(instructionH)]
/ timeout = 2000
/ ontrialend = [text.instructionH.removeitem(text.instructionH.currentindex)]
</trial>

********************* INSTRUCTIONS- MED IMAGES (1/3 of TRIALS SHOULD RECEIVE EACH CUE)***********************
<text instructionM>
/ items = ("REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY", "REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY", "REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY")
/ position = (50,50)
/ select = noreplacenorepeat(instructionM)
/ resetinterval = 36
/ selectionrate = always
/ txcolor = (0,0,0)
/ txbgcolor = (transparent)
/ fontstyle = ("Arial", 25pt)
</text>
<trial instructionM>
/ recorddata = true
/ stimulusframes = [1=noreplacenorepeat(instructionM)]
/ timeout = 2000
/ ontrialend = [text.instructionM.removeitem(text.instructionM.currentindex)]
</trial>

********************* INSTRUCTIONS- LOW IMAGES (1/3 of TRIALS SHOULD RECEIVE EACH CUE)***********************
<text instructionL>
/ items = ("REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY", "REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY", "REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY")
/ position = (50,50)
/ select = noreplacenorepeat(instructionL)
/ resetinterval = 36
/ selectionrate = always
/ txcolor = (0,0,0)
/ txbgcolor = (transparent)
/ fontstyle = ("Arial", 25pt)
</text>
<trial instructionL>
/ recorddata = true
/ stimulusframes = [1=noreplacenorepeat(instructionL)]
/ timeout = 2000
/ ontrialend = [text.instructionL.removeitem(text.instructionL.currentindex)]
</trial>

********************* INSTRUCTIONS- NEUTRAL IMAGES (1/3 of TRIALS SHOULD RECEIVE EACH CUE)***********************
<text instructionN>
/ items = ("REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY", "REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY", "REAPPRAISE", "SUPPRESS", "RESPOND NATURALLY")
/ position = (50,50)
/ select = noreplacenorepeat(instructionN)
/ resetinterval = 36
/ selectionrate = always
/ txcolor = (0,0,0)
/ txbgcolor = (transparent)
/ fontstyle = ("Arial", 25pt)
</text>
<trial instructionN>
/ recorddata = true
/ stimulusframes = [1=noreplacenorepeat(instructionN)]
/ timeout = 2000
/ ontrialend = [text.instructionN.removeitem(text.instructionN.currentindex)]
</trial>


*******************************************************************************************
**********************************************BUILDING AFFECT RATING***********************
*******************************************************************************************

<text feeling>
/ items = ("How negative do you feel?")
/ txcolor = (0,0,0)
/ position = (50%, 25%)
/ txbgcolor = (transparent)
/ fontstyle = ("Arial", 25pt)
</text>

<clock stopwatch>
/ mode = timer
/ txcolor = black
/ txbgcolor = (192, 192, 192)
/ format = "s"
/ position = (50%, 90%)
/ resetrate = trial
/ timeout = 4000
/ fontstyle = ("Arial", 30pt)
/ erase = (192, 192, 192)
</clock>

<likert affect>
/ anchors= [1= "Not at all negative"; 2= " "; 3= " "; 4= " "; 5= "Extremely negative"]
/ anchorwidth = (12%)
/ buttonvalues= [1= "1"; 2= "2"; 3= "3"; 4= "4"; 5= "5"]
/ stimulusframes= [1=feeling, stopwatch]
/ fontstyle = ("Arial", 20pt)
/ mouse = true
/ timeout = 4000
</likert>

*******************************************************************************************************
**********************************************BUILDING BLOCKS******************************************
*******************************************************************************************************

<block high>
/ trials = [1,3= +; 2= noreplacenorepeat(instructionH); 4,5,6= noreplacenorepeat(high); 7=affect]
/ recorddata = true
</block>

<block med>
/ trials = [1,3= +; 2= noreplacenorepeat(instructionM); 4,5,6= noreplacenorepeat(med); 7=affect]
/ recorddata = true
</block>

<block low>
/ trials = [1,3= +; 2= noreplacenorepeat(instructionL); 4,5,6= noreplacenorepeat(low); 7=affect]
/ recorddata = true
</block>

<block neu>
/ trials = [1,3= +; 2= noreplacenorepeat(instructionN); 4,5,6= noreplacenorepeat(neu); 7=affect]
/ recorddata = true
</block>

***************************************************************************************************
**********************************************BUILDING EXPERIMENT**********************************
***************************************************************************************************

<expt EmoReg>
/ blocks = [1-36= noreplacenorepeat(high,med,low,neu)]
</expt>

<data>
/ columns = [date, time, group, subject, blockcode, trialcode, stimulusitem, response, totalcount, latency]
/ labels = true
</data>







Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
<picture high>
/items = ("h3350.jpg", "h6210.jpg", "h1040.jpg", "h9500.jpg", "h6410.jpg", "h6230.jpg", "h6190.jpg", "h9050.jpg", "h9622.jpg", "h9571.jpg", "h6200.jpg", "h9570.jpg", "h1220.jpg", "h9921.jpg", "h9911.jpg", "h2730.jpg", "h9040.jpg", "h9300.jpg", "h2710.jpg", "h9400.jpg", "h2800.jpg", "h6831.jpg", "h3071.jpg", "h9180.jpg", "h6212.jpg", "h9250.jpg" , "h9181.jpg")
/position = (50,50)
/select = noreplacenorepeat(high)
/resetinterval = 0
/selectionrate = always
</picture>

Each item in the <picture> element is unique as far as I can see. Hence

/ select = noreplacenorepeat

does not make any sense here. If every item is different, what could possibly repeat? noreplace is the suitable selection mode.

Moreover the (high) dependency

/select = noreplacenorepeat(high)

makes no sense -- how could the selection for the stimulus <picture high> at the same time depend on the selection for <picture high>? It should simply read

/ select = noreplace

The /resetinterval setting will keep the stimulus' selection pool intact across blocks. I.e., if item 5 gets randomly selected in the 1st block, it won't be selected in the 2nd, 3rd, etc. (until the stimulus element runs out of items).

/ selectionrate = always is also unnecessary. As far as I can see, you want to sample *one* item per trial, not multiple. Leave it at

/ selectionrate = trial or remove the attribute entirely (one item per trial is the default).

<trial high>
/ recorddata = true
/ stimulusframes = [1=noreplacenorepeat(high)]
/ timeout = 6000
/ ontrialend = [picture.high.removeitem(picture.high.currentindex)]
</trial>

Here, too, / stimulusframes = [1=noreplacenorepeat(high)] makes no sense / does nothing. The trial only displays a single stimulus -- high -- so there is nothing that could possibly repeat. It should simply read

/ stimulusframes = [1=high]

Don't remove items at runtime via / ontrialend = [picture.high.removeitem(picture.high.currentindex)]. This will obviously change (a) the element's item count as well as (b) the respective *item index numbers*. I.e., if the 2nd item is removed, what was previously the 3rd item is now the 2nd item and so forth. That's the cause of the runtime errors you described: You are referring to items which no longer exist because you explicitly removed them.

The above is just an example. Your other stimulus elements suffer from the same issues, as do e.g. the /trials attributes in your <block> elements.

jl_4105
jl_4105
Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)Partner Member (601 reputation)
Group: Forum Members
Posts: 2, Visits: 8
Your suggestions fixed all the issues, not sure why I hadn't tried it before. Thank you for your help!

JL
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
Great -- thanks for the update!

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search