Evaluative conditioning task based on a subset of pre-rated CS by the participant


Evaluative conditioning task based on a subset of pre-rated CS by the...
Author
Message
Oulmann
Oulmann
Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)
Group: Forum Members
Posts: 19, Visits: 64
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the participant to first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck
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
Oulmann - Tuesday, February 14, 2017
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the participant to first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck

> but I can't find a function that allows to compute the mean

You have several options. Probably the he easiest one: Add each (numerical!) rating to a <list> /ontrialend. You can then query the list's mean and standarddeviation properties. Here's a simple example using a <likert> trial:

<block myblock>
/ postinstructions = (end)
/ trials = [1-10 = mylikert]
</block>

<likert mylikert>
/ ontrialend = [
    list.ratings.appenditem(likert.mylikert.response)
]
/ stimulusframes = [1=mytext]
/ numpoints = 7
</likert>

<list ratings>
</list>

<text mytext>
/ items = myitems
/ position = (50%, 40%)
</text>

<item myitems>
/ 1 = "A"
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
/ 5 = "E"
/ 6 = "F"
/ 7 = "G"
/ 8 = "H"
/ 9 = "I"
/ 10 = "J"
</item>

<page end>
^Number of ratings: <%list.ratings.itemcount%>
^Mean rating: <%list.ratings.mean%>
^Standard deviation: <%list.ratings.standarddeviation%>
</page>

I frankly don't understand what you aim to do with respect to the selection of US stimuli / items based on your description.


Oulmann
Oulmann
Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)
Group: Forum Members
Posts: 19, Visits: 64
Dave - Tuesday, February 14, 2017
Oulmann - Tuesday, February 14, 2017
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the parotherwisëto first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck

> but I can't find a function that allows to compute the mean

You have several options. Probably the he easiest one: Add each (numerical!) rating to a <list> /ontrialend. You can then query the list's mean and standarddeviation properties. Here's a simple example using a <likert> trial:

<block myblock>
/ postinstructions = (end)
/ trials = [1-10 = mylikert]
</block>

<likert mylikert>
/ ontrialend = [
    list.ratings.appenditem(likert.mylikert.response)
]
/ stimulusframes = [1=mytext]
/ numpoints = 7
</likert>

<list ratings>
</list>

<text mytext>
/ items = myitems
/ position = (50%, 40%)
</text>
.
<item myitems>
/ 1 = "A"4
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
/ 5 = "E"
/ 6 = "F"
/ 7 = "G"
/ 8 = "H"
/ 9 = "I"
/ 10 = "J"
</item>

<page end>
^Number of ratings: <%list.ratings.itemcount%>
^Mean rating: <%list.ratings.mean%>
^Standard deviation: <%list.ratings.standarddeviation%>
</page>

I frankly don't understand what you aim to do with respect to the selection of US stimuli / items based on your description.


Thanks for your fast answer! The "computing" The mean part seems clearer now.
The CS/US selection is done this way to be sure that no CS is associated with both a negative US (usA) and a positive US (usB). Hence I created two CS lists (that are equivalent in terms of Valence neutrality), each being associated with either positive or negative USs (there s then two experiments in the End of the script, each of both combination being a between subject condition).
It s a bit suboptimal as there is no full randomization of CS/US pairs but I can t find how to do it otherwise. 
I guess the best way is to add CS selection with the "ontrialbegin" function based on the created list, but in each trial, the CS and US will be randomly selected from the "item" element. There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all (except with the noreplace function used at the trial level?).
Thanks (again) in advance.
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
Oulmann - Tuesday, February 14, 2017
Dave - Tuesday, February 14, 2017
Oulmann - Tuesday, February 14, 2017
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the parotherwisëto first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck

> but I can't find a function that allows to compute the mean

You have several options. Probably the he easiest one: Add each (numerical!) rating to a <list> /ontrialend. You can then query the list's mean and standarddeviation properties. Here's a simple example using a <likert> trial:

<block myblock>
/ postinstructions = (end)
/ trials = [1-10 = mylikert]
</block>

<likert mylikert>
/ ontrialend = [
    list.ratings.appenditem(likert.mylikert.response)
]
/ stimulusframes = [1=mytext]
/ numpoints = 7
</likert>

<list ratings>
</list>

<text mytext>
/ items = myitems
/ position = (50%, 40%)
</text>
.
<item myitems>
/ 1 = "A"4
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
/ 5 = "E"
/ 6 = "F"
/ 7 = "G"
/ 8 = "H"
/ 9 = "I"
/ 10 = "J"
</item>

<page end>
^Number of ratings: <%list.ratings.itemcount%>
^Mean rating: <%list.ratings.mean%>
^Standard deviation: <%list.ratings.standarddeviation%>
</page>

I frankly don't understand what you aim to do with respect to the selection of US stimuli / items based on your description.


Thanks for your fast answer! The "computing" The mean part seems clearer now.
The CS/US selection is done this way to be sure that no CS is associated with both a negative US (usA) and a positive US (usB). Hence I created two CS lists (that are equivalent in terms of Valence neutrality), each being associated with either positive or negative USs (there s then two experiments in the End of the script, each of both combination being a between subject condition).
It s a bit suboptimal as there is no full randomization of CS/US pairs but I can t find how to do it otherwise. 
I guess the best way is to add CS selection with the "ontrialbegin" function based on the created list, but in each trial, the CS and US will be randomly selected from the "item" element. There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all (except with the noreplace function used at the trial level?).
Thanks (again) in advance.

Sorry, I still don't understand it. Can you give me a concrete, simple simplified example, preferably with actual runable code?

> There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all.

You can pair your CSs and USs at will. Pairing stimuli is covered in https://www.millisecond.com/support/docs/v5/html/howto/howtopairs.htm and you can also do that dynamically at run-time, e.g. with <lists> you fill based on some criteria. See e.g. https://www.millisecond.com/forums/FindPost16277.aspx

Oulmann
Oulmann
Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)
Group: Forum Members
Posts: 19, Visits: 64
Dave - Wednesday, February 15, 2017
Oulmann - Tuesday, February 14, 2017
Dave - Tuesday, February 14, 2017
Oulmann - Tuesday, February 14, 2017
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the parotherwisëto first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck

> but I can't find a function that allows to compute the mean

You have several options. Probably the he easiest one: Add each (numerical!) rating to a <list> /ontrialend. You can then query the list's mean and standarddeviation properties. Here's a simple example using a <likert> trial:

<block myblock>
/ postinstructions = (end)
/ trials = [1-10 = mylikert]
</block>

<likert mylikert>
/ ontrialend = [
    list.ratings.appenditem(likert.mylikert.response)
]
/ stimulusframes = [1=mytext]
/ numpoints = 7
</likert>

<list ratings>
</list>

<text mytext>
/ items = myitems
/ position = (50%, 40%)
</text>
.
<item myitems>
/ 1 = "A"4
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
/ 5 = "E"
/ 6 = "F"
/ 7 = "G"
/ 8 = "H"
/ 9 = "I"
/ 10 = "J"
</item>

<page end>
^Number of ratings: <%list.ratings.itemcount%>
^Mean rating: <%list.ratings.mean%>
^Standard deviation: <%list.ratings.standarddeviation%>
</page>

I frankly don't understand what you aim to do with respect to the selection of US stimuli / items based on your description.


Thanks for your fast answer! The "computing" The mean part seems clearer now.
The CS/US selection is done this way to be sure that no CS is associated with both a negative US (usA) and a positive US (usB). Hence I created two CS lists (that are equivalent in terms of Valence neutrality), each being associated with either positive or negative USs (there s then two experiments in the End of the script, each of both combination being a between subject condition).
It s a bit suboptimal as there is no full randomization of CS/US pairs but I can t find how to do it otherwise. 
I guess the best way is to add CS selection with the "ontrialbegin" function based on the created list, but in each trial, the CS and US will be randomly selected from the "item" element. There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all (except with the noreplace function used at the trial level?).
Thanks (again) in advance.

Sorry, I still don't understand it. Can you give me a concrete, simple simplified example, preferably with actual runable code?

> There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all.

You can pair your CSs and USs at will. Pairing stimuli is covered in https://www.millisecond.com/support/docs/v5/html/howto/howtopairs.htm and you can also do that dynamically at run-time, e.g. with <lists> you fill based on some criteria. See e.g. https://www.millisecond.com/forums/FindPost16277.aspx

I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7 (very unpleasant to pleasant), then have the script select the 20 most neutral CS (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5. So let's say mean +/- 1SD. I don't really know how to formalize this).

Participants then do an evaluative conditioning task in which US (negative and positive stimuli) are paired with the, supposedly neutral, CSs. I would like that each CS to be paired randomly with only one US (10 negative CS-US pairs and 10 positive CS-US pairs, again randomly), and each of the 20 pairs to be presented 5 times.

Than have an contingency awareness task (i.e. a memory task) were participants are asked to remember the valence of the US with wich each CS was paired. So basically a likert scale for each CS with the same questions

Then postratings of the CSs (same as the preatings)

Here is the code :

*******
CSs and USs)
*******

<item csCPic>
/ 1 = "CFD-BF-028-001-N.jpg"
/ 2 = "CFD-BF-205-141-N.jpg"
/ 3 = "CFD-BF-218-207-N.jpg"
/ 4 = "CFD-BF-219-137-N.jpg"
/ 5 = "CFD-BF-221-223-N.jpg"
/ 6 = "CFD-BF-228-212-N.jpg"
/ 7 = "CFD-BF-240-179-N.jpg"
/ 8 = "CFD-BF-249-091-N.jpg"
....
/120 = "CFD-BF-125-874-N.jpg"
</item>

<item ucAPic>
/ 1 = "1525.bmp"
/ 2 ="2053.bmp"
/ 3 ="2141.bmp"
/ 4 ="2276.bmp"
/ 5 ="2375.1.bmp"
/ 6 ="2710.bmp"
/ 7 ="2750.bmp"
/ 8 ="2900.bmp"
...
/ 50="9920.bmp"
</item>

<item ucBPic>
/ 1 = "1440.bmp"
/ 2 = "1463.bmp"
/ 3 = "1650.bmp"
/ 4 = "1710.bmp"
/ 5 = "1999.bmp"
/ 6 = "2040.bmp"
/ 7 = "2050.bmp"
/ 8 = "2057.bmp"
/ 9 = "2058.bmp"
/ 10 = "2070.bmp"
...
/ 50= "2791.bmp"
</item>

***************
pre-ratings
**************

<block preratings>
/ preinstructions = (instruct)
/ trials = [1-120 = preratings]
</block>

<likert preratings>
/ ontrialend = [
    list.preratings.appenditem(likert.preratings.response)
]
/ stimulusframes = [1=csCPicP]
/ numpoints = 7
</likert>

<list preratings>
</list>

<picture csCPicP>
/ items = csCPic
/ position = (50%, 40%)
</text>

<page instruct>
Rate the pictures
</page>

******
evaluative conditioning
******
<list randomcsCPic>
/ poolsize = 20
</list>

<list randomucBPic>
/ poolsize = 10
</list>

<list randomucAPic>
/ poolsize = 10
</list>

<list repeatcsCPic>
</list>

<list repeatucAPic>
/ selectionmode = list.repeatucAPic.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.repeatucBPic.currentindex
</list>

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucAPic=list.randomucAPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucAPic.appenditem(values.ucAPic);
]
/ stimulustimes = [0=erase; 1=csCPic, ucAPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial CBPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucBPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucBPic=list.randomucBPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucBPic.appenditem(values.ucBPic);
]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>



<trial repeatCA>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucAPic=list.repeatucAPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<trial repeatCB>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucBPic=list.repeatucBPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<values>
/ csCPic = 1
/ ucAPic = 1
/ ucBPic = 1
</values>

<picture csCPic>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucAPic)
/ items = ucAPic
</picture>

<picture ucBPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucBPic)
/ items = ucBPic
</picture>

<trial instructions>
/ stimulustimes = [1=instructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial blockinstructions>
/ stimulustimes = [1=blockinstructions, targetinstructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<block CACB>
/ trials = [1=blockinstructions; 2-3 = noreplace (CAPic,CBPic); 3-12 = noreplace(
repeatCA,repeatCA,repeatCA,repeatCA,repeatCA,
repeatCB,repeatCB,repeatCB,repeatCB,repeatCB,
)]
</block>

<block instructions>
/ trials = [1=instructions]
</block>


***
Contingency Awareness
***

<list instructions>
/ items = (1, 2)
/ resetinterval = 20
/ selectionmode = sequence
</list>

<trial instructions>
/ stimulustimes = [1=instructions, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructions>
/ items = instructions
/ hjustify = left
/ size = (90%, 60%)
/ position = (50%, 85%)
/ valign = bottom
/ select = sequence
</text>

<item instructions>
/ 1 = "Vous l'aurez peut être remarqué, certaines images étaient présentées en même temps que les images positives ou négatives.

Vous allez maintenant revoir certaines de ces images, et nous vous demanderons, pour chacune d'entre elles d'essayer de vous rappeler si les images qui lui étaient associées étaient agréables ou désagréables.

Appuyez sur la touche A lorsque les images étaient agréables et sur la touche D lorsqu'elles étaient désagréables. "
</item>

<text spacebar>
/ items = ("Appuyez sur la barre espace pour commencer.")
/ position = (50%, 95%)
/ valign = bottom
</text>

<item attributeAlabel>
/1 = "Plaisant"
</item>

<item attributeDlabel>
/1 = "Déplaisant"
</item>

<picture cibles>
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<text attributeAlabel>
/ items = attributeAlabel
/ valign = top
/ halign = right
/ position = (80, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<text attributeDlabel>
/ items = attributeDlabel
/ valign = top
/ halign = left
/ position = (15, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<trial cibles>
/ validresponse = ("A", "P")
/ correctresponse = ("U")
/ stimulustimes = [1=cibles]
</trial>

<block CC>
/ bgstim = (attributeAlabel, attributeDlabel)
/ trials = [1 = instructions; 2-24 = noreplace(cibles)]
</block>

*****
postratings
*****
<block postratings>
/ preinstructions = (instruct)
/ trials = [1-20 = postratings]
</block>

<likert postratings>
/ ontrialend = [
    list.postratings.appenditem(likert.postratings.response)
]
/ stimulusframes = [1=csCPicPost]
/ numpoints = 7
</likert>

<picture csCPicPost>
/ items = csCPic
/ select = noreplacenot(list.preratings)
/ position = (50%, 40%)
</text>

******
experiment
*****

<expt EC>
/ blocks = [1=instructions; 2=prerating; 3-12=CACB; 13=CC; 14=postratings]
/onexptend = [values.completed = 1]
</expt>

Note that I have voluntarily omitted some parts of the scripts, such as expressions on stimulus position etc.

The idea is to :
1/ select stimuli by mean ratings and store them in an empty "list" element (as you suggested, if I understood)
2/ "tell" the script to go search for CSs in the "item" element at the beggining of the script based on the list "preratings"
3/ select randomly one negative US and one CS, as well as one positive US and another CS (hence the noreplacenorepeat) and display them in one trial each. Record which CS-US have been used, and repeat 5 times each (block CACB).
4/ Repeat step 3/ 10 times, with new CS and US (because of noreplacenorepeat). 
5/ CC and postratings on CS selected in preratings.

I hope I have been clearer.


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
Oulmann - Wednesday, February 15, 2017
Dave - Wednesday, February 15, 2017
Oulmann - Tuesday, February 14, 2017
Dave - Tuesday, February 14, 2017
Oulmann - Tuesday, February 14, 2017
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the parotherwisëto first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck

> but I can't find a function that allows to compute the mean

You have several options. Probably the he easiest one: Add each (numerical!) rating to a <list> /ontrialend. You can then query the list's mean and standarddeviation properties. Here's a simple example using a <likert> trial:

<block myblock>
/ postinstructions = (end)
/ trials = [1-10 = mylikert]
</block>

<likert mylikert>
/ ontrialend = [
    list.ratings.appenditem(likert.mylikert.response)
]
/ stimulusframes = [1=mytext]
/ numpoints = 7
</likert>

<list ratings>
</list>

<text mytext>
/ items = myitems
/ position = (50%, 40%)
</text>
.
<item myitems>
/ 1 = "A"4
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
/ 5 = "E"
/ 6 = "F"
/ 7 = "G"
/ 8 = "H"
/ 9 = "I"
/ 10 = "J"
</item>

<page end>
^Number of ratings: <%list.ratings.itemcount%>
^Mean rating: <%list.ratings.mean%>
^Standard deviation: <%list.ratings.standarddeviation%>
</page>

I frankly don't understand what you aim to do with respect to the selection of US stimuli / items based on your description.


Thanks for your fast answer! The "computing" The mean part seems clearer now.
The CS/US selection is done this way to be sure that no CS is associated with both a negative US (usA) and a positive US (usB). Hence I created two CS lists (that are equivalent in terms of Valence neutrality), each being associated with either positive or negative USs (there s then two experiments in the End of the script, each of both combination being a between subject condition).
It s a bit suboptimal as there is no full randomization of CS/US pairs but I can t find how to do it otherwise. 
I guess the best way is to add CS selection with the "ontrialbegin" function based on the created list, but in each trial, the CS and US will be randomly selected from the "item" element. There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all (except with the noreplace function used at the trial level?).
Thanks (again) in advance.

Sorry, I still don't understand it. Can you give me a concrete, simple simplified example, preferably with actual runable code?

> There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all.

You can pair your CSs and USs at will. Pairing stimuli is covered in https://www.millisecond.com/support/docs/v5/html/howto/howtopairs.htm and you can also do that dynamically at run-time, e.g. with <lists> you fill based on some criteria. See e.g. https://www.millisecond.com/forums/FindPost16277.aspx

I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7 (very unpleasant to pleasant), then have the script select the 20 most neutral CS (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5. So let's say mean +/- 1SD. I don't really know how to formalize this).

Participants then do an evaluative conditioning task in which US (negative and positive stimuli) are paired with the, supposedly neutral, CSs. I would like that each CS to be paired randomly with only one US (10 negative CS-US pairs and 10 positive CS-US pairs, again randomly), and each of the 20 pairs to be presented 5 times.

Than have an contingency awareness task (i.e. a memory task) were participants are asked to remember the valence of the US with wich each CS was paired. So basically a likert scale for each CS with the same questions

Then postratings of the CSs (same as the preatings)

Here is the code :

*******
CSs and USs)
*******

<item csCPic>
/ 1 = "CFD-BF-028-001-N.jpg"
/ 2 = "CFD-BF-205-141-N.jpg"
/ 3 = "CFD-BF-218-207-N.jpg"
/ 4 = "CFD-BF-219-137-N.jpg"
/ 5 = "CFD-BF-221-223-N.jpg"
/ 6 = "CFD-BF-228-212-N.jpg"
/ 7 = "CFD-BF-240-179-N.jpg"
/ 8 = "CFD-BF-249-091-N.jpg"
....
/120 = "CFD-BF-125-874-N.jpg"
</item>

<item ucAPic>
/ 1 = "1525.bmp"
/ 2 ="2053.bmp"
/ 3 ="2141.bmp"
/ 4 ="2276.bmp"
/ 5 ="2375.1.bmp"
/ 6 ="2710.bmp"
/ 7 ="2750.bmp"
/ 8 ="2900.bmp"
...
/ 50="9920.bmp"
</item>

<item ucBPic>
/ 1 = "1440.bmp"
/ 2 = "1463.bmp"
/ 3 = "1650.bmp"
/ 4 = "1710.bmp"
/ 5 = "1999.bmp"
/ 6 = "2040.bmp"
/ 7 = "2050.bmp"
/ 8 = "2057.bmp"
/ 9 = "2058.bmp"
/ 10 = "2070.bmp"
...
/ 50= "2791.bmp"
</item>

***************
pre-ratings
**************

<block preratings>
/ preinstructions = (instruct)
/ trials = [1-120 = preratings]
</block>

<likert preratings>
/ ontrialend = [
    list.preratings.appenditem(likert.preratings.response)
]
/ stimulusframes = [1=csCPicP]
/ numpoints = 7
</likert>

<list preratings>
</list>

<picture csCPicP>
/ items = csCPic
/ position = (50%, 40%)
</text>

<page instruct>
Rate the pictures
</page>

******
evaluative conditioning
******
<list randomcsCPic>
/ poolsize = 20
</list>

<list randomucBPic>
/ poolsize = 10
</list>

<list randomucAPic>
/ poolsize = 10
</list>

<list repeatcsCPic>
</list>

<list repeatucAPic>
/ selectionmode = list.repeatucAPic.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.repeatucBPic.currentindex
</list>

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucAPic=list.randomucAPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucAPic.appenditem(values.ucAPic);
]
/ stimulustimes = [0=erase; 1=csCPic, ucAPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial CBPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucBPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucBPic=list.randomucBPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucBPic.appenditem(values.ucBPic);
]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>



<trial repeatCA>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucAPic=list.repeatucAPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<trial repeatCB>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucBPic=list.repeatucBPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<values>
/ csCPic = 1
/ ucAPic = 1
/ ucBPic = 1
</values>

<picture csCPic>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucAPic)
/ items = ucAPic
</picture>

<picture ucBPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucBPic)
/ items = ucBPic
</picture>

<trial instructions>
/ stimulustimes = [1=instructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial blockinstructions>
/ stimulustimes = [1=blockinstructions, targetinstructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<block CACB>
/ trials = [1=blockinstructions; 2-3 = noreplace (CAPic,CBPic); 3-12 = noreplace(
repeatCA,repeatCA,repeatCA,repeatCA,repeatCA,
repeatCB,repeatCB,repeatCB,repeatCB,repeatCB,
)]
</block>

<block instructions>
/ trials = [1=instructions]
</block>


***
Contingency Awareness
***

<list instructions>
/ items = (1, 2)
/ resetinterval = 20
/ selectionmode = sequence
</list>

<trial instructions>
/ stimulustimes = [1=instructions, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructions>
/ items = instructions
/ hjustify = left
/ size = (90%, 60%)
/ position = (50%, 85%)
/ valign = bottom
/ select = sequence
</text>

<item instructions>
/ 1 = "Vous l'aurez peut être remarqué, certaines images étaient présentées en même temps que les images positives ou négatives.

Vous allez maintenant revoir certaines de ces images, et nous vous demanderons, pour chacune d'entre elles d'essayer de vous rappeler si les images qui lui étaient associées étaient agréables ou désagréables.

Appuyez sur la touche A lorsque les images étaient agréables et sur la touche D lorsqu'elles étaient désagréables. "
</item>

<text spacebar>
/ items = ("Appuyez sur la barre espace pour commencer.")
/ position = (50%, 95%)
/ valign = bottom
</text>

<item attributeAlabel>
/1 = "Plaisant"
</item>

<item attributeDlabel>
/1 = "Déplaisant"
</item>

<picture cibles>
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<text attributeAlabel>
/ items = attributeAlabel
/ valign = top
/ halign = right
/ position = (80, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<text attributeDlabel>
/ items = attributeDlabel
/ valign = top
/ halign = left
/ position = (15, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<trial cibles>
/ validresponse = ("A", "P")
/ correctresponse = ("U")
/ stimulustimes = [1=cibles]
</trial>

<block CC>
/ bgstim = (attributeAlabel, attributeDlabel)
/ trials = [1 = instructions; 2-24 = noreplace(cibles)]
</block>

*****
postratings
*****
<block postratings>
/ preinstructions = (instruct)
/ trials = [1-20 = postratings]
</block>

<likert postratings>
/ ontrialend = [
    list.postratings.appenditem(likert.postratings.response)
]
/ stimulusframes = [1=csCPicPost]
/ numpoints = 7
</likert>

<picture csCPicPost>
/ items = csCPic
/ select = noreplacenot(list.preratings)
/ position = (50%, 40%)
</text>

******
experiment
*****

<expt EC>
/ blocks = [1=instructions; 2=prerating; 3-12=CACB; 13=CC; 14=postratings]
/onexptend = [values.completed = 1]
</expt>

Note that I have voluntarily omitted some parts of the scripts, such as expressions on stimulus position etc.

The idea is to :
1/ select stimuli by mean ratings and store them in an empty "list" element (as you suggested, if I understood)
2/ "tell" the script to go search for CSs in the "item" element at the beggining of the script based on the list "preratings"
3/ select randomly one negative US and one CS, as well as one positive US and another CS (hence the noreplacenorepeat) and display them in one trial each. Record which CS-US have been used, and repeat 5 times each (block CACB).
4/ Repeat step 3/ 10 times, with new CS and US (because of noreplacenorepeat). 
5/ CC and postratings on CS selected in preratings.

I hope I have been clearer.


> I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7
> (very unpleasant to pleasant), then have the script select the 20 most neutral CS
> (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5.
> So let's say mean +/- 1SD. I > don't really know how to formalize this).

Then the idea here would be to sort the rated items into distinct "bins" according to the rating they received. I.e., all items that were rated as "4" go into bin #4, all items rated "2" go into bin #2, etc. See e.g. https://www.millisecond.com/forums/FindPost6881.aspx , although in your case I would recommend storing item *numbers* in <list> elements instead of storing items in <item> elements.

Then, once the ratings are complete and you've calculated the mean and SD, pull 20 item numbers from the relevant bins. Suppose the mean rating is 4 and the SD is 1, you would then pull your "neutral" items primarily from bin #4, and -- if there are less than 20 in that bin -- fill up the rest with item numbers taken from bins #3 and/or #5.


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
Dave - Wednesday, February 15, 2017
Oulmann - Wednesday, February 15, 2017
Dave - Wednesday, February 15, 2017
Oulmann - Tuesday, February 14, 2017
Dave - Tuesday, February 14, 2017
Oulmann - Tuesday, February 14, 2017
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the parotherwisëto first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck

> but I can't find a function that allows to compute the mean

You have several options. Probably the he easiest one: Add each (numerical!) rating to a <list> /ontrialend. You can then query the list's mean and standarddeviation properties. Here's a simple example using a <likert> trial:

<block myblock>
/ postinstructions = (end)
/ trials = [1-10 = mylikert]
</block>

<likert mylikert>
/ ontrialend = [
    list.ratings.appenditem(likert.mylikert.response)
]
/ stimulusframes = [1=mytext]
/ numpoints = 7
</likert>

<list ratings>
</list>

<text mytext>
/ items = myitems
/ position = (50%, 40%)
</text>
.
<item myitems>
/ 1 = "A"4
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
/ 5 = "E"
/ 6 = "F"
/ 7 = "G"
/ 8 = "H"
/ 9 = "I"
/ 10 = "J"
</item>

<page end>
^Number of ratings: <%list.ratings.itemcount%>
^Mean rating: <%list.ratings.mean%>
^Standard deviation: <%list.ratings.standarddeviation%>
</page>

I frankly don't understand what you aim to do with respect to the selection of US stimuli / items based on your description.


Thanks for your fast answer! The "computing" The mean part seems clearer now.
The CS/US selection is done this way to be sure that no CS is associated with both a negative US (usA) and a positive US (usB). Hence I created two CS lists (that are equivalent in terms of Valence neutrality), each being associated with either positive or negative USs (there s then two experiments in the End of the script, each of both combination being a between subject condition).
It s a bit suboptimal as there is no full randomization of CS/US pairs but I can t find how to do it otherwise. 
I guess the best way is to add CS selection with the "ontrialbegin" function based on the created list, but in each trial, the CS and US will be randomly selected from the "item" element. There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all (except with the noreplace function used at the trial level?).
Thanks (again) in advance.

Sorry, I still don't understand it. Can you give me a concrete, simple simplified example, preferably with actual runable code?

> There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all.

You can pair your CSs and USs at will. Pairing stimuli is covered in https://www.millisecond.com/support/docs/v5/html/howto/howtopairs.htm and you can also do that dynamically at run-time, e.g. with <lists> you fill based on some criteria. See e.g. https://www.millisecond.com/forums/FindPost16277.aspx

I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7 (very unpleasant to pleasant), then have the script select the 20 most neutral CS (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5. So let's say mean +/- 1SD. I don't really know how to formalize this).

Participants then do an evaluative conditioning task in which US (negative and positive stimuli) are paired with the, supposedly neutral, CSs. I would like that each CS to be paired randomly with only one US (10 negative CS-US pairs and 10 positive CS-US pairs, again randomly), and each of the 20 pairs to be presented 5 times.

Than have an contingency awareness task (i.e. a memory task) were participants are asked to remember the valence of the US with wich each CS was paired. So basically a likert scale for each CS with the same questions

Then postratings of the CSs (same as the preatings)

Here is the code :

*******
CSs and USs)
*******

<item csCPic>
/ 1 = "CFD-BF-028-001-N.jpg"
/ 2 = "CFD-BF-205-141-N.jpg"
/ 3 = "CFD-BF-218-207-N.jpg"
/ 4 = "CFD-BF-219-137-N.jpg"
/ 5 = "CFD-BF-221-223-N.jpg"
/ 6 = "CFD-BF-228-212-N.jpg"
/ 7 = "CFD-BF-240-179-N.jpg"
/ 8 = "CFD-BF-249-091-N.jpg"
....
/120 = "CFD-BF-125-874-N.jpg"
</item>

<item ucAPic>
/ 1 = "1525.bmp"
/ 2 ="2053.bmp"
/ 3 ="2141.bmp"
/ 4 ="2276.bmp"
/ 5 ="2375.1.bmp"
/ 6 ="2710.bmp"
/ 7 ="2750.bmp"
/ 8 ="2900.bmp"
...
/ 50="9920.bmp"
</item>

<item ucBPic>
/ 1 = "1440.bmp"
/ 2 = "1463.bmp"
/ 3 = "1650.bmp"
/ 4 = "1710.bmp"
/ 5 = "1999.bmp"
/ 6 = "2040.bmp"
/ 7 = "2050.bmp"
/ 8 = "2057.bmp"
/ 9 = "2058.bmp"
/ 10 = "2070.bmp"
...
/ 50= "2791.bmp"
</item>

***************
pre-ratings
**************

<block preratings>
/ preinstructions = (instruct)
/ trials = [1-120 = preratings]
</block>

<likert preratings>
/ ontrialend = [
    list.preratings.appenditem(likert.preratings.response)
]
/ stimulusframes = [1=csCPicP]
/ numpoints = 7
</likert>

<list preratings>
</list>

<picture csCPicP>
/ items = csCPic
/ position = (50%, 40%)
</text>

<page instruct>
Rate the pictures
</page>

******
evaluative conditioning
******
<list randomcsCPic>
/ poolsize = 20
</list>

<list randomucBPic>
/ poolsize = 10
</list>

<list randomucAPic>
/ poolsize = 10
</list>

<list repeatcsCPic>
</list>

<list repeatucAPic>
/ selectionmode = list.repeatucAPic.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.repeatucBPic.currentindex
</list>

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucAPic=list.randomucAPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucAPic.appenditem(values.ucAPic);
]
/ stimulustimes = [0=erase; 1=csCPic, ucAPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial CBPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucBPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucBPic=list.randomucBPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucBPic.appenditem(values.ucBPic);
]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>



<trial repeatCA>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucAPic=list.repeatucAPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<trial repeatCB>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucBPic=list.repeatucBPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<values>
/ csCPic = 1
/ ucAPic = 1
/ ucBPic = 1
</values>

<picture csCPic>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucAPic)
/ items = ucAPic
</picture>

<picture ucBPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucBPic)
/ items = ucBPic
</picture>

<trial instructions>
/ stimulustimes = [1=instructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial blockinstructions>
/ stimulustimes = [1=blockinstructions, targetinstructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<block CACB>
/ trials = [1=blockinstructions; 2-3 = noreplace (CAPic,CBPic); 3-12 = noreplace(
repeatCA,repeatCA,repeatCA,repeatCA,repeatCA,
repeatCB,repeatCB,repeatCB,repeatCB,repeatCB,
)]
</block>

<block instructions>
/ trials = [1=instructions]
</block>


***
Contingency Awareness
***

<list instructions>
/ items = (1, 2)
/ resetinterval = 20
/ selectionmode = sequence
</list>

<trial instructions>
/ stimulustimes = [1=instructions, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructions>
/ items = instructions
/ hjustify = left
/ size = (90%, 60%)
/ position = (50%, 85%)
/ valign = bottom
/ select = sequence
</text>

<item instructions>
/ 1 = "Vous l'aurez peut être remarqué, certaines images étaient présentées en même temps que les images positives ou négatives.

Vous allez maintenant revoir certaines de ces images, et nous vous demanderons, pour chacune d'entre elles d'essayer de vous rappeler si les images qui lui étaient associées étaient agréables ou désagréables.

Appuyez sur la touche A lorsque les images étaient agréables et sur la touche D lorsqu'elles étaient désagréables. "
</item>

<text spacebar>
/ items = ("Appuyez sur la barre espace pour commencer.")
/ position = (50%, 95%)
/ valign = bottom
</text>

<item attributeAlabel>
/1 = "Plaisant"
</item>

<item attributeDlabel>
/1 = "Déplaisant"
</item>

<picture cibles>
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<text attributeAlabel>
/ items = attributeAlabel
/ valign = top
/ halign = right
/ position = (80, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<text attributeDlabel>
/ items = attributeDlabel
/ valign = top
/ halign = left
/ position = (15, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<trial cibles>
/ validresponse = ("A", "P")
/ correctresponse = ("U")
/ stimulustimes = [1=cibles]
</trial>

<block CC>
/ bgstim = (attributeAlabel, attributeDlabel)
/ trials = [1 = instructions; 2-24 = noreplace(cibles)]
</block>

*****
postratings
*****
<block postratings>
/ preinstructions = (instruct)
/ trials = [1-20 = postratings]
</block>

<likert postratings>
/ ontrialend = [
    list.postratings.appenditem(likert.postratings.response)
]
/ stimulusframes = [1=csCPicPost]
/ numpoints = 7
</likert>

<picture csCPicPost>
/ items = csCPic
/ select = noreplacenot(list.preratings)
/ position = (50%, 40%)
</text>

******
experiment
*****

<expt EC>
/ blocks = [1=instructions; 2=prerating; 3-12=CACB; 13=CC; 14=postratings]
/onexptend = [values.completed = 1]
</expt>

Note that I have voluntarily omitted some parts of the scripts, such as expressions on stimulus position etc.

The idea is to :
1/ select stimuli by mean ratings and store them in an empty "list" element (as you suggested, if I understood)
2/ "tell" the script to go search for CSs in the "item" element at the beggining of the script based on the list "preratings"
3/ select randomly one negative US and one CS, as well as one positive US and another CS (hence the noreplacenorepeat) and display them in one trial each. Record which CS-US have been used, and repeat 5 times each (block CACB).
4/ Repeat step 3/ 10 times, with new CS and US (because of noreplacenorepeat). 
5/ CC and postratings on CS selected in preratings.

I hope I have been clearer.


> I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7
> (very unpleasant to pleasant), then have the script select the 20 most neutral CS
> (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5.
> So let's say mean +/- 1SD. I > don't really know how to formalize this).

Then the idea here would be to sort the rated items into distinct "bins" according to the rating they received. I.e., all items that were rated as "4" go into bin #4, all items rated "2" go into bin #2, etc. See e.g. https://www.millisecond.com/forums/FindPost6881.aspx , although in your case I would recommend storing item *numbers* in <list> elements instead of storing items in <item> elements.

Then, once the ratings are complete and you've calculated the mean and SD, pull 20 item numbers from the relevant bins. Suppose the mean rating is 4 and the SD is 1, you would then pull your "neutral" items primarily from bin #4, and -- if there are less than 20 in that bin -- fill up the rest with item numbers taken from bins #3 and/or #5.


To illustrate further, here's an extension of the short example in that thread which I still had handy. The scenario is this:

A number of female and male stimuli are rated (6 female items, 6 male items in the example). Then, based on those ratings, two item sets are assembled:
High: A selection of highest rated items (50% female / 50% male; 2 female items, 2 male items in the example).
Low: A selection of lowest rated items ((50% female / 50% male; 2 female items, 2 male items in the example).

<block myblock>
/ trials = [1-12=noreplace(female_likert, male_likert);
    13=ratingresults;
    14-15=select_females_high;
    16-17=select_females_low;
    18-19=select_males_high;
    20-21=select_males_low;]
/ postinstructions = (selectionresults)
</block>

<likert female_likert>
/ ontrialend = [if(likert.female_likert.response=="1")item.female_r1.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="2")item.female_r2.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="3")item.female_r3.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="4")item.female_r4.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="5")item.female_r5.item=text.female.currentitem]
/ stimulusframes = [1=female,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
</likert>

<text female>
/ items = femaleitems
/ position = (50%, 60%)
</text>

<item femaleitems>
/ 1 = "Female A"
/ 2 = "Female B"
/ 3 = "Female C"
/ 4 = "Female D"
/ 5 = "Female E"
/ 6 = "Female F"
</item>

<likert male_likert>
/ ontrialend = [if(likert.male_likert.response=="1")item.male_r1.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="2")item.male_r2.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="3")item.male_r3.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="4")item.male_r4.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="5")item.male_r5.item=text.male.currentitem]
/ stimulusframes = [1=male,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
</likert>

<text male>
/ items = maleitems
/ position = (50%, 60%)
</text>

<item maleitems>
/ 1 = "Male A"
/ 2 = "Male B"
/ 3 = "Male C"
/ 4 = "Male D"
/ 5 = "Male E"
/ 6 = "Male F"
</item>

<text debug>
/ items = ("Female rating results:
R1=<%item.female_r1.itemcount%>|R2=<%item.female_r2.itemcount%>|R3=<%item.female_r3.itemcount%>|R4=<%item.female_r4.itemcount%>|R5=<%item.female_r5.itemcount%>
Male rating results:
R1=<%item.male_r1.itemcount%>|R2=<%item.male_r2.itemcount%>|R3=<%item.male_r3.itemcount%>|R4=<%item.male_r4.itemcount%>|R5=<%item.male_r5.itemcount%>
")
/ size = (90%, 30%)
/ position = (50%, 30%)
/ erase = false
</text>

<item female_r1>
</item>

<item female_r2>
</item>

<item female_r3>
</item>

<item female_r4>
</item>

<item female_r5>
</item>

<item male_r1>
</item>

<item male_r2>
</item>

<item male_r3>
</item>

<item male_r4>
</item>

<item male_r5>
</item>

<trial ratingresults>
/ stimulusframes = [1=debug]
/ validresponse = (57)
/ timeout = 5000
</trial>

<trial select_females_high>
/ ontrialbegin = [if (item.female_r5.itemcount > 0) {item.high.appenditem(item.female_r5.item(1)); item.female_r5.removeitem(1);}
    else if (item.female_r4.itemcount > 0) {item.high.appenditem(item.female_r4.item(1)); item.female_r4.removeitem(1);}
    else if (item.female_r3.itemcount > 0) {item.high.appenditem(item.female_r3.item(1)); item.female_r3.removeitem(1);}
    else if (item.female_r2.itemcount > 0) {item.high.appenditem(item.female_r2.item(1)); item.female_r2.removeitem(1);}
    else if (item.female_r1.itemcount > 0) {item.high.appenditem(item.female_r1.item(1)); item.female_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_females_low>
/ ontrialbegin = [if (item.female_r1.itemcount > 0) {item.low.appenditem(item.female_r1.item(1)); item.female_r1.removeitem(1);}
    else if (item.female_r2.itemcount > 0) {item.low.appenditem(item.female_r2.item(1)); item.female_r2.removeitem(1);}
    else if (item.female_r3.itemcount > 0) {item.low.appenditem(item.female_r3.item(1)); item.female_r3.removeitem(1);}
    else if (item.female_r4.itemcount > 0) {item.low.appenditem(item.female_r4.item(1)); item.female_r4.removeitem(1);}
    else if (item.female_r5.itemcount > 0) {item.low.appenditem(item.female_r5.item(1)); item.female_r5.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_males_high>
/ ontrialbegin = [if (item.male_r5.itemcount > 0) {item.high.appenditem(item.male_r5.item(1)); item.male_r5.removeitem(1);}
    else if (item.male_r4.itemcount > 0) {item.high.appenditem(item.male_r4.item(1)); item.male_r4.removeitem(1);}
    else if (item.male_r3.itemcount > 0) {item.high.appenditem(item.male_r3.item(1)); item.male_r3.removeitem(1);}
    else if (item.male_r2.itemcount > 0) {item.high.appenditem(item.male_r2.item(1)); item.male_r2.removeitem(1);}
    else if (item.male_r1.itemcount > 0) {item.high.appenditem(item.male_r1.item(1)); item.male_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_males_low>
/ ontrialbegin = [if (item.male_r1.itemcount > 0) {item.low.appenditem(item.male_r1.item(1)); item.male_r1.removeitem(1);}
    else if (item.male_r2.itemcount > 0) {item.low.appenditem(item.male_r2.item(1)); item.male_r2.removeitem(1);}
    else if (item.male_r3.itemcount > 0) {item.low.appenditem(item.male_r3.item(1)); item.male_r3.removeitem(1);}
    else if (item.male_r4.itemcount > 0) {item.low.appenditem(item.male_r4.item(1)); item.male_r4.removeitem(1);}
    else if (item.male_r5.itemcount > 0) {item.low.appenditem(item.male_r5.item(1)); item.male_r5.removeitem(1);}; ]
/ trialduration = 0
</trial>

<item high>
</item>

<item low>
</item>

<page selectionresults>
^'High' item set (<%item.high.itemcount%> items):
^<%item.high.item(1)%>, <%item.high.item(2)%>, <%item.high.item(3)%>, <%item.high.item(4)%>
^^
^'Low' item set (<%item.low.itemcount%> items):
^<%item.low.item(1)%>, <%item.low.item(2)%>, <%item.low.item(3)%>, <%item.low.item(4)%>
</page>



Oulmann
Oulmann
Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)
Group: Forum Members
Posts: 19, Visits: 64
Dave - Wednesday, February 15, 2017
Dave - Wednesday, February 15, 2017
Oulmann - Wednesday, February 15, 2017
Dave - Wednesday, February 15, 2017
Oulmann - Tuesday, February 14, 2017
Dave - Tuesday, February 14, 2017
Oulmann - Tuesday, February 14, 2017
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the parotherwisëto first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck

> but I can't find a function that allows to compute the mean

You have several options. Probably the he easiest one: Add each (numerical!) rating to a <list> /ontrialend. You can then query the list's mean and standarddeviation properties. Here's a simple example using a <likert> trial:

<block myblock>
/ postinstructions = (end)
/ trials = [1-10 = mylikert]
</block>

<likert mylikert>
/ ontrialend = [
    list.ratings.appenditem(likert.mylikert.response)
]
/ stimulusframes = [1=mytext]
/ numpoints = 7
</likert>

<list ratings>
</list>

<text mytext>
/ items = myitems
/ position = (50%, 40%)
</text>
.
<item myitems>
/ 1 = "A"4
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
/ 5 = "E"
/ 6 = "F"
/ 7 = "G"
/ 8 = "H"
/ 9 = "I"
/ 10 = "J"
</item>

<page end>
^Number of ratings: <%list.ratings.itemcount%>
^Mean rating: <%list.ratings.mean%>
^Standard deviation: <%list.ratings.standarddeviation%>
</page>

I frankly don't understand what you aim to do with respect to the selection of US stimuli / items based on your description.


Thanks for your fast answer! The "computing" The mean part seems clearer now.
The CS/US selection is done this way to be sure that no CS is associated with both a negative US (usA) and a positive US (usB). Hence I created two CS lists (that are equivalent in terms of Valence neutrality), each being associated with either positive or negative USs (there s then two experiments in the End of the script, each of both combination being a between subject condition).
It s a bit suboptimal as there is no full randomization of CS/US pairs but I can t find how to do it otherwise. 
I guess the best way is to add CS selection with the "ontrialbegin" function based on the created list, but in each trial, the CS and US will be randomly selected from the "item" element. There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all (except with the noreplace function used at the trial level?).
Thanks (again) in advance.

Sorry, I still don't understand it. Can you give me a concrete, simple simplified example, preferably with actual runable code?

> There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all.

You can pair your CSs and USs at will. Pairing stimuli is covered in https://www.millisecond.com/support/docs/v5/html/howto/howtopairs.htm and you can also do that dynamically at run-time, e.g. with <lists> you fill based on some criteria. See e.g. https://www.millisecond.com/forums/FindPost16277.aspx

I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7 (very unpleasant to pleasant), then have the script select the 20 most neutral CS (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5. So let's say mean +/- 1SD. I don't really know how to formalize this).

Participants then do an evaluative conditioning task in which US (negative and positive stimuli) are paired with the, supposedly neutral, CSs. I would like that each CS to be paired randomly with only one US (10 negative CS-US pairs and 10 positive CS-US pairs, again randomly), and each of the 20 pairs to be presented 5 times.

Than have an contingency awareness task (i.e. a memory task) were participants are asked to remember the valence of the US with wich each CS was paired. So basically a likert scale for each CS with the same questions

Then postratings of the CSs (same as the preatings)

Here is the code :

*******
CSs and USs)
*******

<item csCPic>
/ 1 = "CFD-BF-028-001-N.jpg"
/ 2 = "CFD-BF-205-141-N.jpg"
/ 3 = "CFD-BF-218-207-N.jpg"
/ 4 = "CFD-BF-219-137-N.jpg"
/ 5 = "CFD-BF-221-223-N.jpg"
/ 6 = "CFD-BF-228-212-N.jpg"
/ 7 = "CFD-BF-240-179-N.jpg"
/ 8 = "CFD-BF-249-091-N.jpg"
....
/120 = "CFD-BF-125-874-N.jpg"
</item>

<item ucAPic>
/ 1 = "1525.bmp"
/ 2 ="2053.bmp"
/ 3 ="2141.bmp"
/ 4 ="2276.bmp"
/ 5 ="2375.1.bmp"
/ 6 ="2710.bmp"
/ 7 ="2750.bmp"
/ 8 ="2900.bmp"
...
/ 50="9920.bmp"
</item>

<item ucBPic>
/ 1 = "1440.bmp"
/ 2 = "1463.bmp"
/ 3 = "1650.bmp"
/ 4 = "1710.bmp"
/ 5 = "1999.bmp"
/ 6 = "2040.bmp"
/ 7 = "2050.bmp"
/ 8 = "2057.bmp"
/ 9 = "2058.bmp"
/ 10 = "2070.bmp"
...
/ 50= "2791.bmp"
</item>

***************
pre-ratings
**************

<block preratings>
/ preinstructions = (instruct)
/ trials = [1-120 = preratings]
</block>

<likert preratings>
/ ontrialend = [
    list.preratings.appenditem(likert.preratings.response)
]
/ stimulusframes = [1=csCPicP]
/ numpoints = 7
</likert>

<list preratings>
</list>

<picture csCPicP>
/ items = csCPic
/ position = (50%, 40%)
</text>

<page instruct>
Rate the pictures
</page>

******
evaluative conditioning
******
<list randomcsCPic>
/ poolsize = 20
</list>

<list randomucBPic>
/ poolsize = 10
</list>

<list randomucAPic>
/ poolsize = 10
</list>

<list repeatcsCPic>
</list>

<list repeatucAPic>
/ selectionmode = list.repeatucAPic.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.repeatucBPic.currentindex
</list>

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucAPic=list.randomucAPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucAPic.appenditem(values.ucAPic);
]
/ stimulustimes = [0=erase; 1=csCPic, ucAPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial CBPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucBPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucBPic=list.randomucBPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucBPic.appenditem(values.ucBPic);
]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>



<trial repeatCA>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucAPic=list.repeatucAPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<trial repeatCB>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucBPic=list.repeatucBPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<values>
/ csCPic = 1
/ ucAPic = 1
/ ucBPic = 1
</values>

<picture csCPic>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucAPic)
/ items = ucAPic
</picture>

<picture ucBPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucBPic)
/ items = ucBPic
</picture>

<trial instructions>
/ stimulustimes = [1=instructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial blockinstructions>
/ stimulustimes = [1=blockinstructions, targetinstructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<block CACB>
/ trials = [1=blockinstructions; 2-3 = noreplace (CAPic,CBPic); 3-12 = noreplace(
repeatCA,repeatCA,repeatCA,repeatCA,repeatCA,
repeatCB,repeatCB,repeatCB,repeatCB,repeatCB,
)]
</block>

<block instructions>
/ trials = [1=instructions]
</block>


***
Contingency Awareness
***

<list instructions>
/ items = (1, 2)
/ resetinterval = 20
/ selectionmode = sequence
</list>

<trial instructions>
/ stimulustimes = [1=instructions, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructions>
/ items = instructions
/ hjustify = left
/ size = (90%, 60%)
/ position = (50%, 85%)
/ valign = bottom
/ select = sequence
</text>

<item instructions>
/ 1 = "Vous l'aurez peut être remarqué, certaines images étaient présentées en même temps que les images positives ou négatives.

Vous allez maintenant revoir certaines de ces images, et nous vous demanderons, pour chacune d'entre elles d'essayer de vous rappeler si les images qui lui étaient associées étaient agréables ou désagréables.

Appuyez sur la touche A lorsque les images étaient agréables et sur la touche D lorsqu'elles étaient désagréables. "
</item>

<text spacebar>
/ items = ("Appuyez sur la barre espace pour commencer.")
/ position = (50%, 95%)
/ valign = bottom
</text>

<item attributeAlabel>
/1 = "Plaisant"
</item>

<item attributeDlabel>
/1 = "Déplaisant"
</item>

<picture cibles>
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<text attributeAlabel>
/ items = attributeAlabel
/ valign = top
/ halign = right
/ position = (80, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<text attributeDlabel>
/ items = attributeDlabel
/ valign = top
/ halign = left
/ position = (15, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<trial cibles>
/ validresponse = ("A", "P")
/ correctresponse = ("U")
/ stimulustimes = [1=cibles]
</trial>

<block CC>
/ bgstim = (attributeAlabel, attributeDlabel)
/ trials = [1 = instructions; 2-24 = noreplace(cibles)]
</block>

*****
postratings
*****
<block postratings>
/ preinstructions = (instruct)
/ trials = [1-20 = postratings]
</block>

<likert postratings>
/ ontrialend = [
    list.postratings.appenditem(likert.postratings.response)
]
/ stimulusframes = [1=csCPicPost]
/ numpoints = 7
</likert>

<picture csCPicPost>
/ items = csCPic
/ select = noreplacenot(list.preratings)
/ position = (50%, 40%)
</text>

******
experiment
*****

<expt EC>
/ blocks = [1=instructions; 2=prerating; 3-12=CACB; 13=CC; 14=postratings]
/onexptend = [values.completed = 1]
</expt>

Note that I have voluntarily omitted some parts of the scripts, such as expressions on stimulus position etc.

The idea is to :
1/ select stimuli by mean ratings and store them in an empty "list" element (as you suggested, if I understood)
2/ "tell" the script to go search for CSs in the "item" element at the beggining of the script based on the list "preratings"
3/ select randomly one negative US and one CS, as well as one positive US and another CS (hence the noreplacenorepeat) and display them in one trial each. Record which CS-US have been used, and repeat 5 times each (block CACB).
4/ Repeat step 3/ 10 times, with new CS and US (because of noreplacenorepeat). 
5/ CC and postratings on CS selected in preratings.

I hope I have been clearer.


> I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7
> (very unpleasant to pleasant), then have the script select the 20 most neutral CS
> (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5.
> So let's say mean +/- 1SD. I > don't really know how to formalize this).

Then the idea here would be to sort the rated items into distinct "bins" according to the rating they received. I.e., all items that were rated as "4" go into bin #4, all items rated "2" go into bin #2, etc. See e.g. https://www.millisecond.com/forums/FindPost6881.aspx , although in your case I would recommend storing item *numbers* in <list> elements instead of storing items in <item> elements.

Then, once the ratings are complete and you've calculated the mean and SD, pull 20 item numbers from the relevant bins. Suppose the mean rating is 4 and the SD is 1, you would then pull your "neutral" items primarily from bin #4, and -- if there are less than 20 in that bin -- fill up the rest with item numbers taken from bins #3 and/or #5.


To illustrate further, here's an extension of the short example in that thread which I still had handy. The scenario is this:

A number of female and male stimuli are rated (6 female items, 6 male items in the example). Then, based on those ratings, two item sets are assembled:
High: A selection of highest rated items (50% female / 50% male; 2 female items, 2 male items in the example).
Low: A selection of lowest rated items ((50% female / 50% male; 2 female items, 2 male items in the example).

<block myblock>
/ trials = [1-12=noreplace(female_likert, male_likert);
    13=ratingresults;
    14-15=select_females_high;
    16-17=select_females_low;
    18-19=select_males_high;
    20-21=select_males_low;]
/ postinstructions = (selectionresults)
</block>

<likert female_likert>
/ ontrialend = [if(likert.female_likert.response=="1")item.female_r1.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="2")item.female_r2.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="3")item.female_r3.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="4")item.female_r4.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="5")item.female_r5.item=text.female.currentitem]
/ stimulusframes = [1=female,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
</likert>

<text female>
/ items = femaleitems
/ position = (50%, 60%)
</text>

<item femaleitems>
/ 1 = "Female A"
/ 2 = "Female B"
/ 3 = "Female C"
/ 4 = "Female D"
/ 5 = "Female E"
/ 6 = "Female F"
</item>

<likert male_likert>
/ ontrialend = [if(likert.male_likert.response=="1")item.male_r1.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="2")item.male_r2.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="3")item.male_r3.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="4")item.male_r4.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="5")item.male_r5.item=text.male.currentitem]
/ stimulusframes = [1=male,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
</likert>

<text male>
/ items = maleitems
/ position = (50%, 60%)
</text>

<item maleitems>
/ 1 = "Male A"
/ 2 = "Male B"
/ 3 = "Male C"
/ 4 = "Male D"
/ 5 = "Male E"
/ 6 = "Male F"
</item>

<text debug>
/ items = ("Female rating results:
R1=<%item.female_r1.itemcount%>|R2=<%item.female_r2.itemcount%>|R3=<%item.female_r3.itemcount%>|R4=<%item.female_r4.itemcount%>|R5=<%item.female_r5.itemcount%>
Male rating results:
R1=<%item.male_r1.itemcount%>|R2=<%item.male_r2.itemcount%>|R3=<%item.male_r3.itemcount%>|R4=<%item.male_r4.itemcount%>|R5=<%item.male_r5.itemcount%>
")
/ size = (90%, 30%)
/ position = (50%, 30%)
/ erase = false
</text>

<item female_r1>
</item>

<item female_r2>
</item>

<item female_r3>
</item>

<item female_r4>
</item>

<item female_r5>
</item>

<item male_r1>
</item>

<item male_r2>
</item>

<item male_r3>
</item>

<item male_r4>
</item>

<item male_r5>
</item>

<trial ratingresults>
/ stimulusframes = [1=debug]
/ validresponse = (57)
/ timeout = 5000
</trial>

<trial select_females_high>
/ ontrialbegin = [if (item.female_r5.itemcount > 0) {item.high.appenditem(item.female_r5.item(1)); item.female_r5.removeitem(1);}
    else if (item.female_r4.itemcount > 0) {item.high.appenditem(item.female_r4.item(1)); item.female_r4.removeitem(1);}
    else if (item.female_r3.itemcount > 0) {item.high.appenditem(item.female_r3.item(1)); item.female_r3.removeitem(1);}
    else if (item.female_r2.itemcount > 0) {item.high.appenditem(item.female_r2.item(1)); item.female_r2.removeitem(1);}
    else if (item.female_r1.itemcount > 0) {item.high.appenditem(item.female_r1.item(1)); item.female_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_females_low>
/ ontrialbegin = [if (item.female_r1.itemcount > 0) {item.low.appenditem(item.female_r1.item(1)); item.female_r1.removeitem(1);}
    else if (item.female_r2.itemcount > 0) {item.low.appenditem(item.female_r2.item(1)); item.female_r2.removeitem(1);}
    else if (item.female_r3.itemcount > 0) {item.low.appenditem(item.female_r3.item(1)); item.female_r3.removeitem(1);}
    else if (item.female_r4.itemcount > 0) {item.low.appenditem(item.female_r4.item(1)); item.female_r4.removeitem(1);}
    else if (item.female_r5.itemcount > 0) {item.low.appenditem(item.female_r5.item(1)); item.female_r5.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_males_high>
/ ontrialbegin = [if (item.male_r5.itemcount > 0) {item.high.appenditem(item.male_r5.item(1)); item.male_r5.removeitem(1);}
    else if (item.male_r4.itemcount > 0) {item.high.appenditem(item.male_r4.item(1)); item.male_r4.removeitem(1);}
    else if (item.male_r3.itemcount > 0) {item.high.appenditem(item.male_r3.item(1)); item.male_r3.removeitem(1);}
    else if (item.male_r2.itemcount > 0) {item.high.appenditem(item.male_r2.item(1)); item.male_r2.removeitem(1);}
    else if (item.male_r1.itemcount > 0) {item.high.appenditem(item.male_r1.item(1)); item.male_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_males_low>
/ ontrialbegin = [if (item.male_r1.itemcount > 0) {item.low.appenditem(item.male_r1.item(1)); item.male_r1.removeitem(1);}
    else if (item.male_r2.itemcount > 0) {item.low.appenditem(item.male_r2.item(1)); item.male_r2.removeitem(1);}
    else if (item.male_r3.itemcount > 0) {item.low.appenditem(item.male_r3.item(1)); item.male_r3.removeitem(1);}
    else if (item.male_r4.itemcount > 0) {item.low.appenditem(item.male_r4.item(1)); item.male_r4.removeitem(1);}
    else if (item.male_r5.itemcount > 0) {item.low.appenditem(item.male_r5.item(1)); item.male_r5.removeitem(1);}; ]
/ trialduration = 0
</trial>

<item high>
</item>

<item low>
</item>

<page selectionresults>
^'High' item set (<%item.high.itemcount%> items):
^<%item.high.item(1)%>, <%item.high.item(2)%>, <%item.high.item(3)%>, <%item.high.item(4)%>
^^
^'Low' item set (<%item.low.itemcount%> items):
^<%item.low.item(1)%>, <%item.low.item(2)%>, <%item.low.item(3)%>, <%item.low.item(4)%>
</page>



Hi again! Thanks a lot for the advice, and code.

The ratings and sorting into "bins" part seems to work quite nicely, but now it's the CS-US pairings that doesn't work. I would like the script to select 20 CS (from the neutral items, named "mean" in the script below) and pair 10 of them with one positive US and 10 of them with one negative US. Then repeated each pair 5 times. All this is in the "evaluative conditioning" section in the script. 

 The rationale was to start with a trial that randomly selected one CS and one negative (trial CAPic) or positive (trial CBPic) US, save the values taken by item (meanR), and repeat (basically with this procedure : https://www.millisecond.com/forums/Topic16276.aspx)
What I have is : trial 1 : "CS1-US1", then "CS1, US2 (5 times)", "CS1-US3", then "CS1, US2", etc. It seems that the "repeatCA" and repeatCB" trials are completely independent from CAPic and CBPic.

I think I must have missed something while entering the "values" but I can't find what.

<parameters>
/ exposureDuration = 3000
/ csPicSize = 33%
/ ucPicSize = 25%
/ ucFontHeight = 5%
/ defaultFontHeight = 6%
/ defaultPicSize = 33%
/ ITI = 0
</parameters>

**************************************************************************************************************
**************************************************************************************************************
EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**********************************************************************************************************

<item csCPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 1 = "CFD-LM-208-110-N.jpg"
....
/ 1 = "CFD-WM-254-152-N.jpg"
/ 1 = "CFD-WM-258-125-N.jpg"
</item>


<item ucAPic>
/ 1 = "1525.bmp"
/ 2 ="2053.bmp"
....
/ 50="9920.bmp"
</item>

<item ucBPic>
/ 1 = "1440.bmp"
/ 2 = "1463.bmp"
...
/ 50= "2791.bmp"
</item>

<item targetPic>
/ 1 = "3210.jpg"
/ 2 = "1390.jpg"
/ 3 = "2272.jpg"
/ 4 = "3302.jpg"
/ 5 = "7920.jpg"
/ 6 = "7031.jpg"
/ 7 = "2230.jpg"
/ 8 = "9401.jpg"
/ 9 = "9210.jpg"
/ 10 = "7110.jpg"
/ 11= "8320.jpg"
/ 12 = "5460.bmp"
/ 13 = "5635.jpg"
/ 14 = "2010.jpg"
/ 15 = "7472.jpg"
/ 16 = "8341.jpg"
/ 17 = "2605.jpg"
/ 18 = "1942.jpg"
/ 19 = "4535.jpg"
/ 20= "8540.bmp"
</item>

<item distractorPic>
/ 1 = "distractor1.jpg"
/ 2 = "distractor2.jpg"
/ 3 = "distractor3.jpg"
/ 4 = "distractor4.jpg"
</item>

**************************************************************************************************************
**************************************************************************************************************
EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<item instructionsEC>
/ 1 = "Vous allez réaliser une tâche de vigilance.

Vous allez voir des images apparaitre à l'écran, seules ou par paires. Votre tâche sera d'identifier et de mémoriser la réponse émotionnelle de l'image cible qui apparaitra à l'écran. Cette image apparaitra à l'écran après les mots 'CIBLE-MEMORISEZ'
Il est important que vous identifier et que vous gardiez ce que cette image vous à évoqué émotionnellement en mémoire. Au bout d'un certain temps, une seconde image cible apparaitra à l'écran.

Votre tâche sera d'appuyer sur la barre d'espace <%expressions.buttoninstruct1%> si la seconde image à la même valence émotionnelle que l'image que vous avez mémorisé.

Si ce n'est pas le cas, ne répondez PAS.

Vous devrez completer un total de 6 blocks d'essais.

Appuyez sur la barre d'espace pour continuer."
/ 2 = "Dans les blocks d'essais suivants, la cible sera l'image suivante.

Quand vous verrez cette image, appuyez sur la barre d'espace <%expressions.buttoninstruct1%> aussi vite que possible.

Si quoi que ce soit d'autre que la cible apparait, ne répondez PAS.

Appuyez sur la barre d'espace pour débuter le block."
</item>

<item targettext>
/ 1 = "CIBLE - MEMORISEZ"
</item>


<expressions>
/buttoninstruct1 = if (computer.touch) {"button";} else {"key";}
</expressions>
**************************************************************************************************************
**************************************************************************************************************
DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/canvasaspectratio = (4,3)
/minimumversion = "5.0.0.0"
/ fontstyle = ("Arial", 5.5%, false, false, false, false, 5, 1)
/txbgcolor = white
/ txcolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
Data columns
**************************************************************************************************************
**************************************************************************************************************

*******************
raw data
*******************

<data>
/separatefiles = true
/ columns = (build computer.platform date time subject group blockcode blocknum values.currentblock trialcode trialnum stimulusitem
stimulusitem stimulusitem response latency)
</data>

*******************
summary data
*******************

<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
expressions.meanRT_targets, expressions.percentcorrect_targets)
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
Automatically updated Task Parameters
**************************************************************************************************************
**************************************************************************************************************
The script also have the following parameters:

/ completed:0 = script was not completed; 1 = script was completed (all conditions run)
/ leftStimPosition-
/ rightStimPosition:determines the screen positions of the left and right items
/ currentBlock:counts the blocks
/ csAPosition:stores the x-coordinate of the CSA
/ csBPosition:stores the x-coordinate of the CSB
/ ucPosition:stores the x-coordinate of the UCS

/sumrt_targets:sums the latencies of correct responses to targets (across blocks)
/count_targets:counts target trials (across blocks)
/countcorrect_targets:counts correct responses to target trials (across blocks)


<values>
/ completed = 0
/ leftStimPosition = 50% - (parameters.defaultPicSize / 2)
/ rightStimPosition = 50 + (parameters.defaultPicSize / 2)
/ currentBlock = 0
/ csAPosition = 0
/ csBPosition = 0
/ ucPosition = 0

/sumrt_targets = 0
/count_targets = 0
/countcorrect_targets = 0
</values>

**************************************************************************************************************
**************************************************************************************************************
Expressions
**************************************************************************************************************
**************************************************************************************************************

<expressions>
/ ucAPosition = if ( values.csAPosition == values.rightStimPosition ) values.leftStimPosition else values.rightStimPosition
/ ucBPosition = if ( values.csAPosition == values.rightStimPosition ) values.leftStimPosition else values.rightStimPosition

/percentcorrect_targets = (values.countcorrect_targets/values.count_targets) * 100
/meanRT_targets = values.sumrt_targets/values.countcorrect_targets
</expressions>


**************************************************************************************************************
**************************************************************************************************************
Pre-ratings
**************************************************************************************************************
**************************************************************************************************************

<block preratings>
/ trials = [1-120=noreplace(csCPicP);
  121=ratingresults; 122=selectCS]
</block>

<likert csCPicP>
/ ontrialend = [if(likert.csCPicP.response=="1")item.csCPicP_r1.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="2")item.csCPicP_r2.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="3")item.csCPicP_r3.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="4")item.csCPicP_r4.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="5")item.csCPicP_r5.item=picture.csCPicP.currentitem]
/ stimulusframes = [1=csCPicP,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
/ numpoints = 5
/ position = (50, 85)
/ anchors = [1="Très déplaisant"; 5="Très plaisant"]
/ fontstyle = ("Arial", 2%, false, false, false, false, 5, 1)
</likert>



<text debug>
/ items = ("CS rating results:
R1=<%item.csCPicP_r1.itemcount%>|R2=<%item.csCPicP_r2.itemcount%>|R3=<%item.csCPicP_r3.itemcount%>|R4=<%item.csCPicP_r4.itemcount%>|R5=<%item.csCPicP_r5.itemcount%>

")

/ size = (40%, 20%)
/ position = (50%, 10%)
/ erase = false
</text>

<item csCPicP_r1>
</item>

<item csCPicP_r2>
</item>

<item csCPicP_r3>
</item>

<item csCPicP_r4>
</item>

<item csCPicP_r5>
</item>


<trial ratingresults>
/ stimulusframes = [1=debug]
/ validresponse = (57)
/ timeout = 5000
</trial>


<item mean>
</item>

<item ext>
</item>

<page selectionresults>
^'High' item set (<%item.mean.itemcount%> items):
^<%item.mean.item(1)%>, <%item.mean.item(2)%>, <%item.mean.item(3)%>, <%item.mean.item(4)%>
^^
^'Low' item set (<%item.ext.itemcount%> items):
^<%item.ext.item(1)%>, <%item.ext.item(2)%>, <%item.ext.item(3)%>, <%item.ext.item(4)%>
</page>



<list preratings>
</list>

<picture csCPicP>
/ items = csCPic
/ position = (50%, 50%)
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
</picture>

<page instruct>
Rate the pictures
</page>

<trial selectCS>
/ ontrialbegin = [if (item.csCPicP_r3.itemcount > 0) {item.mean.appenditem(item.csCPicP_r3.item(1)); item.csCPicP_r3.removeitem(1);}
  else if (item.csCPicP_r4.itemcount > 0) {item.mean.appenditem(item.csCPicP_r4.item(1)); item.csCPicP_r4.removeitem(1);}
  else if (item.csCPicP_r2.itemcount > 0) {item.mean.appenditem(item.csCPicP_r2.item(1)); item.csCPicP_r2.removeitem(1);}
  else if (item.csCPicP_r5.itemcount > 0) {item.mean.appenditem(item.csCPicP_r5.item(1)); item.csCPicP_r5.removeitem(1);}
  else if (item.csCPicP_r1.itemcount > 0) {item.mean.appenditem(item.csCPicP_r1.item(1)); item.csCPicP_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>
**************************************************************************************************************
**************************************************************************************************************
Stimulus sets, layout, selection
**************************************************************************************************************
**************************************************************************************************************


<picture targetPic>
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
/ items = targetPic
/ select = values.currentBlock
/ erase = false
</picture>


<picture distractorPic>
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
/ items = distractorPic
/ erase = false
</picture>

<shape blank>
/ shape = rectangle
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
/ color = gray
/ erase = false
</shape>

<list csAPosition>
/ items = (values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition)
/ replace = false
</list>

<list csBPosition>
/ items = (values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition)
/ replace = false
</list>

<text instructionsEC>
/ fontstyle = ("Arial", 3.13%, false, false, false, false, 5, 0)
/ size = (66%, 66%)
/ items = instructionsEC
/ select = 1
</text>

<text blockinstructions>
/ fontstyle = ("Arial", 3.13%, false, false, false, false, 5, 0)
/ position = (50%, 33%)
/ size = (66%, 50%)
/ items = instructionsEC
/ select = 2
</text>

<text targettext>
/ fontstyle = ("Arial", 3.13%, false, false, false, false, 5, 0)
/ position = (50%, 50%)
/ size = (66%, 50%)
/ items = targettext
/ select = 2
</text>

<picture targetinstructions>
/ position = (50%, 66%)
/ size = (33%, 33%)
/ items = targetPic
/ select = values.currentBlock
</picture>

<shape erase>
/ shape = rectangle
/ size = (100%, 100%)
/ color = white
/ erase = false
</shape>



<list randommean>
/ poolsize = 20
</list>

<list randomucBPic>
/ poolsize = 50
</list>

<list randomucAPic>
/ poolsize = 50
</list>

<list repeatmean>
</list>

<list repeatucAPic>
/ selectionmode = list.repeatmean.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.repeatmean.currentindex
</list>


<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.meanR=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucAPic.appenditem(values.ucAPicR);
]
/ stimulustimes = [0=erase; 1=mean, ucAPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial CBPic>
/ ontrialbegin = [
values.csAPosition = list.csBPosition.nextvalue;
values.ucPosition = expressions.ucBPosition;
values.meanR=list.randommean.nextindex; values.ucBPicR=list.randomucBPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucBPic.appenditem(values.ucBPicR);
]
/ stimulustimes = [0=erase; 1= mean, ucbPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>



<trial repeatCA>
/ ontrialbegin = [values.meanR=list.repeatmean.nextvalue; values.ucAPicR=list.repeatucAPic.nextvalue;
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition; ]
/ stimulustimes = [0=erase; 1= meanR, ucAPicR]
/ validresponse = (57)
/ trialduration = parameters.exposureDuration
</trial>


<trial repeatCB>
/ ontrialbegin = [values.meanR=list.repeatmean.nextvalue; values.ucBPicR=list.repeatucBPic.nextvalue;
values.csAPosition = list.csBPosition.nextvalue;
values.ucPosition = expressions.ucBPosition; ]
/ stimulustimes = [0=erase; 1= meanR, ucbPicR]
/ validresponse = (57)
/ trialduration = parameters.exposureDuration
</trial>

<picture meanR>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplace
/ items = mean
</picture>

<picture ucAPicR>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = values.ucAPicR
/ items = ucAPic
</picture>

<picture ucBPicR>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = values.ucBPicR
/ items = ucBPic
</picture>

<values>
/ meanR = 1
/ ucAPicR = 1
/ ucBPicR = 1
</values>

<picture mean>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplace
/ items = mean
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot (ucAPic)
/ items = ucAPic
</picture>

<picture ucBPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot (ucBPic)
/ items = ucBPic
</picture>

<trial instructionsEC>
/ stimulustimes = [1=instructionsEC]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial blockinstructions>
/ stimulustimes = [1=blockinstructions, targetinstructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial mean>
/ stimulusframes = [1=mean]
/ correctresponse = ("D","A")
/ recorddata = true
</trial>

<block instructionsEC>
/ trials = [1=instructionsEC]
</block>


**************************************************************************************************************
**************************************************************************************************************
Trials
**************************************************************************************************************
**************************************************************************************************************

<trial target>
/ ontrialbegin = [values.count_targets += 1]
/ stimulustimes = [0=erase; 16= targettext; 300=targetPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ correctresponse = (" ")
/ ontrialend = [if (trial.target.correct) {values.countcorrect_targets += 1; values.sumrt_targets += trial.target.latency}]
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial distractorPic>
/ stimulustimes = [0=erase, distractorPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial blank>
/ stimulustimes = [0=erase, blank]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>


optional ITI:
<trial ITI>
/ stimulusframes = [1 = erase]
/trialduration = parameters.ITI
/ recorddata = false
</trial>

**************************************************************************************************************
**************************************************************************************************************
Blocks
**************************************************************************************************************
**************************************************************************************************************
The block controls the distribution of trial types. The default settings run a total
of 8 conditioning trials per block, with the rest of the trials divided up between
targets, distractors, and blanks. The ratio of trials, can be changed below.

**************************************************************************************************************
**************************************************************************************************************

<block CA>
/ trials = [1=blockinstructions; 2-8 = CAPic,
repeatCA,repeatCA,repeatCA,repeatCA,repeatCA,
]
</block>

<block CB>
/ trials = [1=blockinstructions; 2-8 = CBPic,
repeatCB,repeatCB,repeatCB,repeatCB,repeatCB
]
</block>



**************************************************************************************************************
**************************************************************************************************************
Contingency Awareness
**************************************************************************************************************
**************************************************************************************************************
<trial instructionsGENERALES>
/ stimulustimes = [1=instructionsGENERALES, instructionsGENERALES, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsGENERALES>
/ items = ("Vous l'aurez peut être remarqué, certaines images étaient présentées en même temps que les images positives ou négatives")
/ size = (500, 70)
/ position = (50, 40)
/ halign = center
/ select = sequence
</text>

<text spacebar>
/ items = ("Appuyez sur la touche ESPACE pour continuer.")
/ position = (50%, 95%)
/ valign = bottom
</text>

<trial instructionsInclusion>
/ stimulustimes = [1=instructionsInclusion]
/ correctresponse = ("S")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsInclusion>
/ items = ("Vous allez maintenant revoir certaines de ces images, et nous vous demanderons, pour chacune d'entre elles d'essayer de vous rappeler si les images qui lui étaient associées étaient agréables ou désagréables.

Vous appuierez sur la touche A lorsque les images étaient agréables et sur la touche D lorsqu'elles étaient désagréables.

Au cas où vous n'arriveriez pas à vous en souvenir, répondez en vous basant sur votre ressenti envers l'image présentée (touche A pour agréable, touche D pour désagréable).

Veuillez appeler l'expérimentateur.")
/ size = (700, 70)
/ position = (50, 20)
/ halign = center
/ select = sequence
</text>

<trial instructionsEntrainement>
/ stimulustimes = [1=instructionsEntrainement, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsEntrainement>
/ items = ("Vous allez maintenant réaliser quelques essais d'entrâinement")
/ size = (500, 70)
/ position = (50, 50)
/ halign = center
/ select = sequence
</text>

<trial instructionsCommencer>
/ stimulustimes = [1=instructionsCommencer, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsCommencer>
/ items = ("Nous allons maintenant commencer la tâche")
/ size = (500, 70)
/ position = (50, 50)
/ halign = center
/ select = sequence
</text>

<trial instructionsMerci>
/ stimulustimes = [1=instructionsMerci]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsMerci>
/ items = ("Merci de votre participation à cette étude")
/ size = (500, 70)
/ position = (50, 50)
/ halign = center
/ select = sequence
</text>

<item agreableM>
/1= "A si l'image associée était AGREABLE"
</item>

<text agreableM>
/ items = agreableM
/ valign = top
/ halign = left
/ position = (2%, 5%)
/ txcolor = (0, 255, 0)
/ fontstyle = ("Arial", 3%)
</text>

<item desagreableM>
/1= "D si les images associées étaient DESAGREABLES"
</item>

<text desagreableM>
/ items = desagreableM
/ valign = top
/ halign = right
/ position = (98%, 5%)
/ txcolor = (0, 255, 0)
/ fontstyle = ("Arial", 3%)
</text>

<item agreableA>
/1= "A si les images associées étaient AGREABLES, D si elles étaient DESAGREABLES. Si vous ne vous en rappelez pas, A si l'image ci-dessous est DESAGREABLE et D si elle est AGREABLE"
</item>

<text agreableA>
/ items = agreableA
/ valign = top
/ halign = center
/ position = (50%, 5%)
/ txcolor = (0, 255, 0)
/ fontstyle = ("Arial", 2%)
</text>

<block instructionsInclusion>
/ trials = [1=instructionsGENERALES; 2=instructionsInclusion;3=instructionsEntrainement]
</block>

<block Inclusion>
/ bgstim = (agreableM, desagreableM)
/ trials = [1=instructionsCommencer; 2-22= noreplace(mean);23=instructionsMerci]
</block>

**************************************************************************************************************
**************************************************************************************************************
postratings
**************************************************************************************************************
**************************************************************************************************************

<block postratings>
/ preinstructions = (instruct)
/ trials = [1-20 = postratings]
</block>

<likert postratings>
/ stimulusframes = [1=mean]
/ numpoints = 7
</likert>




**************************************************************************************************************
**************************************************************************************************************
Experiment
**************************************************************************************************************
**************************************************************************************************************

<expt EC_Inclusion>
/ blocks = [1=preratings; 2=instructionsEC; 3-12=noreplace(CA,CB); 13=instructionsInclusion; 14=instructionsInclusion; 15=postratings]
</expt>

**************************************************************************************************************
**************************************************************************************************************
End of Script
**************************************************************************************************************
**************************************************************************************************************


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
Oulmann - Thursday, February 16, 2017
Dave - Wednesday, February 15, 2017
Dave - Wednesday, February 15, 2017
Oulmann - Wednesday, February 15, 2017
Dave - Wednesday, February 15, 2017
Oulmann - Tuesday, February 14, 2017
Dave - Tuesday, February 14, 2017
Oulmann - Tuesday, February 14, 2017
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the parotherwisëto first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck

> but I can't find a function that allows to compute the mean

You have several options. Probably the he easiest one: Add each (numerical!) rating to a <list> /ontrialend. You can then query the list's mean and standarddeviation properties. Here's a simple example using a <likert> trial:

<block myblock>
/ postinstructions = (end)
/ trials = [1-10 = mylikert]
</block>

<likert mylikert>
/ ontrialend = [
    list.ratings.appenditem(likert.mylikert.response)
]
/ stimulusframes = [1=mytext]
/ numpoints = 7
</likert>

<list ratings>
</list>

<text mytext>
/ items = myitems
/ position = (50%, 40%)
</text>
.
<item myitems>
/ 1 = "A"4
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
/ 5 = "E"
/ 6 = "F"
/ 7 = "G"
/ 8 = "H"
/ 9 = "I"
/ 10 = "J"
</item>

<page end>
^Number of ratings: <%list.ratings.itemcount%>
^Mean rating: <%list.ratings.mean%>
^Standard deviation: <%list.ratings.standarddeviation%>
</page>

I frankly don't understand what you aim to do with respect to the selection of US stimuli / items based on your description.


Thanks for your fast answer! The "computing" The mean part seems clearer now.
The CS/US selection is done this way to be sure that no CS is associated with both a negative US (usA) and a positive US (usB). Hence I created two CS lists (that are equivalent in terms of Valence neutrality), each being associated with either positive or negative USs (there s then two experiments in the End of the script, each of both combination being a between subject condition).
It s a bit suboptimal as there is no full randomization of CS/US pairs but I can t find how to do it otherwise. 
I guess the best way is to add CS selection with the "ontrialbegin" function based on the created list, but in each trial, the CS and US will be randomly selected from the "item" element. There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all (except with the noreplace function used at the trial level?).
Thanks (again) in advance.

Sorry, I still don't understand it. Can you give me a concrete, simple simplified example, preferably with actual runable code?

> There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all.

You can pair your CSs and USs at will. Pairing stimuli is covered in https://www.millisecond.com/support/docs/v5/html/howto/howtopairs.htm and you can also do that dynamically at run-time, e.g. with <lists> you fill based on some criteria. See e.g. https://www.millisecond.com/forums/FindPost16277.aspx

I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7 (very unpleasant to pleasant), then have the script select the 20 most neutral CS (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5. So let's say mean +/- 1SD. I don't really know how to formalize this).

Participants then do an evaluative conditioning task in which US (negative and positive stimuli) are paired with the, supposedly neutral, CSs. I would like that each CS to be paired randomly with only one US (10 negative CS-US pairs and 10 positive CS-US pairs, again randomly), and each of the 20 pairs to be presented 5 times.

Than have an contingency awareness task (i.e. a memory task) were participants are asked to remember the valence of the US with wich each CS was paired. So basically a likert scale for each CS with the same questions

Then postratings of the CSs (same as the preatings)

Here is the code :

*******
CSs and USs)
*******

<item csCPic>
/ 1 = "CFD-BF-028-001-N.jpg"
/ 2 = "CFD-BF-205-141-N.jpg"
/ 3 = "CFD-BF-218-207-N.jpg"
/ 4 = "CFD-BF-219-137-N.jpg"
/ 5 = "CFD-BF-221-223-N.jpg"
/ 6 = "CFD-BF-228-212-N.jpg"
/ 7 = "CFD-BF-240-179-N.jpg"
/ 8 = "CFD-BF-249-091-N.jpg"
....
/120 = "CFD-BF-125-874-N.jpg"
</item>

<item ucAPic>
/ 1 = "1525.bmp"
/ 2 ="2053.bmp"
/ 3 ="2141.bmp"
/ 4 ="2276.bmp"
/ 5 ="2375.1.bmp"
/ 6 ="2710.bmp"
/ 7 ="2750.bmp"
/ 8 ="2900.bmp"
...
/ 50="9920.bmp"
</item>

<item ucBPic>
/ 1 = "1440.bmp"
/ 2 = "1463.bmp"
/ 3 = "1650.bmp"
/ 4 = "1710.bmp"
/ 5 = "1999.bmp"
/ 6 = "2040.bmp"
/ 7 = "2050.bmp"
/ 8 = "2057.bmp"
/ 9 = "2058.bmp"
/ 10 = "2070.bmp"
...
/ 50= "2791.bmp"
</item>

***************
pre-ratings
**************

<block preratings>
/ preinstructions = (instruct)
/ trials = [1-120 = preratings]
</block>

<likert preratings>
/ ontrialend = [
    list.preratings.appenditem(likert.preratings.response)
]
/ stimulusframes = [1=csCPicP]
/ numpoints = 7
</likert>

<list preratings>
</list>

<picture csCPicP>
/ items = csCPic
/ position = (50%, 40%)
</text>

<page instruct>
Rate the pictures
</page>

******
evaluative conditioning
******
<list randomcsCPic>
/ poolsize = 20
</list>

<list randomucBPic>
/ poolsize = 10
</list>

<list randomucAPic>
/ poolsize = 10
</list>

<list repeatcsCPic>
</list>

<list repeatucAPic>
/ selectionmode = list.repeatucAPic.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.repeatucBPic.currentindex
</list>

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucAPic=list.randomucAPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucAPic.appenditem(values.ucAPic);
]
/ stimulustimes = [0=erase; 1=csCPic, ucAPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial CBPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucBPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucBPic=list.randomucBPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucBPic.appenditem(values.ucBPic);
]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>



<trial repeatCA>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucAPic=list.repeatucAPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<trial repeatCB>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucBPic=list.repeatucBPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<values>
/ csCPic = 1
/ ucAPic = 1
/ ucBPic = 1
</values>

<picture csCPic>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucAPic)
/ items = ucAPic
</picture>

<picture ucBPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucBPic)
/ items = ucBPic
</picture>

<trial instructions>
/ stimulustimes = [1=instructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial blockinstructions>
/ stimulustimes = [1=blockinstructions, targetinstructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<block CACB>
/ trials = [1=blockinstructions; 2-3 = noreplace (CAPic,CBPic); 3-12 = noreplace(
repeatCA,repeatCA,repeatCA,repeatCA,repeatCA,
repeatCB,repeatCB,repeatCB,repeatCB,repeatCB,
)]
</block>

<block instructions>
/ trials = [1=instructions]
</block>


***
Contingency Awareness
***

<list instructions>
/ items = (1, 2)
/ resetinterval = 20
/ selectionmode = sequence
</list>

<trial instructions>
/ stimulustimes = [1=instructions, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructions>
/ items = instructions
/ hjustify = left
/ size = (90%, 60%)
/ position = (50%, 85%)
/ valign = bottom
/ select = sequence
</text>

<item instructions>
/ 1 = "Vous l'aurez peut être remarqué, certaines images étaient présentées en même temps que les images positives ou négatives.

Vous allez maintenant revoir certaines de ces images, et nous vous demanderons, pour chacune d'entre elles d'essayer de vous rappeler si les images qui lui étaient associées étaient agréables ou désagréables.

Appuyez sur la touche A lorsque les images étaient agréables et sur la touche D lorsqu'elles étaient désagréables. "
</item>

<text spacebar>
/ items = ("Appuyez sur la barre espace pour commencer.")
/ position = (50%, 95%)
/ valign = bottom
</text>

<item attributeAlabel>
/1 = "Plaisant"
</item>

<item attributeDlabel>
/1 = "Déplaisant"
</item>

<picture cibles>
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<text attributeAlabel>
/ items = attributeAlabel
/ valign = top
/ halign = right
/ position = (80, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<text attributeDlabel>
/ items = attributeDlabel
/ valign = top
/ halign = left
/ position = (15, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<trial cibles>
/ validresponse = ("A", "P")
/ correctresponse = ("U")
/ stimulustimes = [1=cibles]
</trial>

<block CC>
/ bgstim = (attributeAlabel, attributeDlabel)
/ trials = [1 = instructions; 2-24 = noreplace(cibles)]
</block>

*****
postratings
*****
<block postratings>
/ preinstructions = (instruct)
/ trials = [1-20 = postratings]
</block>

<likert postratings>
/ ontrialend = [
    list.postratings.appenditem(likert.postratings.response)
]
/ stimulusframes = [1=csCPicPost]
/ numpoints = 7
</likert>

<picture csCPicPost>
/ items = csCPic
/ select = noreplacenot(list.preratings)
/ position = (50%, 40%)
</text>

******
experiment
*****

<expt EC>
/ blocks = [1=instructions; 2=prerating; 3-12=CACB; 13=CC; 14=postratings]
/onexptend = [values.completed = 1]
</expt>

Note that I have voluntarily omitted some parts of the scripts, such as expressions on stimulus position etc.

The idea is to :
1/ select stimuli by mean ratings and store them in an empty "list" element (as you suggested, if I understood)
2/ "tell" the script to go search for CSs in the "item" element at the beggining of the script based on the list "preratings"
3/ select randomly one negative US and one CS, as well as one positive US and another CS (hence the noreplacenorepeat) and display them in one trial each. Record which CS-US have been used, and repeat 5 times each (block CACB).
4/ Repeat step 3/ 10 times, with new CS and US (because of noreplacenorepeat). 
5/ CC and postratings on CS selected in preratings.

I hope I have been clearer.


> I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7
> (very unpleasant to pleasant), then have the script select the 20 most neutral CS
> (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5.
> So let's say mean +/- 1SD. I > don't really know how to formalize this).

Then the idea here would be to sort the rated items into distinct "bins" according to the rating they received. I.e., all items that were rated as "4" go into bin #4, all items rated "2" go into bin #2, etc. See e.g. https://www.millisecond.com/forums/FindPost6881.aspx , although in your case I would recommend storing item *numbers* in <list> elements instead of storing items in <item> elements.

Then, once the ratings are complete and you've calculated the mean and SD, pull 20 item numbers from the relevant bins. Suppose the mean rating is 4 and the SD is 1, you would then pull your "neutral" items primarily from bin #4, and -- if there are less than 20 in that bin -- fill up the rest with item numbers taken from bins #3 and/or #5.


To illustrate further, here's an extension of the short example in that thread which I still had handy. The scenario is this:

A number of female and male stimuli are rated (6 female items, 6 male items in the example). Then, based on those ratings, two item sets are assembled:
High: A selection of highest rated items (50% female / 50% male; 2 female items, 2 male items in the example).
Low: A selection of lowest rated items ((50% female / 50% male; 2 female items, 2 male items in the example).

<block myblock>
/ trials = [1-12=noreplace(female_likert, male_likert);
    13=ratingresults;
    14-15=select_females_high;
    16-17=select_females_low;
    18-19=select_males_high;
    20-21=select_males_low;]
/ postinstructions = (selectionresults)
</block>

<likert female_likert>
/ ontrialend = [if(likert.female_likert.response=="1")item.female_r1.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="2")item.female_r2.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="3")item.female_r3.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="4")item.female_r4.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="5")item.female_r5.item=text.female.currentitem]
/ stimulusframes = [1=female,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
</likert>

<text female>
/ items = femaleitems
/ position = (50%, 60%)
</text>

<item femaleitems>
/ 1 = "Female A"
/ 2 = "Female B"
/ 3 = "Female C"
/ 4 = "Female D"
/ 5 = "Female E"
/ 6 = "Female F"
</item>

<likert male_likert>
/ ontrialend = [if(likert.male_likert.response=="1")item.male_r1.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="2")item.male_r2.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="3")item.male_r3.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="4")item.male_r4.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="5")item.male_r5.item=text.male.currentitem]
/ stimulusframes = [1=male,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
</likert>

<text male>
/ items = maleitems
/ position = (50%, 60%)
</text>

<item maleitems>
/ 1 = "Male A"
/ 2 = "Male B"
/ 3 = "Male C"
/ 4 = "Male D"
/ 5 = "Male E"
/ 6 = "Male F"
</item>

<text debug>
/ items = ("Female rating results:
R1=<%item.female_r1.itemcount%>|R2=<%item.female_r2.itemcount%>|R3=<%item.female_r3.itemcount%>|R4=<%item.female_r4.itemcount%>|R5=<%item.female_r5.itemcount%>
Male rating results:
R1=<%item.male_r1.itemcount%>|R2=<%item.male_r2.itemcount%>|R3=<%item.male_r3.itemcount%>|R4=<%item.male_r4.itemcount%>|R5=<%item.male_r5.itemcount%>
")
/ size = (90%, 30%)
/ position = (50%, 30%)
/ erase = false
</text>

<item female_r1>
</item>

<item female_r2>
</item>

<item female_r3>
</item>

<item female_r4>
</item>

<item female_r5>
</item>

<item male_r1>
</item>

<item male_r2>
</item>

<item male_r3>
</item>

<item male_r4>
</item>

<item male_r5>
</item>

<trial ratingresults>
/ stimulusframes = [1=debug]
/ validresponse = (57)
/ timeout = 5000
</trial>

<trial select_females_high>
/ ontrialbegin = [if (item.female_r5.itemcount > 0) {item.high.appenditem(item.female_r5.item(1)); item.female_r5.removeitem(1);}
    else if (item.female_r4.itemcount > 0) {item.high.appenditem(item.female_r4.item(1)); item.female_r4.removeitem(1);}
    else if (item.female_r3.itemcount > 0) {item.high.appenditem(item.female_r3.item(1)); item.female_r3.removeitem(1);}
    else if (item.female_r2.itemcount > 0) {item.high.appenditem(item.female_r2.item(1)); item.female_r2.removeitem(1);}
    else if (item.female_r1.itemcount > 0) {item.high.appenditem(item.female_r1.item(1)); item.female_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_females_low>
/ ontrialbegin = [if (item.female_r1.itemcount > 0) {item.low.appenditem(item.female_r1.item(1)); item.female_r1.removeitem(1);}
    else if (item.female_r2.itemcount > 0) {item.low.appenditem(item.female_r2.item(1)); item.female_r2.removeitem(1);}
    else if (item.female_r3.itemcount > 0) {item.low.appenditem(item.female_r3.item(1)); item.female_r3.removeitem(1);}
    else if (item.female_r4.itemcount > 0) {item.low.appenditem(item.female_r4.item(1)); item.female_r4.removeitem(1);}
    else if (item.female_r5.itemcount > 0) {item.low.appenditem(item.female_r5.item(1)); item.female_r5.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_males_high>
/ ontrialbegin = [if (item.male_r5.itemcount > 0) {item.high.appenditem(item.male_r5.item(1)); item.male_r5.removeitem(1);}
    else if (item.male_r4.itemcount > 0) {item.high.appenditem(item.male_r4.item(1)); item.male_r4.removeitem(1);}
    else if (item.male_r3.itemcount > 0) {item.high.appenditem(item.male_r3.item(1)); item.male_r3.removeitem(1);}
    else if (item.male_r2.itemcount > 0) {item.high.appenditem(item.male_r2.item(1)); item.male_r2.removeitem(1);}
    else if (item.male_r1.itemcount > 0) {item.high.appenditem(item.male_r1.item(1)); item.male_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_males_low>
/ ontrialbegin = [if (item.male_r1.itemcount > 0) {item.low.appenditem(item.male_r1.item(1)); item.male_r1.removeitem(1);}
    else if (item.male_r2.itemcount > 0) {item.low.appenditem(item.male_r2.item(1)); item.male_r2.removeitem(1);}
    else if (item.male_r3.itemcount > 0) {item.low.appenditem(item.male_r3.item(1)); item.male_r3.removeitem(1);}
    else if (item.male_r4.itemcount > 0) {item.low.appenditem(item.male_r4.item(1)); item.male_r4.removeitem(1);}
    else if (item.male_r5.itemcount > 0) {item.low.appenditem(item.male_r5.item(1)); item.male_r5.removeitem(1);}; ]
/ trialduration = 0
</trial>

<item high>
</item>

<item low>
</item>

<page selectionresults>
^'High' item set (<%item.high.itemcount%> items):
^<%item.high.item(1)%>, <%item.high.item(2)%>, <%item.high.item(3)%>, <%item.high.item(4)%>
^^
^'Low' item set (<%item.low.itemcount%> items):
^<%item.low.item(1)%>, <%item.low.item(2)%>, <%item.low.item(3)%>, <%item.low.item(4)%>
</page>



Hi again! Thanks a lot for the advice, and code.

The ratings and sorting into "bins" part seems to work quite nicely, but now it's the CS-US pairings that doesn't work. I would like the script to select 20 CS (from the neutral items, named "mean" in the script below) and pair 10 of them with one positive US and 10 of them with one negative US. Then repeated each pair 5 times. All this is in the "evaluative conditioning" section in the script. 

 The rationale was to start with a trial that randomly selected one CS and one negative (trial CAPic) or positive (trial CBPic) US, save the values taken by item (meanR), and repeat (basically with this procedure : https://www.millisecond.com/forums/Topic16276.aspx)
What I have is : trial 1 : "CS1-US1", then "CS1, US2 (5 times)", "CS1-US3", then "CS1, US2", etc. It seems that the "repeatCA" and repeatCB" trials are completely independent from CAPic and CBPic.

I think I must have missed something while entering the "values" but I can't find what.

<parameters>
/ exposureDuration = 3000
/ csPicSize = 33%
/ ucPicSize = 25%
/ ucFontHeight = 5%
/ defaultFontHeight = 6%
/ defaultPicSize = 33%
/ ITI = 0
</parameters>

**************************************************************************************************************
**************************************************************************************************************
EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**********************************************************************************************************

<item csCPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 1 = "CFD-LM-208-110-N.jpg"
....
/ 1 = "CFD-WM-254-152-N.jpg"
/ 1 = "CFD-WM-258-125-N.jpg"
</item>


<item ucAPic>
/ 1 = "1525.bmp"
/ 2 ="2053.bmp"
....
/ 50="9920.bmp"
</item>

<item ucBPic>
/ 1 = "1440.bmp"
/ 2 = "1463.bmp"
...
/ 50= "2791.bmp"
</item>

<item targetPic>
/ 1 = "3210.jpg"
/ 2 = "1390.jpg"
/ 3 = "2272.jpg"
/ 4 = "3302.jpg"
/ 5 = "7920.jpg"
/ 6 = "7031.jpg"
/ 7 = "2230.jpg"
/ 8 = "9401.jpg"
/ 9 = "9210.jpg"
/ 10 = "7110.jpg"
/ 11= "8320.jpg"
/ 12 = "5460.bmp"
/ 13 = "5635.jpg"
/ 14 = "2010.jpg"
/ 15 = "7472.jpg"
/ 16 = "8341.jpg"
/ 17 = "2605.jpg"
/ 18 = "1942.jpg"
/ 19 = "4535.jpg"
/ 20= "8540.bmp"
</item>

<item distractorPic>
/ 1 = "distractor1.jpg"
/ 2 = "distractor2.jpg"
/ 3 = "distractor3.jpg"
/ 4 = "distractor4.jpg"
</item>

**************************************************************************************************************
**************************************************************************************************************
EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<item instructionsEC>
/ 1 = "Vous allez réaliser une tâche de vigilance.

Vous allez voir des images apparaitre à l'écran, seules ou par paires. Votre tâche sera d'identifier et de mémoriser la réponse émotionnelle de l'image cible qui apparaitra à l'écran. Cette image apparaitra à l'écran après les mots 'CIBLE-MEMORISEZ'
Il est important que vous identifier et que vous gardiez ce que cette image vous à évoqué émotionnellement en mémoire. Au bout d'un certain temps, une seconde image cible apparaitra à l'écran.

Votre tâche sera d'appuyer sur la barre d'espace <%expressions.buttoninstruct1%> si la seconde image à la même valence émotionnelle que l'image que vous avez mémorisé.

Si ce n'est pas le cas, ne répondez PAS.

Vous devrez completer un total de 6 blocks d'essais.

Appuyez sur la barre d'espace pour continuer."
/ 2 = "Dans les blocks d'essais suivants, la cible sera l'image suivante.

Quand vous verrez cette image, appuyez sur la barre d'espace <%expressions.buttoninstruct1%> aussi vite que possible.

Si quoi que ce soit d'autre que la cible apparait, ne répondez PAS.

Appuyez sur la barre d'espace pour débuter le block."
</item>

<item targettext>
/ 1 = "CIBLE - MEMORISEZ"
</item>


<expressions>
/buttoninstruct1 = if (computer.touch) {"button";} else {"key";}
</expressions>
**************************************************************************************************************
**************************************************************************************************************
DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/canvasaspectratio = (4,3)
/minimumversion = "5.0.0.0"
/ fontstyle = ("Arial", 5.5%, false, false, false, false, 5, 1)
/txbgcolor = white
/ txcolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
Data columns
**************************************************************************************************************
**************************************************************************************************************

*******************
raw data
*******************

<data>
/separatefiles = true
/ columns = (build computer.platform date time subject group blockcode blocknum values.currentblock trialcode trialnum stimulusitem
stimulusitem stimulusitem response latency)
</data>

*******************
summary data
*******************

<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
expressions.meanRT_targets, expressions.percentcorrect_targets)
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
Automatically updated Task Parameters
**************************************************************************************************************
**************************************************************************************************************
The script also have the following parameters:

/ completed:0 = script was not completed; 1 = script was completed (all conditions run)
/ leftStimPosition-
/ rightStimPosition:determines the screen positions of the left and right items
/ currentBlock:counts the blocks
/ csAPosition:stores the x-coordinate of the CSA
/ csBPosition:stores the x-coordinate of the CSB
/ ucPosition:stores the x-coordinate of the UCS

/sumrt_targets:sums the latencies of correct responses to targets (across blocks)
/count_targets:counts target trials (across blocks)
/countcorrect_targets:counts correct responses to target trials (across blocks)


<values>
/ completed = 0
/ leftStimPosition = 50% - (parameters.defaultPicSize / 2)
/ rightStimPosition = 50 + (parameters.defaultPicSize / 2)
/ currentBlock = 0
/ csAPosition = 0
/ csBPosition = 0
/ ucPosition = 0

/sumrt_targets = 0
/count_targets = 0
/countcorrect_targets = 0
</values>

**************************************************************************************************************
**************************************************************************************************************
Expressions
**************************************************************************************************************
**************************************************************************************************************

<expressions>
/ ucAPosition = if ( values.csAPosition == values.rightStimPosition ) values.leftStimPosition else values.rightStimPosition
/ ucBPosition = if ( values.csAPosition == values.rightStimPosition ) values.leftStimPosition else values.rightStimPosition

/percentcorrect_targets = (values.countcorrect_targets/values.count_targets) * 100
/meanRT_targets = values.sumrt_targets/values.countcorrect_targets
</expressions>


**************************************************************************************************************
**************************************************************************************************************
Pre-ratings
**************************************************************************************************************
**************************************************************************************************************

<block preratings>
/ trials = [1-120=noreplace(csCPicP);
  121=ratingresults; 122=selectCS]
</block>

<likert csCPicP>
/ ontrialend = [if(likert.csCPicP.response=="1")item.csCPicP_r1.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="2")item.csCPicP_r2.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="3")item.csCPicP_r3.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="4")item.csCPicP_r4.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="5")item.csCPicP_r5.item=picture.csCPicP.currentitem]
/ stimulusframes = [1=csCPicP,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
/ numpoints = 5
/ position = (50, 85)
/ anchors = [1="Très déplaisant"; 5="Très plaisant"]
/ fontstyle = ("Arial", 2%, false, false, false, false, 5, 1)
</likert>



<text debug>
/ items = ("CS rating results:
R1=<%item.csCPicP_r1.itemcount%>|R2=<%item.csCPicP_r2.itemcount%>|R3=<%item.csCPicP_r3.itemcount%>|R4=<%item.csCPicP_r4.itemcount%>|R5=<%item.csCPicP_r5.itemcount%>

")

/ size = (40%, 20%)
/ position = (50%, 10%)
/ erase = false
</text>

<item csCPicP_r1>
</item>

<item csCPicP_r2>
</item>

<item csCPicP_r3>
</item>

<item csCPicP_r4>
</item>

<item csCPicP_r5>
</item>


<trial ratingresults>
/ stimulusframes = [1=debug]
/ validresponse = (57)
/ timeout = 5000
</trial>


<item mean>
</item>

<item ext>
</item>

<page selectionresults>
^'High' item set (<%item.mean.itemcount%> items):
^<%item.mean.item(1)%>, <%item.mean.item(2)%>, <%item.mean.item(3)%>, <%item.mean.item(4)%>
^^
^'Low' item set (<%item.ext.itemcount%> items):
^<%item.ext.item(1)%>, <%item.ext.item(2)%>, <%item.ext.item(3)%>, <%item.ext.item(4)%>
</page>



<list preratings>
</list>

<picture csCPicP>
/ items = csCPic
/ position = (50%, 50%)
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
</picture>

<page instruct>
Rate the pictures
</page>

<trial selectCS>
/ ontrialbegin = [if (item.csCPicP_r3.itemcount > 0) {item.mean.appenditem(item.csCPicP_r3.item(1)); item.csCPicP_r3.removeitem(1);}
  else if (item.csCPicP_r4.itemcount > 0) {item.mean.appenditem(item.csCPicP_r4.item(1)); item.csCPicP_r4.removeitem(1);}
  else if (item.csCPicP_r2.itemcount > 0) {item.mean.appenditem(item.csCPicP_r2.item(1)); item.csCPicP_r2.removeitem(1);}
  else if (item.csCPicP_r5.itemcount > 0) {item.mean.appenditem(item.csCPicP_r5.item(1)); item.csCPicP_r5.removeitem(1);}
  else if (item.csCPicP_r1.itemcount > 0) {item.mean.appenditem(item.csCPicP_r1.item(1)); item.csCPicP_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>
**************************************************************************************************************
**************************************************************************************************************
Stimulus sets, layout, selection
**************************************************************************************************************
**************************************************************************************************************


<picture targetPic>
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
/ items = targetPic
/ select = values.currentBlock
/ erase = false
</picture>


<picture distractorPic>
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
/ items = distractorPic
/ erase = false
</picture>

<shape blank>
/ shape = rectangle
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
/ color = gray
/ erase = false
</shape>

<list csAPosition>
/ items = (values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition)
/ replace = false
</list>

<list csBPosition>
/ items = (values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition)
/ replace = false
</list>

<text instructionsEC>
/ fontstyle = ("Arial", 3.13%, false, false, false, false, 5, 0)
/ size = (66%, 66%)
/ items = instructionsEC
/ select = 1
</text>

<text blockinstructions>
/ fontstyle = ("Arial", 3.13%, false, false, false, false, 5, 0)
/ position = (50%, 33%)
/ size = (66%, 50%)
/ items = instructionsEC
/ select = 2
</text>

<text targettext>
/ fontstyle = ("Arial", 3.13%, false, false, false, false, 5, 0)
/ position = (50%, 50%)
/ size = (66%, 50%)
/ items = targettext
/ select = 2
</text>

<picture targetinstructions>
/ position = (50%, 66%)
/ size = (33%, 33%)
/ items = targetPic
/ select = values.currentBlock
</picture>

<shape erase>
/ shape = rectangle
/ size = (100%, 100%)
/ color = white
/ erase = false
</shape>



<list randommean>
/ poolsize = 20
</list>

<list randomucBPic>
/ poolsize = 50
</list>

<list randomucAPic>
/ poolsize = 50
</list>

<list repeatmean>
</list>

<list repeatucAPic>
/ selectionmode = list.repeatmean.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.repeatmean.currentindex
</list>


<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.meanR=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucAPic.appenditem(values.ucAPicR);
]
/ stimulustimes = [0=erase; 1=mean, ucAPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial CBPic>
/ ontrialbegin = [
values.csAPosition = list.csBPosition.nextvalue;
values.ucPosition = expressions.ucBPosition;
values.meanR=list.randommean.nextindex; values.ucBPicR=list.randomucBPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucBPic.appenditem(values.ucBPicR);
]
/ stimulustimes = [0=erase; 1= mean, ucbPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>



<trial repeatCA>
/ ontrialbegin = [values.meanR=list.repeatmean.nextvalue; values.ucAPicR=list.repeatucAPic.nextvalue;
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition; ]
/ stimulustimes = [0=erase; 1= meanR, ucAPicR]
/ validresponse = (57)
/ trialduration = parameters.exposureDuration
</trial>


<trial repeatCB>
/ ontrialbegin = [values.meanR=list.repeatmean.nextvalue; values.ucBPicR=list.repeatucBPic.nextvalue;
values.csAPosition = list.csBPosition.nextvalue;
values.ucPosition = expressions.ucBPosition; ]
/ stimulustimes = [0=erase; 1= meanR, ucbPicR]
/ validresponse = (57)
/ trialduration = parameters.exposureDuration
</trial>

<picture meanR>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplace
/ items = mean
</picture>

<picture ucAPicR>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = values.ucAPicR
/ items = ucAPic
</picture>

<picture ucBPicR>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = values.ucBPicR
/ items = ucBPic
</picture>

<values>
/ meanR = 1
/ ucAPicR = 1
/ ucBPicR = 1
</values>

<picture mean>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplace
/ items = mean
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot (ucAPic)
/ items = ucAPic
</picture>

<picture ucBPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot (ucBPic)
/ items = ucBPic
</picture>

<trial instructionsEC>
/ stimulustimes = [1=instructionsEC]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial blockinstructions>
/ stimulustimes = [1=blockinstructions, targetinstructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial mean>
/ stimulusframes = [1=mean]
/ correctresponse = ("D","A")
/ recorddata = true
</trial>

<block instructionsEC>
/ trials = [1=instructionsEC]
</block>


**************************************************************************************************************
**************************************************************************************************************
Trials
**************************************************************************************************************
**************************************************************************************************************

<trial target>
/ ontrialbegin = [values.count_targets += 1]
/ stimulustimes = [0=erase; 16= targettext; 300=targetPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ correctresponse = (" ")
/ ontrialend = [if (trial.target.correct) {values.countcorrect_targets += 1; values.sumrt_targets += trial.target.latency}]
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial distractorPic>
/ stimulustimes = [0=erase, distractorPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial blank>
/ stimulustimes = [0=erase, blank]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>


optional ITI:
<trial ITI>
/ stimulusframes = [1 = erase]
/trialduration = parameters.ITI
/ recorddata = false
</trial>

**************************************************************************************************************
**************************************************************************************************************
Blocks
**************************************************************************************************************
**************************************************************************************************************
The block controls the distribution of trial types. The default settings run a total
of 8 conditioning trials per block, with the rest of the trials divided up between
targets, distractors, and blanks. The ratio of trials, can be changed below.

**************************************************************************************************************
**************************************************************************************************************

<block CA>
/ trials = [1=blockinstructions; 2-8 = CAPic,
repeatCA,repeatCA,repeatCA,repeatCA,repeatCA,
]
</block>

<block CB>
/ trials = [1=blockinstructions; 2-8 = CBPic,
repeatCB,repeatCB,repeatCB,repeatCB,repeatCB
]
</block>



**************************************************************************************************************
**************************************************************************************************************
Contingency Awareness
**************************************************************************************************************
**************************************************************************************************************
<trial instructionsGENERALES>
/ stimulustimes = [1=instructionsGENERALES, instructionsGENERALES, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsGENERALES>
/ items = ("Vous l'aurez peut être remarqué, certaines images étaient présentées en même temps que les images positives ou négatives")
/ size = (500, 70)
/ position = (50, 40)
/ halign = center
/ select = sequence
</text>

<text spacebar>
/ items = ("Appuyez sur la touche ESPACE pour continuer.")
/ position = (50%, 95%)
/ valign = bottom
</text>

<trial instructionsInclusion>
/ stimulustimes = [1=instructionsInclusion]
/ correctresponse = ("S")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsInclusion>
/ items = ("Vous allez maintenant revoir certaines de ces images, et nous vous demanderons, pour chacune d'entre elles d'essayer de vous rappeler si les images qui lui étaient associées étaient agréables ou désagréables.

Vous appuierez sur la touche A lorsque les images étaient agréables et sur la touche D lorsqu'elles étaient désagréables.

Au cas où vous n'arriveriez pas à vous en souvenir, répondez en vous basant sur votre ressenti envers l'image présentée (touche A pour agréable, touche D pour désagréable).

Veuillez appeler l'expérimentateur.")
/ size = (700, 70)
/ position = (50, 20)
/ halign = center
/ select = sequence
</text>

<trial instructionsEntrainement>
/ stimulustimes = [1=instructionsEntrainement, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsEntrainement>
/ items = ("Vous allez maintenant réaliser quelques essais d'entrâinement")
/ size = (500, 70)
/ position = (50, 50)
/ halign = center
/ select = sequence
</text>

<trial instructionsCommencer>
/ stimulustimes = [1=instructionsCommencer, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsCommencer>
/ items = ("Nous allons maintenant commencer la tâche")
/ size = (500, 70)
/ position = (50, 50)
/ halign = center
/ select = sequence
</text>

<trial instructionsMerci>
/ stimulustimes = [1=instructionsMerci]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsMerci>
/ items = ("Merci de votre participation à cette étude")
/ size = (500, 70)
/ position = (50, 50)
/ halign = center
/ select = sequence
</text>

<item agreableM>
/1= "A si l'image associée était AGREABLE"
</item>

<text agreableM>
/ items = agreableM
/ valign = top
/ halign = left
/ position = (2%, 5%)
/ txcolor = (0, 255, 0)
/ fontstyle = ("Arial", 3%)
</text>

<item desagreableM>
/1= "D si les images associées étaient DESAGREABLES"
</item>

<text desagreableM>
/ items = desagreableM
/ valign = top
/ halign = right
/ position = (98%, 5%)
/ txcolor = (0, 255, 0)
/ fontstyle = ("Arial", 3%)
</text>

<item agreableA>
/1= "A si les images associées étaient AGREABLES, D si elles étaient DESAGREABLES. Si vous ne vous en rappelez pas, A si l'image ci-dessous est DESAGREABLE et D si elle est AGREABLE"
</item>

<text agreableA>
/ items = agreableA
/ valign = top
/ halign = center
/ position = (50%, 5%)
/ txcolor = (0, 255, 0)
/ fontstyle = ("Arial", 2%)
</text>

<block instructionsInclusion>
/ trials = [1=instructionsGENERALES; 2=instructionsInclusion;3=instructionsEntrainement]
</block>

<block Inclusion>
/ bgstim = (agreableM, desagreableM)
/ trials = [1=instructionsCommencer; 2-22= noreplace(mean);23=instructionsMerci]
</block>

**************************************************************************************************************
**************************************************************************************************************
postratings
**************************************************************************************************************
**************************************************************************************************************

<block postratings>
/ preinstructions = (instruct)
/ trials = [1-20 = postratings]
</block>

<likert postratings>
/ stimulusframes = [1=mean]
/ numpoints = 7
</likert>




**************************************************************************************************************
**************************************************************************************************************
Experiment
**************************************************************************************************************
**************************************************************************************************************

<expt EC_Inclusion>
/ blocks = [1=preratings; 2=instructionsEC; 3-12=noreplace(CA,CB); 13=instructionsInclusion; 14=instructionsInclusion; 15=postratings]
</expt>

**************************************************************************************************************
**************************************************************************************************************
End of Script
**************************************************************************************************************
**************************************************************************************************************


I don't understand the thinking here:

You sample a random value between 1 and 20 from list.randommean and store it in values.meanR

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.meanR=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucAPic.appenditem(values.ucAPicR);
]

You then add that value to list.repeatmean

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.meanR=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucAPic.appenditem(values.ucAPicR);
]

which was empty. I.e after adding the value, the list has one item at index 1.

Same for list.randomucAPic / values.ucAPicR and list.repeatucAPic.

However, 

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.meanR=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucAPic.appenditem(values.ucAPicR);
]
/ stimulustimes = [0=erase; 1=mean, ucAPic]

the actual <picture> elements do not in any way use the randomly sampled value for selection:

<picture mean>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplace
/ items = mean
</picture>

picture.mean just samples randomly without replacement, and I can't figure out what

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot (ucAPic)
/ items = ucAPic
</picture>

the circular constrained selection in picture.ucapic is supposed to do: It translates to "sample randomly without replacement from picture.ucapic's items, but *not* the item selected in picture.ucapic." On its face, that doesn't make any sense to me. Please explain.

Oulmann
Oulmann
Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)Esteemed Member (1.8K reputation)
Group: Forum Members
Posts: 19, Visits: 64
Dave - Thursday, February 16, 2017
Oulmann - Thursday, February 16, 2017
Dave - Wednesday, February 15, 2017
Dave - Wednesday, February 15, 2017
Oulmann - Wednesday, February 15, 2017
Dave - Wednesday, February 15, 2017
Oulmann - Tuesday, February 14, 2017
Dave - Tuesday, February 14, 2017
Oulmann - Tuesday, February 14, 2017
Hi,

I am a bit stuck in coding an evaluative conditioning task. I have 120 CS and 100 US. I would like the parotherwisëto first rate the 120 CS on a scale from 1 to 7 (unpleasant-->pleasant), then for the script to select the 20 more "neutral" stimuli, that is the one closest to the overall mean for the participant, and then use them for the evaluative conditioning task. I came up with this script :

<item csAPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 2 = "CFD-LM-208-110-N.jpg"
/ 3 = "CFD-LM-244-068-N.jpg"
/ 4 = "CFD-WF-001-003-N.jpg"
/ 5 = "CFD-WF-002-004-N.jpg"
/ 6 = "CFD-WF-003-003-N.jpg"
...
/ 60="CFD-WM-011-002-N.jpg"
</item>

<item csBPic>
/ 1 = "CFD-WM-013-001-N.jpg"
/ 2 = "CFD-WM-014-002-N.jpg"
/ 3 = "CFD-WM-015-002-N.jpg"
/ 4 = "CFD-WM-016-001-N.jpg"
...
/ 60="CFD-WM-258-125-N.jpg"
</item>

<picture csAPic>
/ items = csAPic
/ erase = false
</picture>

<picture csBPic>
/ items = csBPic
/ erase = false
</picture>

<trial_csAPic>
/ stimulusframes = [1=noreplace(csAPic)]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<trial_csBPic>
/ stimulusframes = [1=noreplace(csBPic )]
/ responseframe = 61
/ response = timeout(3000)
/ validresponse = ("q", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'")
</trial>

<block pretestA>
/ stimulusframes =[1-60=noreplace(csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, 
csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic,csApic,csApic,csApic,csApic,csApic,csApic,csApic, csApic, csApic, csApic )]
/ onblockend = [values.simplemean = round(block.pic_pretestA.mean)]]
</block>

<block pretestB>
/ stimulusframes =[1-60=noreplace(csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,
csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic,csBpic, )]
/ onblockend = [values.simplemeanB = round(block.pic_pretestB.mean)]]
</block>

but I can't find a function that allows to compute the mean, then select stimuli according to this mean (like 1 standard deviation, or minus/plus 1 point around it). Also, I would like the script to select one US for each CS, and then present both of them 5 time (10CS with negative USs and 10 with positive USs).

Trials for the EC tasks would looks like this :

<trial AAPic>
/ ontrialbegin = [values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BBPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial BAPic>
/ ontrialbegin = [
values.simplemeanB = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csBPic, ucAPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial ABPic>
/ ontrialbegin = [
values.simplemeanA = values.testtrialcounter +/- 1
]
/ stimulustimes = [0=erase, 1=noreplace (csAPic, ucbPic)]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

Thanks in advance for the help :/ I'm a bit stuck

> but I can't find a function that allows to compute the mean

You have several options. Probably the he easiest one: Add each (numerical!) rating to a <list> /ontrialend. You can then query the list's mean and standarddeviation properties. Here's a simple example using a <likert> trial:

<block myblock>
/ postinstructions = (end)
/ trials = [1-10 = mylikert]
</block>

<likert mylikert>
/ ontrialend = [
    list.ratings.appenditem(likert.mylikert.response)
]
/ stimulusframes = [1=mytext]
/ numpoints = 7
</likert>

<list ratings>
</list>

<text mytext>
/ items = myitems
/ position = (50%, 40%)
</text>
.
<item myitems>
/ 1 = "A"4
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
/ 5 = "E"
/ 6 = "F"
/ 7 = "G"
/ 8 = "H"
/ 9 = "I"
/ 10 = "J"
</item>

<page end>
^Number of ratings: <%list.ratings.itemcount%>
^Mean rating: <%list.ratings.mean%>
^Standard deviation: <%list.ratings.standarddeviation%>
</page>

I frankly don't understand what you aim to do with respect to the selection of US stimuli / items based on your description.


Thanks for your fast answer! The "computing" The mean part seems clearer now.
The CS/US selection is done this way to be sure that no CS is associated with both a negative US (usA) and a positive US (usB). Hence I created two CS lists (that are equivalent in terms of Valence neutrality), each being associated with either positive or negative USs (there s then two experiments in the End of the script, each of both combination being a between subject condition).
It s a bit suboptimal as there is no full randomization of CS/US pairs but I can t find how to do it otherwise. 
I guess the best way is to add CS selection with the "ontrialbegin" function based on the created list, but in each trial, the CS and US will be randomly selected from the "item" element. There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all (except with the noreplace function used at the trial level?).
Thanks (again) in advance.

Sorry, I still don't understand it. Can you give me a concrete, simple simplified example, preferably with actual runable code?

> There is no way to be sure that the same US is associated with the same CS, or even that a CS won t be selected at all.

You can pair your CSs and USs at will. Pairing stimuli is covered in https://www.millisecond.com/support/docs/v5/html/howto/howtopairs.htm and you can also do that dynamically at run-time, e.g. with <lists> you fill based on some criteria. See e.g. https://www.millisecond.com/forums/FindPost16277.aspx

I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7 (very unpleasant to pleasant), then have the script select the 20 most neutral CS (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5. So let's say mean +/- 1SD. I don't really know how to formalize this).

Participants then do an evaluative conditioning task in which US (negative and positive stimuli) are paired with the, supposedly neutral, CSs. I would like that each CS to be paired randomly with only one US (10 negative CS-US pairs and 10 positive CS-US pairs, again randomly), and each of the 20 pairs to be presented 5 times.

Than have an contingency awareness task (i.e. a memory task) were participants are asked to remember the valence of the US with wich each CS was paired. So basically a likert scale for each CS with the same questions

Then postratings of the CSs (same as the preatings)

Here is the code :

*******
CSs and USs)
*******

<item csCPic>
/ 1 = "CFD-BF-028-001-N.jpg"
/ 2 = "CFD-BF-205-141-N.jpg"
/ 3 = "CFD-BF-218-207-N.jpg"
/ 4 = "CFD-BF-219-137-N.jpg"
/ 5 = "CFD-BF-221-223-N.jpg"
/ 6 = "CFD-BF-228-212-N.jpg"
/ 7 = "CFD-BF-240-179-N.jpg"
/ 8 = "CFD-BF-249-091-N.jpg"
....
/120 = "CFD-BF-125-874-N.jpg"
</item>

<item ucAPic>
/ 1 = "1525.bmp"
/ 2 ="2053.bmp"
/ 3 ="2141.bmp"
/ 4 ="2276.bmp"
/ 5 ="2375.1.bmp"
/ 6 ="2710.bmp"
/ 7 ="2750.bmp"
/ 8 ="2900.bmp"
...
/ 50="9920.bmp"
</item>

<item ucBPic>
/ 1 = "1440.bmp"
/ 2 = "1463.bmp"
/ 3 = "1650.bmp"
/ 4 = "1710.bmp"
/ 5 = "1999.bmp"
/ 6 = "2040.bmp"
/ 7 = "2050.bmp"
/ 8 = "2057.bmp"
/ 9 = "2058.bmp"
/ 10 = "2070.bmp"
...
/ 50= "2791.bmp"
</item>

***************
pre-ratings
**************

<block preratings>
/ preinstructions = (instruct)
/ trials = [1-120 = preratings]
</block>

<likert preratings>
/ ontrialend = [
    list.preratings.appenditem(likert.preratings.response)
]
/ stimulusframes = [1=csCPicP]
/ numpoints = 7
</likert>

<list preratings>
</list>

<picture csCPicP>
/ items = csCPic
/ position = (50%, 40%)
</text>

<page instruct>
Rate the pictures
</page>

******
evaluative conditioning
******
<list randomcsCPic>
/ poolsize = 20
</list>

<list randomucBPic>
/ poolsize = 10
</list>

<list randomucAPic>
/ poolsize = 10
</list>

<list repeatcsCPic>
</list>

<list repeatucAPic>
/ selectionmode = list.repeatucAPic.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.repeatucBPic.currentindex
</list>

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucAPic=list.randomucAPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucAPic.appenditem(values.ucAPic);
]
/ stimulustimes = [0=erase; 1=csCPic, ucAPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial CBPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucBPosition
values.csCPic=list.randomcsCPic.nextindex; values.ucBPic=list.randomucBPic.nextindex;
  list.repeatcsCPic.appenditem(values.csCPic); list.repeatucBPic.appenditem(values.ucBPic);
]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>



<trial repeatCA>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucAPic=list.repeatucAPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<trial repeatCB>
/ ontrialbegin = [values.csCPic=list.repeatcsCPic.nextvalue; values.ucBPic=list.repeatucBPic.nextvalue; ]
/ stimulustimes = [0=erase; 1= csCPic, ucbPic]
/ validresponse = (57)
</trial>


<values>
/ csCPic = 1
/ ucAPic = 1
/ ucBPic = 1
</values>

<picture csCPic>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucAPic)
/ items = ucAPic
</picture>

<picture ucBPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot(ucBPic)
/ items = ucBPic
</picture>

<trial instructions>
/ stimulustimes = [1=instructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial blockinstructions>
/ stimulustimes = [1=blockinstructions, targetinstructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<block CACB>
/ trials = [1=blockinstructions; 2-3 = noreplace (CAPic,CBPic); 3-12 = noreplace(
repeatCA,repeatCA,repeatCA,repeatCA,repeatCA,
repeatCB,repeatCB,repeatCB,repeatCB,repeatCB,
)]
</block>

<block instructions>
/ trials = [1=instructions]
</block>


***
Contingency Awareness
***

<list instructions>
/ items = (1, 2)
/ resetinterval = 20
/ selectionmode = sequence
</list>

<trial instructions>
/ stimulustimes = [1=instructions, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructions>
/ items = instructions
/ hjustify = left
/ size = (90%, 60%)
/ position = (50%, 85%)
/ valign = bottom
/ select = sequence
</text>

<item instructions>
/ 1 = "Vous l'aurez peut être remarqué, certaines images étaient présentées en même temps que les images positives ou négatives.

Vous allez maintenant revoir certaines de ces images, et nous vous demanderons, pour chacune d'entre elles d'essayer de vous rappeler si les images qui lui étaient associées étaient agréables ou désagréables.

Appuyez sur la touche A lorsque les images étaient agréables et sur la touche D lorsqu'elles étaient désagréables. "
</item>

<text spacebar>
/ items = ("Appuyez sur la barre espace pour commencer.")
/ position = (50%, 95%)
/ valign = bottom
</text>

<item attributeAlabel>
/1 = "Plaisant"
</item>

<item attributeDlabel>
/1 = "Déplaisant"
</item>

<picture cibles>
/ erase = false
/ select = noreplacenot(list.preratings)
/ items = csCPic
</picture>

<text attributeAlabel>
/ items = attributeAlabel
/ valign = top
/ halign = right
/ position = (80, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<text attributeDlabel>
/ items = attributeDlabel
/ valign = top
/ halign = left
/ position = (15, 5)
/ txcolor = black
/ fontstyle = ("Arial", 5%)
</text>

<trial cibles>
/ validresponse = ("A", "P")
/ correctresponse = ("U")
/ stimulustimes = [1=cibles]
</trial>

<block CC>
/ bgstim = (attributeAlabel, attributeDlabel)
/ trials = [1 = instructions; 2-24 = noreplace(cibles)]
</block>

*****
postratings
*****
<block postratings>
/ preinstructions = (instruct)
/ trials = [1-20 = postratings]
</block>

<likert postratings>
/ ontrialend = [
    list.postratings.appenditem(likert.postratings.response)
]
/ stimulusframes = [1=csCPicPost]
/ numpoints = 7
</likert>

<picture csCPicPost>
/ items = csCPic
/ select = noreplacenot(list.preratings)
/ position = (50%, 40%)
</text>

******
experiment
*****

<expt EC>
/ blocks = [1=instructions; 2=prerating; 3-12=CACB; 13=CC; 14=postratings]
/onexptend = [values.completed = 1]
</expt>

Note that I have voluntarily omitted some parts of the scripts, such as expressions on stimulus position etc.

The idea is to :
1/ select stimuli by mean ratings and store them in an empty "list" element (as you suggested, if I understood)
2/ "tell" the script to go search for CSs in the "item" element at the beggining of the script based on the list "preratings"
3/ select randomly one negative US and one CS, as well as one positive US and another CS (hence the noreplacenorepeat) and display them in one trial each. Record which CS-US have been used, and repeat 5 times each (block CACB).
4/ Repeat step 3/ 10 times, with new CS and US (because of noreplacenorepeat). 
5/ CC and postratings on CS selected in preratings.

I hope I have been clearer.


> I will try to clarify all this. What I want to do is to have participants pre-rate 120 pictures (hence CSs) on a scale from 1 to 7
> (very unpleasant to pleasant), then have the script select the 20 most neutral CS
> (i.e. situated around the mean for each participant, but since they are neutral CS I expect to have means around 3.5.
> So let's say mean +/- 1SD. I > don't really know how to formalize this).

Then the idea here would be to sort the rated items into distinct "bins" according to the rating they received. I.e., all items that were rated as "4" go into bin #4, all items rated "2" go into bin #2, etc. See e.g. https://www.millisecond.com/forums/FindPost6881.aspx , although in your case I would recommend storing item *numbers* in <list> elements instead of storing items in <item> elements.

Then, once the ratings are complete and you've calculated the mean and SD, pull 20 item numbers from the relevant bins. Suppose the mean rating is 4 and the SD is 1, you would then pull your "neutral" items primarily from bin #4, and -- if there are less than 20 in that bin -- fill up the rest with item numbers taken from bins #3 and/or #5.


To illustrate further, here's an extension of the short example in that thread which I still had handy. The scenario is this:

A number of female and male stimuli are rated (6 female items, 6 male items in the example). Then, based on those ratings, two item sets are assembled:
High: A selection of highest rated items (50% female / 50% male; 2 female items, 2 male items in the example).
Low: A selection of lowest rated items ((50% female / 50% male; 2 female items, 2 male items in the example).

<block myblock>
/ trials = [1-12=noreplace(female_likert, male_likert);
    13=ratingresults;
    14-15=select_females_high;
    16-17=select_females_low;
    18-19=select_males_high;
    20-21=select_males_low;]
/ postinstructions = (selectionresults)
</block>

<likert female_likert>
/ ontrialend = [if(likert.female_likert.response=="1")item.female_r1.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="2")item.female_r2.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="3")item.female_r3.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="4")item.female_r4.item=text.female.currentitem]
/ ontrialend = [if(likert.female_likert.response=="5")item.female_r5.item=text.female.currentitem]
/ stimulusframes = [1=female,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
</likert>

<text female>
/ items = femaleitems
/ position = (50%, 60%)
</text>

<item femaleitems>
/ 1 = "Female A"
/ 2 = "Female B"
/ 3 = "Female C"
/ 4 = "Female D"
/ 5 = "Female E"
/ 6 = "Female F"
</item>

<likert male_likert>
/ ontrialend = [if(likert.male_likert.response=="1")item.male_r1.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="2")item.male_r2.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="3")item.male_r3.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="4")item.male_r4.item=text.male.currentitem]
/ ontrialend = [if(likert.male_likert.response=="5")item.male_r5.item=text.male.currentitem]
/ stimulusframes = [1=male,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
</likert>

<text male>
/ items = maleitems
/ position = (50%, 60%)
</text>

<item maleitems>
/ 1 = "Male A"
/ 2 = "Male B"
/ 3 = "Male C"
/ 4 = "Male D"
/ 5 = "Male E"
/ 6 = "Male F"
</item>

<text debug>
/ items = ("Female rating results:
R1=<%item.female_r1.itemcount%>|R2=<%item.female_r2.itemcount%>|R3=<%item.female_r3.itemcount%>|R4=<%item.female_r4.itemcount%>|R5=<%item.female_r5.itemcount%>
Male rating results:
R1=<%item.male_r1.itemcount%>|R2=<%item.male_r2.itemcount%>|R3=<%item.male_r3.itemcount%>|R4=<%item.male_r4.itemcount%>|R5=<%item.male_r5.itemcount%>
")
/ size = (90%, 30%)
/ position = (50%, 30%)
/ erase = false
</text>

<item female_r1>
</item>

<item female_r2>
</item>

<item female_r3>
</item>

<item female_r4>
</item>

<item female_r5>
</item>

<item male_r1>
</item>

<item male_r2>
</item>

<item male_r3>
</item>

<item male_r4>
</item>

<item male_r5>
</item>

<trial ratingresults>
/ stimulusframes = [1=debug]
/ validresponse = (57)
/ timeout = 5000
</trial>

<trial select_females_high>
/ ontrialbegin = [if (item.female_r5.itemcount > 0) {item.high.appenditem(item.female_r5.item(1)); item.female_r5.removeitem(1);}
    else if (item.female_r4.itemcount > 0) {item.high.appenditem(item.female_r4.item(1)); item.female_r4.removeitem(1);}
    else if (item.female_r3.itemcount > 0) {item.high.appenditem(item.female_r3.item(1)); item.female_r3.removeitem(1);}
    else if (item.female_r2.itemcount > 0) {item.high.appenditem(item.female_r2.item(1)); item.female_r2.removeitem(1);}
    else if (item.female_r1.itemcount > 0) {item.high.appenditem(item.female_r1.item(1)); item.female_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_females_low>
/ ontrialbegin = [if (item.female_r1.itemcount > 0) {item.low.appenditem(item.female_r1.item(1)); item.female_r1.removeitem(1);}
    else if (item.female_r2.itemcount > 0) {item.low.appenditem(item.female_r2.item(1)); item.female_r2.removeitem(1);}
    else if (item.female_r3.itemcount > 0) {item.low.appenditem(item.female_r3.item(1)); item.female_r3.removeitem(1);}
    else if (item.female_r4.itemcount > 0) {item.low.appenditem(item.female_r4.item(1)); item.female_r4.removeitem(1);}
    else if (item.female_r5.itemcount > 0) {item.low.appenditem(item.female_r5.item(1)); item.female_r5.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_males_high>
/ ontrialbegin = [if (item.male_r5.itemcount > 0) {item.high.appenditem(item.male_r5.item(1)); item.male_r5.removeitem(1);}
    else if (item.male_r4.itemcount > 0) {item.high.appenditem(item.male_r4.item(1)); item.male_r4.removeitem(1);}
    else if (item.male_r3.itemcount > 0) {item.high.appenditem(item.male_r3.item(1)); item.male_r3.removeitem(1);}
    else if (item.male_r2.itemcount > 0) {item.high.appenditem(item.male_r2.item(1)); item.male_r2.removeitem(1);}
    else if (item.male_r1.itemcount > 0) {item.high.appenditem(item.male_r1.item(1)); item.male_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>

<trial select_males_low>
/ ontrialbegin = [if (item.male_r1.itemcount > 0) {item.low.appenditem(item.male_r1.item(1)); item.male_r1.removeitem(1);}
    else if (item.male_r2.itemcount > 0) {item.low.appenditem(item.male_r2.item(1)); item.male_r2.removeitem(1);}
    else if (item.male_r3.itemcount > 0) {item.low.appenditem(item.male_r3.item(1)); item.male_r3.removeitem(1);}
    else if (item.male_r4.itemcount > 0) {item.low.appenditem(item.male_r4.item(1)); item.male_r4.removeitem(1);}
    else if (item.male_r5.itemcount > 0) {item.low.appenditem(item.male_r5.item(1)); item.male_r5.removeitem(1);}; ]
/ trialduration = 0
</trial>

<item high>
</item>

<item low>
</item>

<page selectionresults>
^'High' item set (<%item.high.itemcount%> items):
^<%item.high.item(1)%>, <%item.high.item(2)%>, <%item.high.item(3)%>, <%item.high.item(4)%>
^^
^'Low' item set (<%item.low.itemcount%> items):
^<%item.low.item(1)%>, <%item.low.item(2)%>, <%item.low.item(3)%>, <%item.low.item(4)%>
</page>



Hi again! Thanks a lot for the advice, and code.

The ratings and sorting into "bins" part seems to work quite nicely, but now it's the CS-US pairings that doesn't work. I would like the script to select 20 CS (from the neutral items, named "mean" in the script below) and pair 10 of them with one positive US and 10 of them with one negative US. Then repeated each pair 5 times. All this is in the "evaluative conditioning" section in the script. 

 The rationale was to start with a trial that randomly selected one CS and one negative (trial CAPic) or positive (trial CBPic) US, save the values taken by item (meanR), and repeat (basically with this procedure : https://www.millisecond.com/forums/Topic16276.aspx)
What I have is : trial 1 : "CS1-US1", then "CS1, US2 (5 times)", "CS1-US3", then "CS1, US2", etc. It seems that the "repeatCA" and repeatCB" trials are completely independent from CAPic and CBPic.

I think I must have missed something while entering the "values" but I can't find what.

<parameters>
/ exposureDuration = 3000
/ csPicSize = 33%
/ ucPicSize = 25%
/ ucFontHeight = 5%
/ defaultFontHeight = 6%
/ defaultPicSize = 33%
/ ITI = 0
</parameters>

**************************************************************************************************************
**************************************************************************************************************
EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**********************************************************************************************************

<item csCPic>
/ 1 = "CFD-LM-204-001-N.jpg"
/ 1 = "CFD-LM-208-110-N.jpg"
....
/ 1 = "CFD-WM-254-152-N.jpg"
/ 1 = "CFD-WM-258-125-N.jpg"
</item>


<item ucAPic>
/ 1 = "1525.bmp"
/ 2 ="2053.bmp"
....
/ 50="9920.bmp"
</item>

<item ucBPic>
/ 1 = "1440.bmp"
/ 2 = "1463.bmp"
...
/ 50= "2791.bmp"
</item>

<item targetPic>
/ 1 = "3210.jpg"
/ 2 = "1390.jpg"
/ 3 = "2272.jpg"
/ 4 = "3302.jpg"
/ 5 = "7920.jpg"
/ 6 = "7031.jpg"
/ 7 = "2230.jpg"
/ 8 = "9401.jpg"
/ 9 = "9210.jpg"
/ 10 = "7110.jpg"
/ 11= "8320.jpg"
/ 12 = "5460.bmp"
/ 13 = "5635.jpg"
/ 14 = "2010.jpg"
/ 15 = "7472.jpg"
/ 16 = "8341.jpg"
/ 17 = "2605.jpg"
/ 18 = "1942.jpg"
/ 19 = "4535.jpg"
/ 20= "8540.bmp"
</item>

<item distractorPic>
/ 1 = "distractor1.jpg"
/ 2 = "distractor2.jpg"
/ 3 = "distractor3.jpg"
/ 4 = "distractor4.jpg"
</item>

**************************************************************************************************************
**************************************************************************************************************
EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<item instructionsEC>
/ 1 = "Vous allez réaliser une tâche de vigilance.

Vous allez voir des images apparaitre à l'écran, seules ou par paires. Votre tâche sera d'identifier et de mémoriser la réponse émotionnelle de l'image cible qui apparaitra à l'écran. Cette image apparaitra à l'écran après les mots 'CIBLE-MEMORISEZ'
Il est important que vous identifier et que vous gardiez ce que cette image vous à évoqué émotionnellement en mémoire. Au bout d'un certain temps, une seconde image cible apparaitra à l'écran.

Votre tâche sera d'appuyer sur la barre d'espace <%expressions.buttoninstruct1%> si la seconde image à la même valence émotionnelle que l'image que vous avez mémorisé.

Si ce n'est pas le cas, ne répondez PAS.

Vous devrez completer un total de 6 blocks d'essais.

Appuyez sur la barre d'espace pour continuer."
/ 2 = "Dans les blocks d'essais suivants, la cible sera l'image suivante.

Quand vous verrez cette image, appuyez sur la barre d'espace <%expressions.buttoninstruct1%> aussi vite que possible.

Si quoi que ce soit d'autre que la cible apparait, ne répondez PAS.

Appuyez sur la barre d'espace pour débuter le block."
</item>

<item targettext>
/ 1 = "CIBLE - MEMORISEZ"
</item>


<expressions>
/buttoninstruct1 = if (computer.touch) {"button";} else {"key";}
</expressions>
**************************************************************************************************************
**************************************************************************************************************
DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/canvasaspectratio = (4,3)
/minimumversion = "5.0.0.0"
/ fontstyle = ("Arial", 5.5%, false, false, false, false, 5, 1)
/txbgcolor = white
/ txcolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
Data columns
**************************************************************************************************************
**************************************************************************************************************

*******************
raw data
*******************

<data>
/separatefiles = true
/ columns = (build computer.platform date time subject group blockcode blocknum values.currentblock trialcode trialnum stimulusitem
stimulusitem stimulusitem response latency)
</data>

*******************
summary data
*******************

<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
expressions.meanRT_targets, expressions.percentcorrect_targets)
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
Automatically updated Task Parameters
**************************************************************************************************************
**************************************************************************************************************
The script also have the following parameters:

/ completed:0 = script was not completed; 1 = script was completed (all conditions run)
/ leftStimPosition-
/ rightStimPosition:determines the screen positions of the left and right items
/ currentBlock:counts the blocks
/ csAPosition:stores the x-coordinate of the CSA
/ csBPosition:stores the x-coordinate of the CSB
/ ucPosition:stores the x-coordinate of the UCS

/sumrt_targets:sums the latencies of correct responses to targets (across blocks)
/count_targets:counts target trials (across blocks)
/countcorrect_targets:counts correct responses to target trials (across blocks)


<values>
/ completed = 0
/ leftStimPosition = 50% - (parameters.defaultPicSize / 2)
/ rightStimPosition = 50 + (parameters.defaultPicSize / 2)
/ currentBlock = 0
/ csAPosition = 0
/ csBPosition = 0
/ ucPosition = 0

/sumrt_targets = 0
/count_targets = 0
/countcorrect_targets = 0
</values>

**************************************************************************************************************
**************************************************************************************************************
Expressions
**************************************************************************************************************
**************************************************************************************************************

<expressions>
/ ucAPosition = if ( values.csAPosition == values.rightStimPosition ) values.leftStimPosition else values.rightStimPosition
/ ucBPosition = if ( values.csAPosition == values.rightStimPosition ) values.leftStimPosition else values.rightStimPosition

/percentcorrect_targets = (values.countcorrect_targets/values.count_targets) * 100
/meanRT_targets = values.sumrt_targets/values.countcorrect_targets
</expressions>


**************************************************************************************************************
**************************************************************************************************************
Pre-ratings
**************************************************************************************************************
**************************************************************************************************************

<block preratings>
/ trials = [1-120=noreplace(csCPicP);
  121=ratingresults; 122=selectCS]
</block>

<likert csCPicP>
/ ontrialend = [if(likert.csCPicP.response=="1")item.csCPicP_r1.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="2")item.csCPicP_r2.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="3")item.csCPicP_r3.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="4")item.csCPicP_r4.item=picture.csCPicP.currentitem]
/ ontrialend = [if(likert.csCPicP.response=="5")item.csCPicP_r5.item=picture.csCPicP.currentitem]
/ stimulusframes = [1=csCPicP,debug]
/ anchorwidth = (4%)
/ position = (50%, 75%)
/ numpoints = 5
/ position = (50, 85)
/ anchors = [1="Très déplaisant"; 5="Très plaisant"]
/ fontstyle = ("Arial", 2%, false, false, false, false, 5, 1)
</likert>



<text debug>
/ items = ("CS rating results:
R1=<%item.csCPicP_r1.itemcount%>|R2=<%item.csCPicP_r2.itemcount%>|R3=<%item.csCPicP_r3.itemcount%>|R4=<%item.csCPicP_r4.itemcount%>|R5=<%item.csCPicP_r5.itemcount%>

")

/ size = (40%, 20%)
/ position = (50%, 10%)
/ erase = false
</text>

<item csCPicP_r1>
</item>

<item csCPicP_r2>
</item>

<item csCPicP_r3>
</item>

<item csCPicP_r4>
</item>

<item csCPicP_r5>
</item>


<trial ratingresults>
/ stimulusframes = [1=debug]
/ validresponse = (57)
/ timeout = 5000
</trial>


<item mean>
</item>

<item ext>
</item>

<page selectionresults>
^'High' item set (<%item.mean.itemcount%> items):
^<%item.mean.item(1)%>, <%item.mean.item(2)%>, <%item.mean.item(3)%>, <%item.mean.item(4)%>
^^
^'Low' item set (<%item.ext.itemcount%> items):
^<%item.ext.item(1)%>, <%item.ext.item(2)%>, <%item.ext.item(3)%>, <%item.ext.item(4)%>
</page>



<list preratings>
</list>

<picture csCPicP>
/ items = csCPic
/ position = (50%, 50%)
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
</picture>

<page instruct>
Rate the pictures
</page>

<trial selectCS>
/ ontrialbegin = [if (item.csCPicP_r3.itemcount > 0) {item.mean.appenditem(item.csCPicP_r3.item(1)); item.csCPicP_r3.removeitem(1);}
  else if (item.csCPicP_r4.itemcount > 0) {item.mean.appenditem(item.csCPicP_r4.item(1)); item.csCPicP_r4.removeitem(1);}
  else if (item.csCPicP_r2.itemcount > 0) {item.mean.appenditem(item.csCPicP_r2.item(1)); item.csCPicP_r2.removeitem(1);}
  else if (item.csCPicP_r5.itemcount > 0) {item.mean.appenditem(item.csCPicP_r5.item(1)); item.csCPicP_r5.removeitem(1);}
  else if (item.csCPicP_r1.itemcount > 0) {item.mean.appenditem(item.csCPicP_r1.item(1)); item.csCPicP_r1.removeitem(1);}; ]
/ trialduration = 0
</trial>
**************************************************************************************************************
**************************************************************************************************************
Stimulus sets, layout, selection
**************************************************************************************************************
**************************************************************************************************************


<picture targetPic>
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
/ items = targetPic
/ select = values.currentBlock
/ erase = false
</picture>


<picture distractorPic>
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
/ items = distractorPic
/ erase = false
</picture>

<shape blank>
/ shape = rectangle
/ size = (parameters.defaultPicSize, parameters.defaultPicSize)
/ color = gray
/ erase = false
</shape>

<list csAPosition>
/ items = (values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition)
/ replace = false
</list>

<list csBPosition>
/ items = (values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.leftStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition, values.rightStimPosition)
/ replace = false
</list>

<text instructionsEC>
/ fontstyle = ("Arial", 3.13%, false, false, false, false, 5, 0)
/ size = (66%, 66%)
/ items = instructionsEC
/ select = 1
</text>

<text blockinstructions>
/ fontstyle = ("Arial", 3.13%, false, false, false, false, 5, 0)
/ position = (50%, 33%)
/ size = (66%, 50%)
/ items = instructionsEC
/ select = 2
</text>

<text targettext>
/ fontstyle = ("Arial", 3.13%, false, false, false, false, 5, 0)
/ position = (50%, 50%)
/ size = (66%, 50%)
/ items = targettext
/ select = 2
</text>

<picture targetinstructions>
/ position = (50%, 66%)
/ size = (33%, 33%)
/ items = targetPic
/ select = values.currentBlock
</picture>

<shape erase>
/ shape = rectangle
/ size = (100%, 100%)
/ color = white
/ erase = false
</shape>



<list randommean>
/ poolsize = 20
</list>

<list randomucBPic>
/ poolsize = 50
</list>

<list randomucAPic>
/ poolsize = 50
</list>

<list repeatmean>
</list>

<list repeatucAPic>
/ selectionmode = list.repeatmean.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.repeatmean.currentindex
</list>


<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.meanR=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucAPic.appenditem(values.ucAPicR);
]
/ stimulustimes = [0=erase; 1=mean, ucAPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial CBPic>
/ ontrialbegin = [
values.csAPosition = list.csBPosition.nextvalue;
values.ucPosition = expressions.ucBPosition;
values.meanR=list.randommean.nextindex; values.ucBPicR=list.randomucBPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucBPic.appenditem(values.ucBPicR);
]
/ stimulustimes = [0=erase; 1= mean, ucbPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>



<trial repeatCA>
/ ontrialbegin = [values.meanR=list.repeatmean.nextvalue; values.ucAPicR=list.repeatucAPic.nextvalue;
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition; ]
/ stimulustimes = [0=erase; 1= meanR, ucAPicR]
/ validresponse = (57)
/ trialduration = parameters.exposureDuration
</trial>


<trial repeatCB>
/ ontrialbegin = [values.meanR=list.repeatmean.nextvalue; values.ucBPicR=list.repeatucBPic.nextvalue;
values.csAPosition = list.csBPosition.nextvalue;
values.ucPosition = expressions.ucBPosition; ]
/ stimulustimes = [0=erase; 1= meanR, ucbPicR]
/ validresponse = (57)
/ trialduration = parameters.exposureDuration
</trial>

<picture meanR>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplace
/ items = mean
</picture>

<picture ucAPicR>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = values.ucAPicR
/ items = ucAPic
</picture>

<picture ucBPicR>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = values.ucBPicR
/ items = ucBPic
</picture>

<values>
/ meanR = 1
/ ucAPicR = 1
/ ucBPicR = 1
</values>

<picture mean>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplace
/ items = mean
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot (ucAPic)
/ items = ucAPic
</picture>

<picture ucBPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot (ucBPic)
/ items = ucBPic
</picture>

<trial instructionsEC>
/ stimulustimes = [1=instructionsEC]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial blockinstructions>
/ stimulustimes = [1=blockinstructions, targetinstructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial mean>
/ stimulusframes = [1=mean]
/ correctresponse = ("D","A")
/ recorddata = true
</trial>

<block instructionsEC>
/ trials = [1=instructionsEC]
</block>


**************************************************************************************************************
**************************************************************************************************************
Trials
**************************************************************************************************************
**************************************************************************************************************

<trial target>
/ ontrialbegin = [values.count_targets += 1]
/ stimulustimes = [0=erase; 16= targettext; 300=targetPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ correctresponse = (" ")
/ ontrialend = [if (trial.target.correct) {values.countcorrect_targets += 1; values.sumrt_targets += trial.target.latency}]
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial distractorPic>
/ stimulustimes = [0=erase, distractorPic]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>

<trial blank>
/ stimulustimes = [0=erase, blank]
/ trialduration = parameters.exposureDuration
/ validresponse = (" ")
/ branch = [if (parameters.ITI > 0) trial.ITI]
</trial>


optional ITI:
<trial ITI>
/ stimulusframes = [1 = erase]
/trialduration = parameters.ITI
/ recorddata = false
</trial>

**************************************************************************************************************
**************************************************************************************************************
Blocks
**************************************************************************************************************
**************************************************************************************************************
The block controls the distribution of trial types. The default settings run a total
of 8 conditioning trials per block, with the rest of the trials divided up between
targets, distractors, and blanks. The ratio of trials, can be changed below.

**************************************************************************************************************
**************************************************************************************************************

<block CA>
/ trials = [1=blockinstructions; 2-8 = CAPic,
repeatCA,repeatCA,repeatCA,repeatCA,repeatCA,
]
</block>

<block CB>
/ trials = [1=blockinstructions; 2-8 = CBPic,
repeatCB,repeatCB,repeatCB,repeatCB,repeatCB
]
</block>



**************************************************************************************************************
**************************************************************************************************************
Contingency Awareness
**************************************************************************************************************
**************************************************************************************************************
<trial instructionsGENERALES>
/ stimulustimes = [1=instructionsGENERALES, instructionsGENERALES, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsGENERALES>
/ items = ("Vous l'aurez peut être remarqué, certaines images étaient présentées en même temps que les images positives ou négatives")
/ size = (500, 70)
/ position = (50, 40)
/ halign = center
/ select = sequence
</text>

<text spacebar>
/ items = ("Appuyez sur la touche ESPACE pour continuer.")
/ position = (50%, 95%)
/ valign = bottom
</text>

<trial instructionsInclusion>
/ stimulustimes = [1=instructionsInclusion]
/ correctresponse = ("S")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsInclusion>
/ items = ("Vous allez maintenant revoir certaines de ces images, et nous vous demanderons, pour chacune d'entre elles d'essayer de vous rappeler si les images qui lui étaient associées étaient agréables ou désagréables.

Vous appuierez sur la touche A lorsque les images étaient agréables et sur la touche D lorsqu'elles étaient désagréables.

Au cas où vous n'arriveriez pas à vous en souvenir, répondez en vous basant sur votre ressenti envers l'image présentée (touche A pour agréable, touche D pour désagréable).

Veuillez appeler l'expérimentateur.")
/ size = (700, 70)
/ position = (50, 20)
/ halign = center
/ select = sequence
</text>

<trial instructionsEntrainement>
/ stimulustimes = [1=instructionsEntrainement, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsEntrainement>
/ items = ("Vous allez maintenant réaliser quelques essais d'entrâinement")
/ size = (500, 70)
/ position = (50, 50)
/ halign = center
/ select = sequence
</text>

<trial instructionsCommencer>
/ stimulustimes = [1=instructionsCommencer, spacebar]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsCommencer>
/ items = ("Nous allons maintenant commencer la tâche")
/ size = (500, 70)
/ position = (50, 50)
/ halign = center
/ select = sequence
</text>

<trial instructionsMerci>
/ stimulustimes = [1=instructionsMerci]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<text instructionsMerci>
/ items = ("Merci de votre participation à cette étude")
/ size = (500, 70)
/ position = (50, 50)
/ halign = center
/ select = sequence
</text>

<item agreableM>
/1= "A si l'image associée était AGREABLE"
</item>

<text agreableM>
/ items = agreableM
/ valign = top
/ halign = left
/ position = (2%, 5%)
/ txcolor = (0, 255, 0)
/ fontstyle = ("Arial", 3%)
</text>

<item desagreableM>
/1= "D si les images associées étaient DESAGREABLES"
</item>

<text desagreableM>
/ items = desagreableM
/ valign = top
/ halign = right
/ position = (98%, 5%)
/ txcolor = (0, 255, 0)
/ fontstyle = ("Arial", 3%)
</text>

<item agreableA>
/1= "A si les images associées étaient AGREABLES, D si elles étaient DESAGREABLES. Si vous ne vous en rappelez pas, A si l'image ci-dessous est DESAGREABLE et D si elle est AGREABLE"
</item>

<text agreableA>
/ items = agreableA
/ valign = top
/ halign = center
/ position = (50%, 5%)
/ txcolor = (0, 255, 0)
/ fontstyle = ("Arial", 2%)
</text>

<block instructionsInclusion>
/ trials = [1=instructionsGENERALES; 2=instructionsInclusion;3=instructionsEntrainement]
</block>

<block Inclusion>
/ bgstim = (agreableM, desagreableM)
/ trials = [1=instructionsCommencer; 2-22= noreplace(mean);23=instructionsMerci]
</block>

**************************************************************************************************************
**************************************************************************************************************
postratings
**************************************************************************************************************
**************************************************************************************************************

<block postratings>
/ preinstructions = (instruct)
/ trials = [1-20 = postratings]
</block>

<likert postratings>
/ stimulusframes = [1=mean]
/ numpoints = 7
</likert>




**************************************************************************************************************
**************************************************************************************************************
Experiment
**************************************************************************************************************
**************************************************************************************************************

<expt EC_Inclusion>
/ blocks = [1=preratings; 2=instructionsEC; 3-12=noreplace(CA,CB); 13=instructionsInclusion; 14=instructionsInclusion; 15=postratings]
</expt>

**************************************************************************************************************
**************************************************************************************************************
End of Script
**************************************************************************************************************
**************************************************************************************************************


I don't understand the thinking here:

You sample a random value between 1 and 20 from list.randommean and store it in values.meanR

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.meanR=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucAPic.appenditem(values.ucAPicR);
]

You then add that value to list.repeatmean

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.meanR=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucAPic.appenditem(values.ucAPicR);
]

which was empty. I.e after adding the value, the list has one item at index 1.

Same for list.randomucAPic / values.ucAPicR and list.repeatucAPic.

However, 

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.meanR=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.meanR); list.repeatucAPic.appenditem(values.ucAPicR);
]
/ stimulustimes = [0=erase; 1=mean, ucAPic]

the actual <picture> elements do not in any way use the randomly sampled value for selection:

<picture mean>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = noreplace
/ items = mean
</picture>

picture.mean just samples randomly without replacement, and I can't figure out what

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = noreplacenot (ucAPic)
/ items = ucAPic
</picture>

the circular constrained selection in picture.ucapic is supposed to do: It translates to "sample randomly without replacement from picture.ucapic's items, but *not* the item selected in picture.ucapic." On its face, that doesn't make any sense to me. Please explain.

I reused the script used here : https://www.millisecond.com/forums/Topic16276.aspx as it seemed that the problem was similar (although I'm not sure I understood the reasoning behind the script). I'll try to reformulate to see if I understood what's wrong.

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.mean=list.randommean.nextindex; values.ucAPic=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.mean); list.repeatucAPic.appenditem(values.ucAPic);
]

sampling a random value from mean and put it in mean. Let's drop "meanR" as it doesn't seem to be necessary.

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.mean=list.randommean.nextindex; values.ucAPic=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.mean); list.repeatucAPic.appenditem(values.ucAPic);
]

<trial CAPic>
/ ontrialbegin = [
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition;
values.mean=list.randommean.nextindex; values.ucAPicR=list.randomucAPic.nextindex;
list.repeatmean.appenditem(values.mean); list.repeatucAPic.appenditem(values.ucAPic);
]
/ stimulustimes = [0=erase; 1=mean, ucAPic]

<picture mean>
/ size = (parameters.csPicSize, parameters.csPicSize)
/ hposition = values.csAPosition
/ erase = false
/ select = values.mean
/ items = mean
</picture>

<picture ucAPic>
/ size = (parameters.ucPicSize, parameters.ucPicSize)
/ hposition = values.ucPosition
/ erase = false
/ select = values.ucAPic
/ items = ucAPic
</picture>

Here, the picture element select the item stored in values.mean/values.ucAPic

and for the repeated trials, the expression "repeatmean" retrieves the item in "values.item"

<trial repeatCA>
/ ontrialbegin = [values.mean=list.repeatmean.nextvalue; values.ucAPic=list.repeatucAPic.nextvalue;
values.csAPosition = list.csAPosition.nextvalue;
values.ucPosition = expressions.ucAPosition; ]
/ stimulustimes = [0=erase; 1= meanR, ucAPicR]
/ validresponse = (57)
/ trialduration = parameters.exposureDuration
</trial>

<list repeatucAPic>
/ selectionmode = list.mean.currentindex
</list>

<list repeatucBPic>
/ selectionmode = list.mean.currentindex
</list>

But still not sure of what to put in the "list repeatucBPic" element


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search