Random presentation of coloured letters


Author
Message
lukasg
lukasg
Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)
Group: Forum Members
Posts: 35, Visits: 103
Dave - 1/24/2022

You can easily integrate that into the existing logic.

<defaults>
/ fontstyle = ("Arial", 5%, true)
</defaults>

<values>
/ t = 0
/ t_x = 0
/ t_color = black
/ d1 = 0
/ d1_x = 0
/ d1_color = black
/ d2 = 0
/ d2_x = 0
/ d2_color = black

/ cresp = " "
</values>

<text t>
/ items = targets
/ select = values.t
/ hposition = values.t_x
/ txcolor = values.t_color
/ erase = false
</text>

<item targets>
/ 1 = "N"
/ 2 = "X"
</item>

<text d1>
/ items = distractors
/ select = values.d1
/ hposition = values.d1_x
/ txcolor = values.d1_color
/ erase = false
</text>

<text d2>
/ items = distractors
/ select = values.d2
/ hposition = values.d2_x
/ txcolor = values.d2_color
/ erase = false
</text>

<item distractors>
/ 1 = "H"
/ 1 = "S"
/ 1 = "T"
/ 1 = "O"
</item>

// 30 trials in this example,
// 15 x target 1 ("N")
// 15 x target 2 ("X")
<list t_items>
/ items = (1,2)
/ poolsize = 10
</list>

// two distractors sampled per trial at random
<list d_items>
/ items = (1,2,3,4)
/ selectionrate = always
</list>

// 30 trials in this example,
// target 10 x in left position,
// target 10 x in middle position,
// target 10 x in right position
<list t_x>
/ items = (40%, 50%, 60%)
/ poolsize = 30
</list>

// random position for two distractors, not equal to target position
<list d_x>
/ items = (40%, 50%, 60%)
/ selectionrate = always
/ not = (values.t_x)
</list>

// 30 trials in this example,
// target 10 x in red,
// target 10 x in green,
// target 10 x in blue,
<list t_colors>
/ items = (red, green, blue)
/ poolsize = 30
</list>

// random colors for two distractors, not equal to target color
<list d_colors>
/ items = (red, green, blue)
/ selectionrate = always
/ not = (values.t_color)
</list>

<trial example>
/ ontrialbegin = [
    // select target item
    values.t = list.t_items.nextvalue;
    // select distractor items
    values.d1 = list.d_items.nextvalue;
    values.d2 = list.d_items.nextvalue;
    // select target position
    values.t_x = list.t_x.nextvalue;
    // select distractor positions
    values.d1_x = list.d_x.nextvalue;
    values.d2_x = list.d_x.nextvalue;
    // select target color
    values.t_color = list.t_colors.nextvalue;
    // and corresponding response key
    if (values.t_color == red) {
        values.cresp = "R";
    } else if (values.t_color == green) {
        values.cresp = "G";
    } else if (values.t_color == blue) {
        values.cresp = "B";
    };
    // select distractor colors
    values.d1_color = list.d_colors.nextvalue;
    values.d2_color = list.d_colors.nextvalue;
]

/ ontrialend = [
    // reset relevant lists for next trial
    list.d_items.reset();
    list.d_x.reset();
    list.d_colors.reset();
]

/ stimulusframes = [1=clearscreen, t, d1, d2]
/ validresponse = ("R", "G", "B")
/ correctresponse = (values.cresp)
</trial>

<block myblock>
/ trials = [1-30 = example]
/ correctmessage = true(correctmsg, 500)
/ errormessage = true(errormsg, 500)
</block>

<text correctmsg>
/ items = ("CORRECT")
/ color = green
/ position = (50%, 80%)
/ erase = false
</text>

<text errormsg>
/ items = ("WRONG")
/ color = red
/ position = (50%, 80%)
/ erase = false
</text>

Thanks a lot 
lukasg
lukasg
Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)Partner Member (633 reputation)
Group: Forum Members
Posts: 35, Visits: 103
When trying to replace the colour names with RGB codes, I keep getting the error code 'Missing ['. What is the issue with the following code:

<item itemCols>
/ 1 = "31,119,180"
/ 2 = "255,127,14"
/ 3 = "44,160,44"
/ 4 = "214,39,40"
/ 5 = "148,103,189"
/ 6 = "140,86,75"
/ 7 = "227,119,194"
/ 8 = "23,190,207"
</item>

<list d_colors>
/ items = item.itemCols
/ selectionrate = always
/ not = (values.t_color)
</list>

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: 105K
lukasg - 1/24/2022
When trying to replace the colour names with RGB codes, I keep getting the error code 'Missing ['. What is the issue with the following code:

<item itemCols>
/ 1 = "31,119,180"
/ 2 = "255,127,14"
/ 3 = "44,160,44"
/ 4 = "214,39,40"
/ 5 = "148,103,189"
/ 6 = "140,86,75"
/ 7 = "227,119,194"
/ 8 = "23,190,207"
</item>

<list d_colors>
/ items = item.itemCols
/ selectionrate = always
/ not = (values.t_color)
</list>

That's not valid syntax. /items in list elements cannot refer to <item> elements and you cannot define the colors that way either. If you want to use RGB codes, you would need three linked lists -- one for the red channel, one for the green channel, one for the blue channel -- though I would simply use hex values if I were you.

<list d_colors>
/ items = (#1f77b4, #ff7f0e, #2ca02c, #d62728, #9467bd, #8c564b, #e377c2, #17becf)
/ selectionrate = always
/ not = (values.t_color)
</list>


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search