Off-by-one error when setting correctresponse and getitem via value


Author
Message
Jack S.
Jack S.
Partner Member (573 reputation)Partner Member (573 reputation)Partner Member (573 reputation)Partner Member (573 reputation)Partner Member (573 reputation)Partner Member (573 reputation)Partner Member (573 reputation)Partner Member (573 reputation)Partner Member (573 reputation)
Group: Forum Members
Posts: 8, Visits: 99
Hello all,

I'm creating a modified version of the Digit Symbol Substitution Task in which the symbols are displayed one at a time (rather than in a large grid, as in the more common implementation of the task). At the beginning of each trial, the script selects a random value between 1 and 9, which determines both what symbol to display and what answer is correct for that trial. The problem I'm encountering is that the correct response seems to be off by one; i.e., if the random value is 5, the 5th symbol is displayed (confirmed via debug window), but "4" is treated as the correct answer. Even more confusingly, in trial data from monkey mode, the problem seems to disappear; if a trial's random value is 7, then a response of "7" is coded as correct.

 Any idea what might be causing this? I've included my code below; the problem is easiest to spot if you run the digit_sub_practice block. Please let me know if I can provide any additional info!


****************************
PARAMETERS/VALUES
****************************

<parameters>
/substitution_post_stim_pause = 100
/substitution_feedback_duration = 500
</parameters>

<values>
/trialtype = ""
/substitution_complete = 0
/task_order = 99
</values>

Symbol to display is determined by current_symbol, which is set randomly at start of each trial.

<values>
/ current_symbol = ""
/ total_digit_sub_trials = 0
</values>


********************
SYMBOL RANDOMIZATION
********************

A list to select which of the nine symbols to display, and thus determine which answer is correct:

<list random_pick>
/ items = (1-9)
/ select = random
/ resetinterval = 1
</list>


The symbols themselves:

<item symbols>
/1 = "Л"
/2 = "◇"
/3 = "ϴ"
/4 = "Ш"
/5 = "σ"
/6 = "Џ"
/7 = "Г"
/8 = "Λ"
/9 = "Ҩ"
</item>

The key (from original implementation of DSST):

<picture key_pic>
/items = ("key.png")
/vposition = (75%)
/ erase = false
</picture>


*************
STIMULI
*************

The symbol display itself:

<text symbol_display>
/ items = ("<% getitem(item.symbols, values.current_symbol) %>")
/ fontstyle = ("Helvetica", 25%)
/ vposition = 33%
</text>


Feedback in case of error, and helpful instructions:

<text DSST_error>
/ items = ("X")
/ vposition = 33%
/ fontstyle = ("Helvetica", 40%)
/ color = red
/ halign = center
/ hjustify = center
</text>

<text DSST_feedback>
/ items = ("Refer to key below")
/ vposition = 50%
/ fontstyle = ("Helvetice", 5%)
</text>

Feedback if correct:

<text DSST_correct>
/ items = ("✓")
/ vposition = 33%
/ fontstyle = ("Helvetica", 40%)
/ color = green
/ halign = center
/ hjustify = center
</text>


*************
TRIALS
*************


<trial DSST_main>
/ ontrialbegin = [ values.current_symbol = list.random_pick.nextvalue ]
/ stimulustimes = [ 0 = symbol_display ]
/ validresponse = ("1", "2", "3", "4", "5", "6", "7", "8", "9")
/ correctresponse = (values.current_symbol)
/ ontrialend = [ values.total_digit_sub_trials += 1 ]
/ branch = [ trial.DSST_main ]
/ posttrialpause = parameters.substitution_post_stim_pause
</trial>


<trial DSST_practice>
/ ontrialbegin = [ values.current_symbol = list.random_pick.nextvalue ]
/ stimulustimes = [ 0 = symbol_display ]
/ validresponse = ("1", "2", "3", "4", "5", "6", "7", "8", "9")
/ correctresponse = (values.current_symbol)
/ posttrialpause = parameters.substitution_post_stim_pause
/ errormessage = true(text.DSST_error, parameters.substitution_feedback_duration)
/ correctmessage = true(text.DSST_correct, parameters.substitution_feedback_duration)
</trial>


<block digit_sub_practice>
/ onblockbegin = [ values.trialtype = "Practice" ]
/ trials = [ 1-10 = DSST_practice]
/ bgstim = (key_pic)
/ branch = [ block.digit_sub_main ]
</block>


<block digit_sub_main>
/ onblockbegin = [ values.trialtype = "DSST" ]
/ trials = [ 1 = DSST_main]
/ bgstim = (key_pic)
/ timeout = 120000
/ onblockend = [
values.task_order += 1;
values.substitution_complete = values.task_order;
values.trialtype = "";
]
</block>




GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Reading This Topic

Explore
Messages
Mentions
Search