List element_item selection


Author
Message
pawelstrojny
pawelstrojny
Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)
Group: Forum Members
Posts: 43, Visits: 76
I need to program script which will display random images (defined in the list element), I have three different images to display in random order (repeated 40 times). I know how to program up to this point.
What I don't know is how to define list (or another part of the script) to select items randomly but in the way which provides me fixed proportion of items at the end of each trial - in other words I need to select items randomly from 3 items 40 times but at the end I need to have 20 displays of item #1, 10 of #2 and 10 of #3 (50%, 25% and 25%)
I am aware of / itemprobabilities command but if I understand it correctly, it does not secure the proportion at the end - only the probability of selecting given item.

Is the "list" element proper for my goal?

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
The list element is perfectly fine for that.

<block myblock>
/ trials = [1-40=mytrial]
</block>

<trial mytrial>
/ ontrialbegin = [values.myvalue=list.mylist.nextvalue]
/ trialduration = 10
</trial>

<list mylist>
/ items = ("A", "B", "C")
/ poolsize = 40
/ itemprobabilities = (.50; .25; .25)
</list>

<values>
/ myvalue = ""
</values>

<data>
/ columns = [trialnum, values.myvalue]
</data>


Will give you exactly 20 x A, 10 x B and 10 x C.

pawelstrojny
pawelstrojny
Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)
Group: Forum Members
Posts: 43, Visits: 76
Thank You Dave.

What if I want to divide probability among 12 items and set poolsize to 36? I want to have equal probability for every item - should I type: / itemprobabilities = (.083; .083; .083...).

In that case probabilities set doesn't sum to 100, additionally I'm not sure whether script will be smart enough to display every item exactly three times.

Is there a problem with any of those issues?

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
If you want each item to be sampled equally often, you don't need to do anything beyond defining the poolsize.

<list mylist>
/ items = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L")
/ poolsize = 36
</list>

Each item will be sampled 3 times.

pawelstrojny
pawelstrojny
Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)
Group: Forum Members
Posts: 43, Visits: 76
Thank you for your help, I guess I still have some problem, probably I'm doing some simple mistake in the trial element, maybe you could have a look?

Basically I want to display series of stimuli and ask participants to answer whether the picture contains specific element (shape) or not by pressing a key.
I have 12 different graphic files (e.g. Circle made of Triangles and so on) and I want them to be displayed randomly.
My script doesn't identify mistakes during validation (F7), but while I want to run the procedure, it always displays only one picture (item # 1).
Maybe you could help me?

I used four "list" elements like you suggested:
<list stimitemnumber_CircleCondition>
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/ itemprobabilities = (.083, .083, .083, .083, .083, .083, .083, .083, .083, .083, .083, .083)
/ poolsize = 36
/replace = false
/resetinterval = 1
</list>

<list stimitemnumber_TriangleCondition>
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/ itemprobabilities = (.083, .083, .083, .083, .083, .083, .083, .083, .083, .083, .083, .083)
/ poolsize = 36
/replace = false
/resetinterval = 1
</list>

<list stimitemnumber_DiamondCondition>
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/ itemprobabilities = (.083, .083, .083, .083, .083, .083, .083, .083, .083, .083, .083, .083)
/ poolsize = 36
/replace = false
/resetinterval = 1
</list>

<list stimitemnumber_SquareCondition>
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/ itemprobabilities = (.083, .083, .083, .083, .083, .083, .083, .083, .083, .083, .083, .083)
/ poolsize = 36
/replace = false
/resetinterval = 1
</list>
Then I used "trial" element:

<trial main>
/ontrialbegin = [values.counttrials += 1]

/ontrialbegin = [if (values.condition ==1) values.stim = list.stimitemnumber_Circlecondition.nextvalue || 
                if (values.condition ==2) values.stim = list.stimitemnumber_Squarecondition.nextvalue ||
                if (values.condition ==3) values.stim = list.stimitemnumber_Diamondcondition.nextvalue ||
                if (values.condition ==4) values.stim = list.stimitemnumber_Trianglecondition.nextvalue]


/ontrialbegin = [trial.main.insertstimulustime(shape.eraser, values.fixationduration)]
/ontrialbegin = [trial.main.insertstimulustime(picture.target, values.fixationduration)]
/ontrialbegin = [trial.main.insertstimulustime(picture.mask, (values.fixationduration + values.stimulusduration))]
/ontrialend = [trial.main.resetstimulusframes()]
/stimulustimes = [0 = fixation, signal]
/beginresponsetime = (values.fixationduration)
/responseinterrupt = immediate
/isvalidresponse = [trial.main.response == values.responsekey1 || trial.main.response == values.responsekey2]
/monkeyresponse = (44, 50)

/iscorrectresponse = [(values.condition == 1 && (values.stim == 4 || values.stim == 5 || values.stim == 6 ||values.stim == 7 || values.stim == 10 || values.stim == 1) && trial.main.response == values.responsekey1) ||
                        (values.condition == 1 && (values.stim == 2 || values.stim == 3 || values.stim == 8 ||values.stim == 9 || values.stim == 11 || values.stim == 12) && trial.main.response == values.responsekey2) ||

                        (values.condition == 2 && (values.stim == 2 || values.stim == 5 || values.stim == 8 ||values.stim == 10 || values.stim == 11 || values.stim == 12) && trial.main.response == values.responsekey1) ||
                        (values.condition == 2 && (values.stim == 1 || values.stim == 3 || values.stim == 4 ||values.stim == 6 || values.stim == 7 || values.stim == 9) && trial.main.response == values.responsekey2) ||
                       
                        (values.condition == 3 && (values.stim == 3 || values.stim == 6 || values.stim == 7 ||values.stim == 8 || values.stim == 9 || values.stim == 11) && trial.main.response == values.responsekey1) ||
                        (values.condition == 3 && (values.stim == 1 || values.stim == 2 || values.stim == 4 ||values.stim == 5 || values.stim == 10 || values.stim == 12) && trial.main.response == values.responsekey2) ||
                       
                        (values.condition == 4 && (values.stim == 1 || values.stim == 2 || values.stim == 3 ||values.stim == 4 || values.stim == 9 || values.stim == 12) && trial.main.response == values.responsekey1) ||
                        (values.condition == 4 && (values.stim == 5 || values.stim == 6 || values.stim == 7 ||values.stim == 8 || values.stim == 10 || values.stim == 11) && trial.main.response == values.responsekey2) ||]

/ontrialend = [values.stimulus = picture.target.currentitem]
/ontrialend = [if (values.stim == 1 || values.stim == 2 || values.stim == 3) values.big = "triangle"]
/ontrialend = [if (values.stim == 4 || values.stim == 9 || values.stim == 12) values.small = "triangle"]

/ontrialend = [if (values.stim == 4 || values.stim == 5 || values.stim == 6) values.big = "circle"]
/ontrialend = [if (values.stim == 1 || values.stim == 7 || values.stim == 10) values.small = "circle"]

/ontrialend = [if (values.stim == 7 || values.stim == 8 || values.stim == 9) values.big = "diamond"]
/ontrialend = [if (values.stim == 3 || values.stim == 6 || values.stim == 11) values.small = "diamond"]

/ontrialend = [if (values.stim == 10 || values.stim == 11 || values.stim == 12) values.big = "square"]
/ontrialend = [if (values.stim == 2 || values.stim == 5 || values.stim == 8) values.small = "square"]

/ontrialend = [if (values.condition == 1 && values.phase == "test" && trial.main.correct && values.big == "circle") {               
                                                values.count_circle_big += 1;
                                                values.sumRT_circle_big += trial.main.latency;
                                                values.count_big += 1;
                                                values.sumRT_big += trial.main.latency}]
/ontrialend = [if (values.condition == 1 && values.phase == "test" && trial.main.correct && values.small == "circle") {               
                                                values.count_circle_small += 1;
                                                values.sumRT_circle_small += trial.main.latency;
                                                values.count_small += 1;
                                                values.sumRT_small += trial.main.latency}]

/ontrialend = [if (values.condition == 2 && values.phase == "test" && trial.main.correct && values.big == "square") {               
                                                values.count_square_big += 1;
                                                values.sumRT_square_big += trial.main.latency;
                                                values.count_big += 1;
                                                values.sumRT_big += trial.main.latency}]
/ontrialend = [if (values.condition == 2 && values.phase == "test" && trial.main.correct && values.small == "square") {               
                                                values.count_square_small += 1;
                                                values.sumRT_square_small += trial.main.latency;
                                                values.count_small += 1;
                                                values.sumRT_small += trial.main.latency}]

/ontrialend = [if (values.condition == 3 && values.phase == "test" && trial.main.correct && values.big == "diamond") {               
                                                values.count_diamond_big += 1;
                                                values.sumRT_diamond_big += trial.main.latency;
                                                values.count_big += 1;
                                                values.sumRT_big += trial.main.latency}]
/ontrialend = [if (values.condition == 3 && values.phase == "test" && trial.main.correct && values.small == "diamond") {               
                                                values.count_diamond_small += 1;
                                                values.sumRT_diamond_small += trial.main.latency;
                                                values.count_small += 1;
                                                values.sumRT_small += trial.main.latency}]

/ontrialend = [if (values.condition == 4 && values.phase == "test" && trial.main.correct && values.big == "triangle") {               
                                                values.count_triangle_big += 1;
                                                values.sumRT_triangle_big += trial.main.latency;
                                                values.count_big += 1;
                                                values.sumRT_big += trial.main.latency}]
/ontrialend = [if (values.condition == 4 && values.phase == "test" && trial.main.correct && values.small == "triangle") {               
                                                values.count_triangle_small += 1;
                                                values.sumRT_triangle_small += trial.main.latency;
                                                values.count_small += 1;
                                                values.sumRT_small += trial.main.latency}]

/posttrialpause = values.iti
/recorddata = true
</trial>

I have basic value of "stim" set as "0"


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
The code excerpt you provide is too incomplete to tell you everything that may be wrong. Put the script and required external files (pictures, etc.) in a ZIP archive and attach it to this thread. Better yet, instead of posting the full script, provide a self-contained, runnable short version that *only* contains the part you are having trouble with.

What I can already tell you based on the snippets you provided is that

/ontrialbegin = [if (values.condition ==1) values.stim = list.stimitemnumber_Circlecondition.nextvalue || 
                if (values.condition ==2) values.stim = list.stimitemnumber_Squarecondition.nextvalue ||
                if (values.condition ==3) values.stim = list.stimitemnumber_Diamondcondition.nextvalue ||
                if (values.condition ==4) values.stim = list.stimitemnumber_Trianglecondition.nextvalue]

is *not* valid syntax. You need to use the proper if ... else if ... construct, not the OR operator ( || ).

pawelstrojny
pawelstrojny
Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)Guru (6.4K reputation)
Group: Forum Members
Posts: 43, Visits: 76
Sure, please find the script attached. I have no graphip files yet, thats why I use pictures with text - name of file whish is going to be used, e.g. Ct means that it will be big Circle made of small Triangles.

Could you tell me where is the problem?

Attachments
Navon_Tanetal2009Version.rar (581 views, 220.00 KB)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
As I already detailed in my previous reply, parts of your /ontrialbegin syntax in <trial main> is broken. The part I highlighted ought to read

/ontrialbegin = [if (values.condition ==1) {values.stim = list.stimitemnumber_Circlecondition.nextvalue}
                else if (values.condition ==2) {values.stim = list.stimitemnumber_Squarecondition.nextvalue}
                else if (values.condition ==3) {values.stim = list.stimitemnumber_Diamondcondition.nextvalue}
                else if (values.condition ==4) {values.stim = list.stimitemnumber_Trianglecondition.nextvalue}]

i.e., you need to use the proper if... else if construct, use of the logical OR || is inappropriate. It is still broken in the script version you attached.

Something similar is true for the trial's /iscorrectresponse syntax, which fails to evaluate at runtime

/iscorrectresponse = [(values.condition == 1 && (values.stim == 4 || values.stim == 5 || values.stim == 6 ||values.stim == 7 || values.stim == 10 || values.stim == 1) && trial.main.response == values.responsekey1) ||
                        (values.condition == 1 && (values.stim == 2 || values.stim == 3 || values.stim == 8 ||values.stim == 9 || values.stim == 11 || values.stim == 12) && trial.main.response == values.responsekey2) ||

                        (values.condition == 2 && (values.stim == 2 || values.stim == 5 || values.stim == 8 ||values.stim == 10 || values.stim == 11 || values.stim == 12) && trial.main.response == values.responsekey1) ||
                        (values.condition == 2 && (values.stim == 1 || values.stim == 3 || values.stim == 4 ||values.stim == 6 || values.stim == 7 || values.stim == 9) && trial.main.response == values.responsekey2) ||
                       
                        (values.condition == 3 && (values.stim == 3 || values.stim == 6 || values.stim == 7 ||values.stim == 8 || values.stim == 9 || values.stim == 11) && trial.main.response == values.responsekey1) ||
                        (values.condition == 3 && (values.stim == 1 || values.stim == 2 || values.stim == 4 ||values.stim == 5 || values.stim == 10 || values.stim == 12) && trial.main.response == values.responsekey2) ||
                       
                        (values.condition == 4 && (values.stim == 1 || values.stim == 2 || values.stim == 3 ||values.stim == 4 || values.stim == 9 || values.stim == 12) && trial.main.response == values.responsekey1) ||
                        (values.condition == 4 && (values.stim == 5 || values.stim == 6 || values.stim == 7 ||values.stim == 8 || values.stim == 10 || values.stim == 11) && trial.main.response == values.responsekey2) ||]

with

Error evaluating '(values.condition == 1 && (values.stim == 4 || values.stim == 5 || values.stim == 6 ||values.stim == 7 || values.stim == 10 || values.stim == 1) && trial.main.response == values.responsekey1) || ... ': Unknown error.

I am not quite sure what exactly /iscorrectresponse is supposed to achieve as stated, so I cannot necessarily offer a correction. At the very least, though, the trailing || operator (enlarged above) needs to be removed.

Once you correct those errors, the item selection should work fine.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search