list means not being assigned to values halfway through


Author
Message
pops
pops
Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)
Group: Forum Members
Posts: 69, Visits: 85
Hi not sure what I am doing wrong but I have some values=0 defined at the start of my experiment and I have some empty lists. On each trial accuracy and RT data are appended to the relevant lists. Half way through I wish to take the means of the lists, assign them to the values and then reset the lists to be empty before continuing with the second half of the experiment. At the end I use expressions to calculate means from the lists again and save both the final expression output and the half way values into the summary data file. But the values are never updating. Something like this:

<values>
/ overallpropcorrect_Before = 0
/ meanRT_correct_Before = 0
</values>

<expressions>
/ overallpropcorrect_After = list.ACC.mean
/ meanRT_correct_After = list.RT.mean
</expressions>

<list ACC>
</list>

<list RT>
</list>

<trial cond1>
....
/ ontrialend = [
   list.ACC.appenditem(values.correct);
if (values.correct == 1) {
        list.RT.appenditem(values.rt);}]
</trial>


<block trialBlock>
/ trials = [1 = blockinfo; 2-8 = noreplace(cond1, cond2, cond3)]
</block>

<block halfway>
/onblockbegin = [
values.overallpropcorrect_Before = list.ACC.mean
values.meanRT_correct_Before = list.RT.mean]
/trials = [instr1, instr2]
/onblockend = [
list.ACC.reset();
list.RT.reset()]
</block>

<summarydata>
/ columns = (......
values.overallpropcorrect_Before, values.meanRT_correct_Before, expressions.overallpropcorrect_After, expressions.meanRT_correct_After)
</summarydata>

<expt >
/ blocks = [
    1-2 = trialBlock;
    5 = halfway;
    6-7 = trialBlock]
</expt>

The documentation makes it sound like anytime list.x.mean is called that it should calculate the mean so I don't understand why it is not assigning it to the value at the halfway. I added the values to the regular datafile but they remain at 0 on every trial, even during the halfway blocks. I realise that I could just duplicate all the lists and all the expressions but there are a lot of them so I would rather just assign the means of the lists to the values half way through and then reset them...

Any thoughts appreciated!

Thank you






Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 105K
pops - 6/23/2023
Hi not sure what I am doing wrong but I have some values=0 defined at the start of my experiment and I have some empty lists. On each trial accuracy and RT data are appended to the relevant lists. Half way through I wish to take the means of the lists, assign them to the values and then reset the lists to be empty before continuing with the second half of the experiment. At the end I use expressions to calculate means from the lists again and save both the final expression output and the half way values into the summary data file. But the values are never updating. Something like this:

<values>
/ overallpropcorrect_Before = 0
/ meanRT_correct_Before = 0
</values>

<expressions>
/ overallpropcorrect_After = list.ACC.mean
/ meanRT_correct_After = list.RT.mean
</expressions>

<list ACC>
</list>

<list RT>
</list>

<trial cond1>
....
/ ontrialend = [
   list.ACC.appenditem(values.correct);
if (values.correct == 1) {
        list.RT.appenditem(values.rt);}]
</trial>


<block trialBlock>
/ trials = [1 = blockinfo; 2-8 = noreplace(cond1, cond2, cond3)]
</block>

<block halfway>
/onblockbegin = [
values.overallpropcorrect_Before = list.ACC.mean
values.meanRT_correct_Before = list.RT.mean]
/trials = [instr1, instr2]
/onblockend = [
list.ACC.reset();
list.RT.reset()]
</block>

<summarydata>
/ columns = (......
values.overallpropcorrect_Before, values.meanRT_correct_Before, expressions.overallpropcorrect_After, expressions.meanRT_correct_After)
</summarydata>

<expt >
/ blocks = [
    1-2 = trialBlock;
    5 = halfway;
    6-7 = trialBlock]
</expt>

The documentation makes it sound like anytime list.x.mean is called that it should calculate the mean so I don't understand why it is not assigning it to the value at the halfway. I added the values to the regular datafile but they remain at 0 on every trial, even during the halfway blocks. I realise that I could just duplicate all the lists and all the expressions but there are a lot of them so I would rather just assign the means of the lists to the values half way through and then reset them...

Any thoughts appreciated!

Thank you






Can you provide some actually runnable code, not an incomplete snippet where it's not possible to see or reproduce what's going on?

Thanks.
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 105K
Dave - 6/23/2023
pops - 6/23/2023
Hi not sure what I am doing wrong but I have some values=0 defined at the start of my experiment and I have some empty lists. On each trial accuracy and RT data are appended to the relevant lists. Half way through I wish to take the means of the lists, assign them to the values and then reset the lists to be empty before continuing with the second half of the experiment. At the end I use expressions to calculate means from the lists again and save both the final expression output and the half way values into the summary data file. But the values are never updating. Something like this:

<values>
/ overallpropcorrect_Before = 0
/ meanRT_correct_Before = 0
</values>

<expressions>
/ overallpropcorrect_After = list.ACC.mean
/ meanRT_correct_After = list.RT.mean
</expressions>

<list ACC>
</list>

<list RT>
</list>

<trial cond1>
....
/ ontrialend = [
   list.ACC.appenditem(values.correct);
if (values.correct == 1) {
        list.RT.appenditem(values.rt);}]
</trial>


<block trialBlock>
/ trials = [1 = blockinfo; 2-8 = noreplace(cond1, cond2, cond3)]
</block>

<block halfway>
/onblockbegin = [
values.overallpropcorrect_Before = list.ACC.mean
values.meanRT_correct_Before = list.RT.mean]
/trials = [instr1, instr2]
/onblockend = [
list.ACC.reset();
list.RT.reset()]
</block>

<summarydata>
/ columns = (......
values.overallpropcorrect_Before, values.meanRT_correct_Before, expressions.overallpropcorrect_After, expressions.meanRT_correct_After)
</summarydata>

<expt >
/ blocks = [
    1-2 = trialBlock;
    5 = halfway;
    6-7 = trialBlock]
</expt>

The documentation makes it sound like anytime list.x.mean is called that it should calculate the mean so I don't understand why it is not assigning it to the value at the halfway. I added the values to the regular datafile but they remain at 0 on every trial, even during the halfway blocks. I realise that I could just duplicate all the lists and all the expressions but there are a lot of them so I would rather just assign the means of the lists to the values half way through and then reset them...

Any thoughts appreciated!

Thank you






Can you provide some actually runnable code, not an incomplete snippet where it's not possible to see or reproduce what's going on?

Thanks.

Assuming the below snippet you shared is an accurate representation of what you have, then you are missing statement separators:

<block halfway>
/onblockbegin = [
values.overallpropcorrect_Before = list.ACC.mean
values.meanRT_correct_Before = list.RT.mean
]
....
</block>

This ought to be

/onblockbegin = [
values.overallpropcorrect_Before = list.ACC.mean;
values.meanRT_correct_Before = list.RT.mean]

Since you've obviously edited the snippets, however, it's impossible to say whether that issue exists in the actual code or whether you've just deletd the semicolon while editing the snippet.

For what it's worth, however,

<expt myexpt>
/ blocks = [
    1-2 = trialBlock;
    3 = halfway;
    4-5 = trialBlock;
    ]
</expt>

<list RT>
</list>

<list ACC>
</list>

<values>
/ rt = 0
/ correct = 0

/ rt_pre = 0
/ acc_pre = 0
</values>

<expressions>
/ rt_post = list.RT.mean
/ acc_post = list.ACC.mean
</expressions>

<block trialBlock>
/ trials = [1-9 = noreplace(a, b, c)]
</block>

<block halfway>
/ onblockbegin = [
    values.rt_pre = list.RT.mean;
    values.acc_pre = list.ACC.mean;
]
/ trials = [1=halfwaytrial]

/ onblockend = [
    list.RT.reset();
    list.ACC.reset();
]
</block>

<trial halfwaytrial>
/ stimulusframes = [1=mytext]
/ trialduration = 500
/ validresponse = (0)
</trial>


<trial a>
/ stimulusframes = [1=mytext]
/ validresponse = ("a", "b", "c")
/ correctresponse = ("a")
/ ontrialend = [
    values.rt = trial.a.latency;
    values.correct = trial.a.correct;
    list.ACC.appenditem(values.correct);
    if (values.correct == 1) {
        list.RT.appenditem(values.rt);
    }
]
</trial>

<trial b>
/ stimulusframes = [1=mytext]
/ validresponse = ("a", "b", "c")
/ correctresponse = ("b")
/ ontrialend = [
    values.rt = trial.b.latency;
    values.correct = trial.b.correct;
    list.ACC.appenditem(values.correct);
    if (values.correct == 1) {
        list.RT.appenditem(values.rt);
    }
]
</trial>

<trial c>
/ stimulusframes = [1=mytext]
/ validresponse = ("a", "b", "c")
/ correctresponse = ("c")
/ ontrialend = [
    values.rt = trial.c.latency;
    values.correct = trial.c.correct;
    list.ACC.appenditem(values.correct);
    if (values.correct == 1) {
        list.RT.appenditem(values.rt);
    }
]
</trial>

<text mytext>
/ items = ("<%script.currenttrial%>")
</text>

<data>
/ columns = (date time subject group session blocknum blockcode trialnum trialcode response latency correct
    values.rt values.correct values.rt_pre values.acc_pre expressions.rt_post expressions.acc_post)
</data>

<summarydata>
/ columns = (script.startdate script.starttime script.subjectid script.groupid script.sessionid
    values.rt_pre values.acc_pre expressions.rt_post expressions.acc_post)
</summarydata>


works perfectly fine. (It does not matter whether you log the expressions etc. to the raw data, remove the <data> element if you want to, the result will still be the same. Logging that information just makes it easy to see that things actually do work as expected.)

pops
pops
Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)
Group: Forum Members
Posts: 69, Visits: 85
Thanks Dave, the typos you spotted above (missing the ; in between the statements) were indeed the problem!! All working fine now. Thanks for your help as always :)

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search