list selection based on criteria


Author
Message
nfbecker
nfbecker
New Member (29 reputation)New Member (29 reputation)New Member (29 reputation)New Member (29 reputation)New Member (29 reputation)New Member (29 reputation)New Member (29 reputation)New Member (29 reputation)New Member (29 reputation)
Group: Forum Members
Posts: 7, Visits: 39
Hi!
I'm struggeling to program a presentation of pictures and texts with randomized selection based on specific criteria: I want to randomly select three out of five pictures from each category A and B. For each selected picture, I also want to select a text corresponding to the same category A or B. Within a block, the trials could look like this: picA1-textA2, picA2-textA1, picB1-textB5, ... (each picture-text combination is presented twice)

I've tried different settings using the variables within /onBlockBegin. But currently, I either manage to present the corresponding pairs by item numbers (picA1-textA1) or present compleatly random combinations and mixing A and B incorrectly (picA1-textB2).
What I'm looking for is something like "if list.selected_picA then list.selected_textA", but I cannot figure out how to program this dependency correctly. 
I would really appreciate your help or hints!

This is the code I'm working with at the moment:
<item pic_all>
/ 1 = "picA1"
/ 2 = "picA2"
/ 3 = "picA3"
/ 4 = "picA4"
/ 5 = "picA5"
/ 6 = "picB1"
/ 7 = "picB2"
/ 8 = "picB3"
/ 9 = "picB4"
/ 10 = "picB5"
</item>
<list selected_pic>
</list>
<text pic>
/ items = pic_all
/ position = (50, 40)
/ select = list.selected_pic.nextvalue
</text>
<list selected_picA>
/ items = (1-5)
/ selectionrate = always
</list>
<list selected_picB>
/ items = (6-10)
/ selectionrate = always
</list>

<item text_all>
/ 1 = "textA1"
/ 2 = "textA2"
/ 3 = "textA3"
/ 4 = "textA4"
/ 5 = "textA5"
/ 6 = "textB1"
/ 7 = "textB2"
/ 8 = "textB3"
/ 9 = "textB4"
/ 10 = "textB5"
</item>
<list selected_text>
</list>
<text text>
/ items = text_all
/ position = (50, 55)
/ select = list.selected_text.nextvalue
</text>
<list selected_textA>
/ items = (1-5)
/ selectionrate = always
</list>
<list selected_textB>
/ items = (6-10)
/ selectionrate = always
</list>

<trial trial>
/ stimulusframes = [1 = pic, text]
/ timeout = 1000
</trial>
<block block>
/ onblockbegin = [
var i = 0;
while (i < 3) {list.selected_pic.appendItem(list.selected_picA.nextValue); i += 1; };
i = 0;
while (i < 3) {list.selected_pic.appendItem(list.selected_picB.nextValue); i += 1; };
var j = 0;
while (j < 3) {list.selected_text.appendItem(list.selected_textA.nextValue); j += 1; };
j = 0;
while (j < 3) {list.selected_text.appendItem(list.selected_textB.nextValue); j += 1; };]
/ trials = [1-12 = trial]
</block>


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: 108K
nfbecker - 7/17/2025
Hi!
I'm struggeling to program a presentation of pictures and texts with randomized selection based on specific criteria: I want to randomly select three out of five pictures from each category A and B. For each selected picture, I also want to select a text corresponding to the same category A or B. Within a block, the trials could look like this: picA1-textA2, picA2-textA1, picB1-textB5, ... (each picture-text combination is presented twice)

I've tried different settings using the variables within /onBlockBegin. But currently, I either manage to present the corresponding pairs by item numbers (picA1-textA1) or present compleatly random combinations and mixing A and B incorrectly (picA1-textB2).
What I'm looking for is something like "if list.selected_picA then list.selected_textA", but I cannot figure out how to program this dependency correctly. 
I would really appreciate your help or hints!

This is the code I'm working with at the moment:
<item pic_all>
/ 1 = "picA1"
/ 2 = "picA2"
/ 3 = "picA3"
/ 4 = "picA4"
/ 5 = "picA5"
/ 6 = "picB1"
/ 7 = "picB2"
/ 8 = "picB3"
/ 9 = "picB4"
/ 10 = "picB5"
</item>
<list selected_pic>
</list>
<text pic>
/ items = pic_all
/ position = (50, 40)
/ select = list.selected_pic.nextvalue
</text>
<list selected_picA>
/ items = (1-5)
/ selectionrate = always
</list>
<list selected_picB>
/ items = (6-10)
/ selectionrate = always
</list>

<item text_all>
/ 1 = "textA1"
/ 2 = "textA2"
/ 3 = "textA3"
/ 4 = "textA4"
/ 5 = "textA5"
/ 6 = "textB1"
/ 7 = "textB2"
/ 8 = "textB3"
/ 9 = "textB4"
/ 10 = "textB5"
</item>
<list selected_text>
</list>
<text text>
/ items = text_all
/ position = (50, 55)
/ select = list.selected_text.nextvalue
</text>
<list selected_textA>
/ items = (1-5)
/ selectionrate = always
</list>
<list selected_textB>
/ items = (6-10)
/ selectionrate = always
</list>

<trial trial>
/ stimulusframes = [1 = pic, text]
/ timeout = 1000
</trial>
<block block>
/ onblockbegin = [
var i = 0;
while (i < 3) {list.selected_pic.appendItem(list.selected_picA.nextValue); i += 1; };
i = 0;
while (i < 3) {list.selected_pic.appendItem(list.selected_picB.nextValue); i += 1; };
var j = 0;
while (j < 3) {list.selected_text.appendItem(list.selected_textA.nextValue); j += 1; };
j = 0;
while (j < 3) {list.selected_text.appendItem(list.selected_textB.nextValue); j += 1; };]
/ trials = [1-12 = trial]
</block>


You just need to pair the pic and text list, it's not complicated.

<item pic_all>
/ 1 = "picA1"
/ 2 = "picA2"
/ 3 = "picA3"
/ 4 = "picA4"
/ 5 = "picA5"
/ 6 = "picB1"
/ 7 = "picB2"
/ 8 = "picB3"
/ 9 = "picB4"
/ 10 = "picB5"
</item>
<list selected_pic>
</list>
<text pic>
/ items = pic_all
/ position = (50, 40)
/ select = list.selected_pic.nextvalue
</text>
<list selected_picA>
/ items = (1-5)
/ selectionrate = always
</list>
<list selected_picB>
/ items = (6-10)
/ selectionrate = always
</list>

<item text_all>
/ 1 = "textA1"
/ 2 = "textA2"
/ 3 = "textA3"
/ 4 = "textA4"
/ 5 = "textA5"
/ 6 = "textB1"
/ 7 = "textB2"
/ 8 = "textB3"
/ 9 = "textB4"
/ 10 = "textB5"
</item>
<list selected_text>
/ selectionmode = list.selected_pic.currentindex // pair to pic list
</list>
<text text>
/ items = text_all
/ position = (50, 55)
/ select = list.selected_text.nextvalue
</text>
<list selected_textA>
/ items = (1-5)
/ selectionrate = always
</list>
<list selected_textB>
/ items = (6-10)
/ selectionrate = always
</list>

<trial trial>
/ stimulusframes = [1 = pic, text]
/ timeout = 1000
</trial>

<block block>
/ onblockbegin = [
    var i = 0;
    while (i < 3) {
        list.selected_pic.appendItem(list.selected_picA.nextValue); // pick random pic from category A
        list.selected_text.appendItem(list.selected_textA.nextValue); // pick random text from category A
        i += 1;
    };
    i = 0;
    while (i < 3) {
        list.selected_pic.appendItem(list.selected_picB.nextValue); // pick random pic from category B
        list.selected_text.appendItem(list.selected_textB.nextValue); // pick random text from category B
        i += 1;
    };
]
/ trials = [1-12 = trial]
</block>

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search