Millisecond Forums

Mean recall duration in summary (letter memory task)

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

By cyril.forestier - 11/10/2020

Dear all,
I'd like your help because after several test, I didn't succeeded at calculate a mean duration on the summary.

More precisely, I am using the Letter Memory task that exists on the Milliseconds library. I didn't change the code. A screenshot of the raw data is attached.
 

In this task, participants have some letters to memorize, and then they are on a page where they can report the last letters they memorized. I am interested in the latency of this last action, i.e., the time people take to report the last letters they memorized, and then clik to "next". Inquisit already calculate the latency for each trial where participants do this process, you can see it on the picture under the name "recallDuration" (column). 
On the original script, it seems that this latency is already calculate with these two part (A and B) of the code. 

I tried to code that inquisit include in the summary a the mean of all latencies  that are on the column "recallDuration" when the trial code is "recall_end" (because the rest of the time it reports NA, because participants only look at letters, there is no response latency), but it didn't works. I geta value on the summary, but this value is not the mean of the 12 recalls durations ... 
I tried different version with "recall_end" or "recallDuration" but never found the correct command ...

The last code I tried is below (part C), could you please help me to correct it so I can get this value ? 

Let me know if anything is not clear enough, or if you have questions.
Best regards,

Cyril

CODE

A)
<trial recall_letter>
/ ontrialbegin = [
    values.last3 = substring(values.presentedLetters, length(values.presentedLetters) - 3, 3);
    values.recallCount += 1;
    if (values.recallCount == 1){
        values.RecallStart = script.elapsedtime;
    };
]
/ stimulusframes = [1=WhiteScreen, B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z, _, clear, exit, recalledletters, recallprompt]
/ validresponse = (B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z, _, clear, exit)
/ monkeyresponse = ("B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z", "exit")
/ ontrialend = [
    if(trial.recall_letter.response!="exit" && trial.recall_letter.response!="clear") {
        values.recalledletters=concat(values.recalledletters, trial.recall_letter.response);
        values.recalledletters = substring(values.recalledletters, 0, 3);
    };
    if(trial.recall_letter.response=="clear") {
        values.recalledletters="";
    };
    if (trial.recall_letter.response == "exit"){
        values.RecallEnd = script.elapsedtime;
    };
]

B)
<trial recall_end>
/ ontrialbegin = [
    values.recallDuration = values.RecallEnd - values.RecallStart;
    values.temp_last3 = values.last3;
        
    values.recalledletters = concat(values.recalledletters, " ");
    if (contains(values.temp_last3, substring(values.recalledletters, 0, 1))){
        values.countCorrectLetters += 1;
        values.temp_last3 = replaceall(values.temp_last3, substring(values.recalledletters, 0, 1), "");
    };
    if (contains(values.temp_last3, substring(values.recalledletters, 1, 1))){
        values.countCorrectLetters += 1;
        values.temp_last3 = replaceall(values.temp_last3, substring(values.recalledletters, 1, 1), "");
    };    
    if (contains(values.temp_last3, substring(values.recalledletters, 2, 1))){
        values.countCorrectLetters += 1;
        values.temp_last3 = replaceall(values.temp_last3, substring(values.recalledletters, 2, 1), "");
    };    

    list.correctLetters.insertitem(values.countCorrectLetters, 1);
    
    if (values.countCorrectLetters != 3){
        trial.recall_end.insertstimulusframe(text.errorFeedback, 1);
        values.ACC = 0;        
    } else {
        trial.recall_end.insertstimulusframe(text.correctFeedback, 1);
        values.ACC = 1;
    };
    list.accuracy.insertitem(values.ACC, 1);
]
/ stimulusframes = [1 = clearscreen, continue]
/ validresponse = (continue)
/ recorddata = true
/ posttrialpause = parameters.ITI
</trial>


C)
***********************
summary data file
***********************
<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
expressions.propCorrect, expressions.mean_correctLetters, trial.recall_end.meanlatency)
/ separatefiles = true
</summarydata>
By Dave - 11/10/2020

cyril.forestier - 11/10/2020
Dear all,
I'd like your help because after several test, I didn't succeeded at calculate a mean duration on the summary.

More precisely, I am using the Letter Memory task that exists on the Milliseconds library. I didn't change the code. A screenshot of the raw data is attached.
 

In this task, participants have some letters to memorize, and then they are on a page where they can report the last letters they memorized. I am interested in the latency of this last action, i.e., the time people take to report the last letters they memorized, and then clik to "next". Inquisit already calculate the latency for each trial where participants do this process, you can see it on the picture under the name "recallDuration" (column). 
On the original script, it seems that this latency is already calculate with these two part (A and B) of the code. 

I tried to code that inquisit include in the summary a the mean of all latencies  that are on the column "recallDuration" when the trial code is "recall_end" (because the rest of the time it reports NA, because participants only look at letters, there is no response latency), but it didn't works. I geta value on the summary, but this value is not the mean of the 12 recalls durations ... 
I tried different version with "recall_end" or "recallDuration" but never found the correct command ...

The last code I tried is below (part C), could you please help me to correct it so I can get this value ? 

Let me know if anything is not clear enough, or if you have questions.
Best regards,

Cyril

CODE

A)
<trial recall_letter>
/ ontrialbegin = [
    values.last3 = substring(values.presentedLetters, length(values.presentedLetters) - 3, 3);
    values.recallCount += 1;
    if (values.recallCount == 1){
        values.RecallStart = script.elapsedtime;
    };
]
/ stimulusframes = [1=WhiteScreen, B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z, _, clear, exit, recalledletters, recallprompt]
/ validresponse = (B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z, _, clear, exit)
/ monkeyresponse = ("B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z", "exit")
/ ontrialend = [
    if(trial.recall_letter.response!="exit" && trial.recall_letter.response!="clear") {
        values.recalledletters=concat(values.recalledletters, trial.recall_letter.response);
        values.recalledletters = substring(values.recalledletters, 0, 3);
    };
    if(trial.recall_letter.response=="clear") {
        values.recalledletters="";
    };
    if (trial.recall_letter.response == "exit"){
        values.RecallEnd = script.elapsedtime;
    };
]

B)
<trial recall_end>
/ ontrialbegin = [
    values.recallDuration = values.RecallEnd - values.RecallStart;
    values.temp_last3 = values.last3;
        
    values.recalledletters = concat(values.recalledletters, " ");
    if (contains(values.temp_last3, substring(values.recalledletters, 0, 1))){
        values.countCorrectLetters += 1;
        values.temp_last3 = replaceall(values.temp_last3, substring(values.recalledletters, 0, 1), "");
    };
    if (contains(values.temp_last3, substring(values.recalledletters, 1, 1))){
        values.countCorrectLetters += 1;
        values.temp_last3 = replaceall(values.temp_last3, substring(values.recalledletters, 1, 1), "");
    };    
    if (contains(values.temp_last3, substring(values.recalledletters, 2, 1))){
        values.countCorrectLetters += 1;
        values.temp_last3 = replaceall(values.temp_last3, substring(values.recalledletters, 2, 1), "");
    };    

    list.correctLetters.insertitem(values.countCorrectLetters, 1);
    
    if (values.countCorrectLetters != 3){
        trial.recall_end.insertstimulusframe(text.errorFeedback, 1);
        values.ACC = 0;        
    } else {
        trial.recall_end.insertstimulusframe(text.correctFeedback, 1);
        values.ACC = 1;
    };
    list.accuracy.insertitem(values.ACC, 1);
]
/ stimulusframes = [1 = clearscreen, continue]
/ validresponse = (continue)
/ recorddata = true
/ posttrialpause = parameters.ITI
</trial>


C)
***********************
summary data file
***********************
<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
expressions.propCorrect, expressions.mean_correctLetters, trial.recall_end.meanlatency)
/ separatefiles = true
</summarydata>

Create a <list>:

<list recall_durations>
</list>

In <trial recall_end>, add values.recallDuration to the list

<trial recall_end>
...
/ ontrialend = [list.recall_durations.appenditem(values.recallDuration)]
...
</trial>

You don't want to include the practtice trials in the calculation of the mean, so reset the list at the start of the test block:

<block lettermemory>
/ preinstructions = (testIntro)
/ onblockbegin = [
    list.correctLetters.reset();
    list.accuracy.reset();
    list.recall_durations.reset();
]
/ trials = [1-12 = sequence(fixation, show_letter, recall_letter)]
</block>

Finally, log the list's mean to the summary file.

<summarydata>
/columns = (script.startdate, ..., list.recall_durations.mean)
/ separatefiles = true
</summarydata>