Controlling number of stimuli of same type presented in a row


Author
Message
Lewis99
Lewis99
Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)
Group: Forum Members
Posts: 9, Visits: 73
Hi,
I am a bit stuck on a problem and haven't been able to get any of the similar solutions I've seen on the forum to work for me so was wondering if someone would be able to help. I have a list of 100 items (item pos), containing images (picture pos) divided "high" emotional intensity and "low" emotional intensity groups (Images prefixed with HP = high intensity, images prefixed with LP = low intensity). Each block maintains the same image throughout, however I want the blocks to present no more than two images of the same intensity in a row, but can't figure out how to do this. Any help would be appreciated. I've posted the relevant parts of my code below, trying to exclude extraneous information. Please let me know if you need any further information or code.
Best,
Lewis

<values>
/countposblocks = 0
/fixationduration = 0
/blankduration = 0
/trialimagepos = 0
/intialstrategy = 0
/strategychoice = 0
</values>

<parameters>
/nr_totalpostrialblocks = 5
</parameters>

<picture pos>
/ items = pos
/ select = values.trialimagepos
/ size = (50%, 50%)
/ position = (50%, 50%)
</picture>

<item pos> #have shortened the list to keep this post manageable.#
/1 = "HPAstronaut 1.jpg"
/2 = "HPBeach 1.jpg"
/3 = "HPBungee jumping 2.jpg"
/4 = "HPCat 5.jpg"
/5 = "HPCliff diver 1.jpg"
/6 = "LPCold 5.jpg"
/7 = "LPCollaboration 1.jpg"
/8 = "LPDancing 7.jpg"
/9 = "LPDessert 2.jpg"
/10 = "LPDessert 4.jpg"
</item>

<counter itemspos>
/ select = noreplace(1-10)
/ selectionrate = always
/ resetinterval = 0
</counter>

<block pos>
/ onblockbegin = [
  values.countposblocks += 1;
  values.trialimagepos=counter.itemspos.selectedvalue;
  ]
/ trials = [1= trial.regulationposone; 2=trial.regulationpostwo]
/ branch = [
if (values.countposblocks < parameters.nr_totalpostrialblocks){ return block.pos}
else values.countposblocks = 0]
/ onblockend = [
values.trialimagepos = 0;
]
</block>

<trial regulationposone>
/ ontrialbegin = [
  trial.regulationposone.resetstimulusframes();
  values.fixationduration = round(rand(2100, 2900));
  values.blankduration = round(rand(400, 800));
    values.intialstrategy = round(rand(1, 2));
    trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration);
  trial.regulationposone.insertstimulustime(text.initialstrategy, values.fixationduration);
  trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration + 2500);
    trial.regulationposone.insertstimulustime(picture.pos, values.fixationduration + 2500 + values.blankduration); #selected high or low intensity image is inserted here#
  trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration + 2500 + values.blankduration + 3000);
    ]
/ stimulustimes = [0=fixation;]
/ timeout = values.fixationduration + 2500 + values.blankduration + 3000
</trial>

<trial regulationpostwo>
/ ontrialbegin = [
  trial.regulationpostwo.resetstimulusframes();
  values.blankduration = round(rand(400, 800));
  trial.regulationpostwo.insertstimulustime(text.strategychoice, +0);
  trial.regulationpostwo.insertstimulustime(clearscreen, + 2000);
    trial.regulationpostwo.insertstimulustime(picture.pos, 2000 + values.blankduration); #trial two uses the same images as trial one#
  trial.regulationpostwo.insertstimulustime(clearscreen, 2000 + values.blankduration + 3000);
]
/ stimulustimes = [0=strategychoice;]
/ timeout = 2000 + values.blankduration + 3000
</trial>



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: 12K, Visits: 98K
Lewis99 - 1/8/2024
Hi,
I am a bit stuck on a problem and haven't been able to get any of the similar solutions I've seen on the forum to work for me so was wondering if someone would be able to help. I have a list of 100 items (item pos), containing images (picture pos) divided "high" emotional intensity and "low" emotional intensity groups (Images prefixed with HP = high intensity, images prefixed with LP = low intensity). Each block maintains the same image throughout, however I want the blocks to present no more than two images of the same intensity in a row, but can't figure out how to do this. Any help would be appreciated. I've posted the relevant parts of my code below, trying to exclude extraneous information. Please let me know if you need any further information or code.
Best,
Lewis

<values>
/countposblocks = 0
/fixationduration = 0
/blankduration = 0
/trialimagepos = 0
/intialstrategy = 0
/strategychoice = 0
</values>

<parameters>
/nr_totalpostrialblocks = 5
</parameters>

<picture pos>
/ items = pos
/ select = values.trialimagepos
/ size = (50%, 50%)
/ position = (50%, 50%)
</picture>

<item pos> #have shortened the list to keep this post manageable.#
/1 = "HPAstronaut 1.jpg"
/2 = "HPBeach 1.jpg"
/3 = "HPBungee jumping 2.jpg"
/4 = "HPCat 5.jpg"
/5 = "HPCliff diver 1.jpg"
/6 = "LPCold 5.jpg"
/7 = "LPCollaboration 1.jpg"
/8 = "LPDancing 7.jpg"
/9 = "LPDessert 2.jpg"
/10 = "LPDessert 4.jpg"
</item>

<counter itemspos>
/ select = noreplace(1-10)
/ selectionrate = always
/ resetinterval = 0
</counter>

<block pos>
/ onblockbegin = [
  values.countposblocks += 1;
  values.trialimagepos=counter.itemspos.selectedvalue;
  ]
/ trials = [1= trial.regulationposone; 2=trial.regulationpostwo]
/ branch = [
if (values.countposblocks < parameters.nr_totalpostrialblocks){ return block.pos}
else values.countposblocks = 0]
/ onblockend = [
values.trialimagepos = 0;
]
</block>

<trial regulationposone>
/ ontrialbegin = [
  trial.regulationposone.resetstimulusframes();
  values.fixationduration = round(rand(2100, 2900));
  values.blankduration = round(rand(400, 800));
    values.intialstrategy = round(rand(1, 2));
    trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration);
  trial.regulationposone.insertstimulustime(text.initialstrategy, values.fixationduration);
  trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration + 2500);
    trial.regulationposone.insertstimulustime(picture.pos, values.fixationduration + 2500 + values.blankduration); #selected high or low intensity image is inserted here#
  trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration + 2500 + values.blankduration + 3000);
    ]
/ stimulustimes = [0=fixation;]
/ timeout = values.fixationduration + 2500 + values.blankduration + 3000
</trial>

<trial regulationpostwo>
/ ontrialbegin = [
  trial.regulationpostwo.resetstimulusframes();
  values.blankduration = round(rand(400, 800));
  trial.regulationpostwo.insertstimulustime(text.strategychoice, +0);
  trial.regulationpostwo.insertstimulustime(clearscreen, + 2000);
    trial.regulationpostwo.insertstimulustime(picture.pos, 2000 + values.blankduration); #trial two uses the same images as trial one#
  trial.regulationpostwo.insertstimulustime(clearscreen, 2000 + values.blankduration + 3000);
]
/ stimulustimes = [0=strategychoice;]
/ timeout = 2000 + values.blankduration + 3000
</trial>



You need a list than encodes intensity (hi vs low) with its /maxrunsize set to 2. You also need a list containing the item numbers for all "hi" items in pos an all "lo" items in pos.

You sample a value from this list at the start of each block. Depending on the value sampled ("lo" or "hi"), you then sample an item number from the appropriate item number list,

<list intensity>
/ items = (
    "hi", "hi", "hi", "hi", "hi",
    "lo", "lo", "lo", "lo", "lo"
    )
/ maxrunsize = 2 // no more than 2 hi or lo in a row
</list>

// items 1 to 5 are hi
<list hi_itemnumbers>
/ items = (1,2,3,4,5)
</list>

// items 6 to 10 are lo
<list lo_itemnumbers>
/ items = (6,7,8,9,10)
</list>

<item pos>
/1 = "HPAstronaut 1.jpg"
/2 = "HPBeach 1.jpg"
/3 = "HPBungee jumping 2.jpg"
/4 = "HPCat 5.jpg"
/5 = "HPCliff diver 1.jpg"
/6 = "LPCold 5.jpg"
/7 = "LPCollaboration 1.jpg"
/8 = "LPDancing 7.jpg"
/9 = "LPDessert 2.jpg"
/10 = "LPDessert 4.jpg"
</item>

<text pos>
/ items = item.pos
/ select = values.itemnumber
</text>

<values>
/ intensity = "?"
/ itemnumber = 1
</values>

<block exampleblock>
/ onblockbegin = [
    values.intensity = list.intensity.nextvalue; // sample intensity for this block, hi vs lo
    if (values.intensity == "hi") { // if selected intensity is hi
        values.itemnumber = list.hi_itemnumbers.nextvalue; // select a hi intensity item
    } else { // otherwise
        values.itemnumber = list.lo_itemnumbers.nextvalue; // select a lo intensity item
    };
]
/ trials = [1=trial.exampletrial]
</block>

<trial exampletrial>
/ stimulusframes = [1=text.pos]
/ validresponse = (57)
</trial>

<expt exampleexpt>
/ blocks = [1-10 = block.exampleblock]
</expt>

<data>
/ columns = (date time subject group session blocknum blockcode trialnum trialcode stimulusitem stimulusnumber
    response latency correct values.intensity values.itemnumber)
</data>


Lewis99
Lewis99
Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)
Group: Forum Members
Posts: 9, Visits: 73
Hi Dave,
Legendary, thanks again for your help. Just wondering, I have two types of stimuli, positive picture and negative pictures (groups of blocks will alternate between positive and negative pictures - with 25 images in each group of blocks) . The negative pictures will use the same rule as the positive ones with regards to the number of high and low intensity pictures that will be selected in a row.

My question is will I need to make separate lists of high and low numbers, and intensity for positive and negative images, or can i just use the same list.

For example do I have to do:
<list intensitypos>
/ items = (
  "hi", "hi", "hi", "hi", "hi",
  "lo", "lo", "lo", "lo", "lo"
  )
/ maxrunsize = 2
</list>

<list intensityneg>
/ items = (
"hi", "hi", "hi", "hi", "hi",
"lo", "lo", "lo", "lo", "lo"
)
/ maxrunsize = 2
</list>

<list hi_itemnumberspos>
/ items = (1,2,3,4,5)
</list>

<list lo_itemnumberspos>
/ items = (6,7,8,9,10)
</list>

<list hi_itemnumbersneg>
/ items = (1,2,3,4,5)
</list>

<list lo_itemnumbersneg>
/ items = (6,7,8,9,10)
</list>


Or will having the one list work? Just wondering if having the one list might impact image selection.
Thanks,
Lewis


Lewis99
Lewis99
Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)Associate Member (96 reputation)
Group: Forum Members
Posts: 9, Visits: 73
Hi Dave,
I tried implementing that code but have run into a problem. Each block is only selecting the first image in the list of images, not a random image. Then on the next block the same image is being selected. Do you know where I've gone wrong here?
Thanks,
Lewis


<values>
/itemnumber = 1
/intensity = "?"
</values>

<parameters>
/nr_totalpostrialblocks = 25
/nr_totalnegtrialblocks = 25
</parameters>
<list intensity>
/ items = (
"hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi"
"lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo" )
/ maxrunsize = 2
</list>

<list hi_itemnumbers>
/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, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50)
</list>

<list lo_itemnumbers>
/items (51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100)
</list>

<picture pos>
/ items = item.pos
/ select = values.itemnumber
/ size = (60%, 60%)
/ position = (50%, 50%)
</picture>

<item pos>
/1 = "HPAstronaut 1.jpg"
/2 = "HPBeach 1.jpg"
/3 = "HPBungee jumping 2.jpg"
/4 = "HPCat 5.jpg"
/5 = "HPCliff diver 1.jpg"
/6 = "HPCliff diver 3.jpg"
/7 = "HPCouple 4.jpg"
/8 = "HPDog 5.jpg"
/9 = "HPDog 6.jpg"
/10 = "HPDog 12.jpg" //continues till item 100
/100 = "LPBear 1.jpg"
</item>

<block pos>
/ onblockbegin = [
    values.trialcount +=1;
    values.countposblocks += 1;
    values.intensity = list.intensity.nextvalue;
    if (values.intensity == "hi") {
        values.itemnumber = list.hi_itemnumbers.nextvalue;
    } else {
        values.itemnumber = list.lo_itemnumbers.nextvalue;
            };
    ]
/ trials = [1= trial.regulationposone; 2= likert.Arousalposquestions; 3=trial.moinitoringchoice; 4=trial.regulationpostwo; 5= likert.Arousalposquestions]
/ branch = [
if (values.countposblocks < parameters.nr_totalpostrialblocks){ return block.pos}
else values.countposblocks = 0]
/ onblockend = [
values.strategychoice = 0;
values.trialimagepos = 0;
values.monitoringchoice = 0;
]
</block>

<trial regulationposone>
/ ontrialbegin = [
  trial.regulationposone.resetstimulusframes();
  values.fixationduration = round(rand(2100, 2900));
  values.blankduration = round(rand(400, 800));
    values.intialstrategy = round(rand(1, 2));
    trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration);
  trial.regulationposone.insertstimulustime(text.initialstrategy, values.fixationduration);
  trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration + 2500);
    trial.regulationposone.insertstimulustime(picture.pos, values.fixationduration + 2500 + values.blankduration);
  trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration + 2500 + values.blankduration + 3000);
    ]
/ stimulustimes = [0=fixation;]
/ timeout = values.fixationduration + 2500 + values.blankduration + 3000
</trial>

<trial regulationpostwo>
/ ontrialbegin = [
    values.monitoringchoice = 0;
  trial.regulationpostwo.resetstimulusframes();
  values.blankduration = round(rand(400, 800));
  trial.regulationpostwo.insertstimulustime(text.strategychoice, +0);
  trial.regulationpostwo.insertstimulustime(clearscreen, + 2000);
    trial.regulationpostwo.insertstimulustime(picture.pos, 2000 + values.blankduration);
  trial.regulationpostwo.insertstimulustime(clearscreen, 2000 + values.blankduration + 3000);
]
/ stimulustimes = [0=strategychoice;]
/ timeout = 2000 + values.blankduration + 3000
</trial>



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: 12K, Visits: 98K
Lewis99 - 1/9/2024
Hi Dave,
I tried implementing that code but have run into a problem. Each block is only selecting the first image in the list of images, not a random image. Then on the next block the same image is being selected. Do you know where I've gone wrong here?
Thanks,
Lewis


<values>
/itemnumber = 1
/intensity = "?"
</values>

<parameters>
/nr_totalpostrialblocks = 25
/nr_totalnegtrialblocks = 25
</parameters>
<list intensity>
/ items = (
"hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi", "hi"
"lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo", "lo" )
/ maxrunsize = 2
</list>

<list hi_itemnumbers>
/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, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50)
</list>

<list lo_itemnumbers>
/items (51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100)
</list>

<picture pos>
/ items = item.pos
/ select = values.itemnumber
/ size = (60%, 60%)
/ position = (50%, 50%)
</picture>

<item pos>
/1 = "HPAstronaut 1.jpg"
/2 = "HPBeach 1.jpg"
/3 = "HPBungee jumping 2.jpg"
/4 = "HPCat 5.jpg"
/5 = "HPCliff diver 1.jpg"
/6 = "HPCliff diver 3.jpg"
/7 = "HPCouple 4.jpg"
/8 = "HPDog 5.jpg"
/9 = "HPDog 6.jpg"
/10 = "HPDog 12.jpg" //continues till item 100
/100 = "LPBear 1.jpg"
</item>

<block pos>
/ onblockbegin = [
    values.trialcount +=1;
    values.countposblocks += 1;
    values.intensity = list.intensity.nextvalue;
    if (values.intensity == "hi") {
        values.itemnumber = list.hi_itemnumbers.nextvalue;
    } else {
        values.itemnumber = list.lo_itemnumbers.nextvalue;
            };
    ]
/ trials = [1= trial.regulationposone; 2= likert.Arousalposquestions; 3=trial.moinitoringchoice; 4=trial.regulationpostwo; 5= likert.Arousalposquestions]
/ branch = [
if (values.countposblocks < parameters.nr_totalpostrialblocks){ return block.pos}
else values.countposblocks = 0]
/ onblockend = [
values.strategychoice = 0;
values.trialimagepos = 0;
values.monitoringchoice = 0;
]
</block>

<trial regulationposone>
/ ontrialbegin = [
  trial.regulationposone.resetstimulusframes();
  values.fixationduration = round(rand(2100, 2900));
  values.blankduration = round(rand(400, 800));
    values.intialstrategy = round(rand(1, 2));
    trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration);
  trial.regulationposone.insertstimulustime(text.initialstrategy, values.fixationduration);
  trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration + 2500);
    trial.regulationposone.insertstimulustime(picture.pos, values.fixationduration + 2500 + values.blankduration);
  trial.regulationposone.insertstimulustime(clearscreen, values.fixationduration + 2500 + values.blankduration + 3000);
    ]
/ stimulustimes = [0=fixation;]
/ timeout = values.fixationduration + 2500 + values.blankduration + 3000
</trial>

<trial regulationpostwo>
/ ontrialbegin = [
    values.monitoringchoice = 0;
  trial.regulationpostwo.resetstimulusframes();
  values.blankduration = round(rand(400, 800));
  trial.regulationpostwo.insertstimulustime(text.strategychoice, +0);
  trial.regulationpostwo.insertstimulustime(clearscreen, + 2000);
    trial.regulationpostwo.insertstimulustime(picture.pos, 2000 + values.blankduration);
  trial.regulationpostwo.insertstimulustime(clearscreen, 2000 + values.blankduration + 3000);
]
/ stimulustimes = [0=strategychoice;]
/ timeout = 2000 + values.blankduration + 3000
</trial>



Your item number lists are effecitvely empty, because you're missing the = after /items.




GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search