Millisecond Forums

Random presentation of coloured letters

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

By lukasg - 1/24/2022

Hi All,

I am new to Inquisit and in the process of programming an illusory conjunction task. The paradigm involves the random presentation of three coloured letters flanked by two digits (see image: ). The letters are sampled from a target-population (e.g., X or N) and a distractor population (e.g., HSTO). On a given trial, the letters should be distinct in colour and letter. I am struggling to implement this characteristic in Inquisit and would greatly appreciate your help. 

Since Inquisit seems unable to present separate text-items in combination or a text-element with different colours, I have switched to images and defined them as follows:

<item targets>
/1 = "Stimuli\nblue.png"
/2 = "Stimuli\ngreen.png"
...
</item>

<item distractors>
/1 = "Stimuli\oblue.png"
/2 = "Stimuli\ogreen.png"
...
</item>

<list xpos>
/items = (35%,50%,65%)
/ selectionrate = always
/ resetinterval = 0
</list>

<list target>
/ items = (1,2,3,4,5,6)
/ replace = false
/ selectionrate = trial
/ resetinterval = 0
</list>


Using this code, the pictures are sampled via values determined at the start of each trial (with ontrialstart), which looks like the following:

<picture target>
/ items = letters
/ select = list.target.nextvalue
/ erase = false
/ position = (list.xpos.nextvalue, 50%)
</picture>

<picture distr1>
/ items = distractors
/ select = list.distractor1.nextvalue
/ erase = false
/ position = (list.xpos.nextvalue, 50%)
</picture>

<picture distr2>
/ items = distractors
/ select = list.distractor2.nextvalue
/ erase = false
/ position = (list.xpos.nextvalue, 50%)
</picture>


The following if-functions are thought to limit the possible distractor space depending on the characteristics of the already selected stimuli. In theory that is, as the if-functions appear not to work as intended. Trials frequently feature stimuli with the same letter or colour. I hope the above code-chunks are sufficient, if not, please see the attached file with the entire script. Thanks in advance for your help!

All the best,
Lukas

By lukasg - 1/24/2022

lukasg - 1/24/2022
Hi All,

I am new to Inquisit and in the process of programming an illusory conjunction task. The paradigm involves the random presentation of three coloured letters flanked by two digits (see image: ). The letters are sampled from a target-population (e.g., X or N) and a distractor population (e.g., HSTO). On a given trial, the letters should be distinct in colour and letter. I am struggling to implement this characteristic in Inquisit and would greatly appreciate your help. 

Since Inquisit seems unable to present separate text-items in combination or a text-element with different colours, I have switched to images and defined them as follows:

<item targets>
/1 = "Stimuli\nblue.png"
/2 = "Stimuli\ngreen.png"
...
</item>

<item distractors>
/1 = "Stimuli\oblue.png"
/2 = "Stimuli\ogreen.png"
...
</item>

<list xpos>
/items = (35%,50%,65%)
/ selectionrate = always
/ resetinterval = 0
</list>

<list target>
/ items = (1,2,3,4,5,6)
/ replace = false
/ selectionrate = trial
/ resetinterval = 0
</list>


Using this code, the pictures are sampled via values determined at the start of each trial (with ontrialstart), which looks like the following:

<picture target>
/ items = letters
/ select = list.target.nextvalue
/ erase = false
/ position = (list.xpos.nextvalue, 50%)
</picture>

<picture distr1>
/ items = distractors
/ select = list.distractor1.nextvalue
/ erase = false
/ position = (list.xpos.nextvalue, 50%)
</picture>

<picture distr2>
/ items = distractors
/ select = list.distractor2.nextvalue
/ erase = false
/ position = (list.xpos.nextvalue, 50%)
</picture>


The following if-functions are thought to limit the possible distractor space depending on the characteristics of the already selected stimuli. In theory that is, as the if-functions appear not to work as intended. Trials frequently feature stimuli with the same letter or colour. I hope the above code-chunks are sufficient, if not, please see the attached file with the entire script. Thanks in advance for your help!

All the best,
Lukas


This is trial-code, intended to update the values to sample the picture stimuli:

<trial trial200>
/ ontrialbegin = [
    values.selectTarget = list.target.nextvalue;
    values.currentTarget = values.selectTarget;
    
    if(values.selectTarget.currentvalue == 1 || values.selectTarget.currentvalue == 7){
        values.targetColor = "blue"
    } elese if (values.selectTarget.currentvalue == 3 || values.selectTarget.currentvalue == 9){
        values.targetColor = "green"
    } else if (values.selectTarget.currentvalue == 6 || values.selectTarget.currentvalue == 12){
        values.targetColor = "red"
    }
    
    list.xpos.reset();
    picture.target.hposition = list.xpos.nextvalue;
    picture.distr1.hposition = list.xpos.nextvalue;
    picture.distr2.hposition = list.xpos.nextvalue;
    
    //TARGET - SELECTION OF 1st DISTR
    if(picture.target.currentvalue == list.targetBlue){
        values.selectDistr1 == list.distr1bl.nextvalue
    } else if (picture.target.currentvalue == list.targetGreen){
        values.selectDistr1 == list.distr1gr.nextvalue
    } else if (picture.target.currentvalue == list.targetRed){
        values.selectDistr1 == list.distr1re.nextvalue
    }
    
    //BLUE TARGET - SELECTION OF 2nd DISTR
    if(picture.target.currentvalue == list.targetBlue && values.selectDistr1 == list.distr1Green){
        values.selectDistr2 == list.distr2blgr.nextvalue
    } else if (picture.target.currentvalue == list.targetBlue && values.selectDistr1 == list.distr1Red){
        values.selectDistr2 == list.distr2blre.nextvalue
    }
    
    //GREEN TARGET - SELECTION OF 2nd DISTR
    if(picture.target.currentvalue == list.targetGreen && values.selectDistr1 == list.distr1Blue){
        values.selectDistr2 == list.distr2blgr.nextvalue
    } else if (picture.target.currentvalue == list.targetGreen && values.selectDistr1 == list.distr1Red){
        values.selectDistr2 == list.distr2grre.nextvalue
    }
    
    //RED TARGET - SELECTION OF 2nd DISTR
    if(picture.target.currentvalue == list.targetRed && values.selectDistr1 == list.distr1Blue){
        values.selectDistr2 == list.distr2blre.nextvalue
    } else if (picture.target.currentvalue == list.targetRed && values.selectDistr1 == list.distr1Green){
        values.selectDistr2 == list.distr2grre.nextvalue
    }
    
]

/ response = timeout(parameters.responseWindow)
/ validresponse = (parameters.blueKey, parameters.greenKey, parameters.redKey)
/ iscorrectresponse = [
    return (
    (values.currentTarget == 1 && trial.trial200.responsetext == parameters.blueKey) ||
    (values.currentTarget == 7 && trial.trial200.responsetext == parameters.blueKey) ||
    (values.currentTarget == 3 && trial.trial200.responsetext == parameters.greenKey) ||
    (values.currentTarget == 9 && trial.trial200.responsetext == parameters.greenKey) ||
    (values.currentTarget == 6 && trial.trial200.responsetext == parameters.redKey) ||
    (values.currentTarget == 12 && trial.trial200.responsetext == parameters.redKey))
    ]
    
/ stimulustimes = [0 = text.fixation;250 = picture.target, picture.distr1, picture.distr2; 1000 = shape.eraser; 1001 = picture.noisemask; 1501 = shape.eraser]

/ ontrialend = [
    
    //reset(list.distr1bl); reset(list.distr1gr); reset(list.distr1re);
    //reset(list.distr2blgr); reset(list.distr2blre); reset(list.distr2grre);
    //reset(list.xpos); reset(values.)
    
    values.selectDistr1 = 0;
    values.selectDistr2 = 0

]

</trial>

By Dave - 1/24/2022

lukasg - 1/24/2022
lukasg - 1/24/2022
Hi All,

I am new to Inquisit and in the process of programming an illusory conjunction task. The paradigm involves the random presentation of three coloured letters flanked by two digits (see image: ). The letters are sampled from a target-population (e.g., X or N) and a distractor population (e.g., HSTO). On a given trial, the letters should be distinct in colour and letter. I am struggling to implement this characteristic in Inquisit and would greatly appreciate your help. 

Since Inquisit seems unable to present separate text-items in combination or a text-element with different colours, I have switched to images and defined them as follows:

<item targets>
/1 = "Stimuli\nblue.png"
/2 = "Stimuli\ngreen.png"
...
</item>

<item distractors>
/1 = "Stimuli\oblue.png"
/2 = "Stimuli\ogreen.png"
...
</item>

<list xpos>
/items = (35%,50%,65%)
/ selectionrate = always
/ resetinterval = 0
</list>

<list target>
/ items = (1,2,3,4,5,6)
/ replace = false
/ selectionrate = trial
/ resetinterval = 0
</list>


Using this code, the pictures are sampled via values determined at the start of each trial (with ontrialstart), which looks like the following:

<picture target>
/ items = letters
/ select = list.target.nextvalue
/ erase = false
/ position = (list.xpos.nextvalue, 50%)
</picture>

<picture distr1>
/ items = distractors
/ select = list.distractor1.nextvalue
/ erase = false
/ position = (list.xpos.nextvalue, 50%)
</picture>

<picture distr2>
/ items = distractors
/ select = list.distractor2.nextvalue
/ erase = false
/ position = (list.xpos.nextvalue, 50%)
</picture>


The following if-functions are thought to limit the possible distractor space depending on the characteristics of the already selected stimuli. In theory that is, as the if-functions appear not to work as intended. Trials frequently feature stimuli with the same letter or colour. I hope the above code-chunks are sufficient, if not, please see the attached file with the entire script. Thanks in advance for your help!

All the best,
Lukas


This is trial-code, intended to update the values to sample the picture stimuli:

<trial trial200>
/ ontrialbegin = [
    values.selectTarget = list.target.nextvalue;
    values.currentTarget = values.selectTarget;
    
    if(values.selectTarget.currentvalue == 1 || values.selectTarget.currentvalue == 7){
        values.targetColor = "blue"
    } elese if (values.selectTarget.currentvalue == 3 || values.selectTarget.currentvalue == 9){
        values.targetColor = "green"
    } else if (values.selectTarget.currentvalue == 6 || values.selectTarget.currentvalue == 12){
        values.targetColor = "red"
    }
    
    list.xpos.reset();
    picture.target.hposition = list.xpos.nextvalue;
    picture.distr1.hposition = list.xpos.nextvalue;
    picture.distr2.hposition = list.xpos.nextvalue;
    
    //TARGET - SELECTION OF 1st DISTR
    if(picture.target.currentvalue == list.targetBlue){
        values.selectDistr1 == list.distr1bl.nextvalue
    } else if (picture.target.currentvalue == list.targetGreen){
        values.selectDistr1 == list.distr1gr.nextvalue
    } else if (picture.target.currentvalue == list.targetRed){
        values.selectDistr1 == list.distr1re.nextvalue
    }
    
    //BLUE TARGET - SELECTION OF 2nd DISTR
    if(picture.target.currentvalue == list.targetBlue && values.selectDistr1 == list.distr1Green){
        values.selectDistr2 == list.distr2blgr.nextvalue
    } else if (picture.target.currentvalue == list.targetBlue && values.selectDistr1 == list.distr1Red){
        values.selectDistr2 == list.distr2blre.nextvalue
    }
    
    //GREEN TARGET - SELECTION OF 2nd DISTR
    if(picture.target.currentvalue == list.targetGreen && values.selectDistr1 == list.distr1Blue){
        values.selectDistr2 == list.distr2blgr.nextvalue
    } else if (picture.target.currentvalue == list.targetGreen && values.selectDistr1 == list.distr1Red){
        values.selectDistr2 == list.distr2grre.nextvalue
    }
    
    //RED TARGET - SELECTION OF 2nd DISTR
    if(picture.target.currentvalue == list.targetRed && values.selectDistr1 == list.distr1Blue){
        values.selectDistr2 == list.distr2blre.nextvalue
    } else if (picture.target.currentvalue == list.targetRed && values.selectDistr1 == list.distr1Green){
        values.selectDistr2 == list.distr2grre.nextvalue
    }
    
]

/ response = timeout(parameters.responseWindow)
/ validresponse = (parameters.blueKey, parameters.greenKey, parameters.redKey)
/ iscorrectresponse = [
    return (
    (values.currentTarget == 1 && trial.trial200.responsetext == parameters.blueKey) ||
    (values.currentTarget == 7 && trial.trial200.responsetext == parameters.blueKey) ||
    (values.currentTarget == 3 && trial.trial200.responsetext == parameters.greenKey) ||
    (values.currentTarget == 9 && trial.trial200.responsetext == parameters.greenKey) ||
    (values.currentTarget == 6 && trial.trial200.responsetext == parameters.redKey) ||
    (values.currentTarget == 12 && trial.trial200.responsetext == parameters.redKey))
    ]
    
/ stimulustimes = [0 = text.fixation;250 = picture.target, picture.distr1, picture.distr2; 1000 = shape.eraser; 1001 = picture.noisemask; 1501 = shape.eraser]

/ ontrialend = [
    
    //reset(list.distr1bl); reset(list.distr1gr); reset(list.distr1re);
    //reset(list.distr2blgr); reset(list.distr2blre); reset(list.distr2grre);
    //reset(list.xpos); reset(values.)
    
    values.selectDistr1 = 0;
    values.selectDistr2 = 0

]

</trial>


> Since Inquisit seems unable to present separate text-items in combination or a text-element with different colours

What makes you think that?
By lukasg - 1/24/2022

Dave - 1/24/2022

> Since Inquisit seems unable to present separate text-items in combination or a text-element with different colours

What makes you think that?

This forum entry from a few years back. However, I am more than happy to explore alternative avenues in setting up an illusory conjunction task.
By lukasg - 1/24/2022

lukasg - 1/24/2022
Dave - 1/24/2022

> Since Inquisit seems unable to present separate text-items in combination or a text-element with different colours

What makes you think that?

This forum entry from a few years back. However, I am more than happy to explore alternative avenues in setting up an illusory conjunction task.

https://www.millisecond.com/forums/Topic18657.aspx
By Dave - 1/24/2022

lukasg - 1/24/2022
lukasg - 1/24/2022
Dave - 1/24/2022

> Since Inquisit seems unable to present separate text-items in combination or a text-element with different colours

What makes you think that?

This forum entry from a few years back. However, I am more than happy to explore alternative avenues in setting up an illusory conjunction task.

https://www.millisecond.com/forums/Topic18657.aspx

This pertained to a case where you have a single <text> element and want to display single letters or words of a given *item* in different colors than the rest of the item's words or letters. That wasn't possible back then (though it is now). You, however, have separate <text> elements for target and distractors anyway, which can easily be displayed in different colors, that was possible even back then and of course still is.
By lukasg - 1/24/2022

Dave - 1/24/2022

This pertained to a case where you have a single <text> element and want to display single letters or words of a given *item* in different colors than the rest of the item's words or letters. That wasn't possible back then (though it is now). You, however, have separate <text> elements for target and distractors anyway, which can easily be displayed in different colors, that was possible even back then and of course still is.

Thanks for your response, Dave. Would you be able to demonstrate how this could be achieved? My previous attempts have been without success :/
By Dave - 1/24/2022

lukasg - 1/24/2022
Dave - 1/24/2022

This pertained to a case where you have a single <text> element and want to display single letters or words of a given *item* in different colors than the rest of the item's words or letters. That wasn't possible back then (though it is now). You, however, have separate <text> elements for target and distractors anyway, which can easily be displayed in different colors, that was possible even back then and of course still is.

Thanks for your response, Dave. Would you be able to demonstrate how this could be achieved? My previous attempts have been without success :/

Here's a basic example:

<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
</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;
    // 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 = (57)
</trial>

<block myblock>
/ trials = [1-30 = example]
</block>

By lukasg - 1/24/2022

Dave - 1/24/2022

Here's a basic example:

<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
</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;
    // 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 = (57)
</trial>

<block myblock>
/ trials = [1-30 = example]
</block>


Thanks! Sadly, this would have taken me hours. One additional question, if I want the correct response to be conditional on the colour of the presented target, how would I equate the different colours to the different response keys?
By Dave - 1/24/2022

lukasg - 1/24/2022
Dave - 1/24/2022

Here's a basic example:

<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
</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;
    // 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 = (57)
</trial>

<block myblock>
/ trials = [1-30 = example]
</block>


Thanks! Sadly, this would have taken me hours. One additional question, if I want the correct response to be conditional on the colour of the presented target, how would I equate the different colours to the different response keys?

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>
By lukasg - 1/24/2022

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 
By 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>
By Dave - 1/24/2022

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>