## Expression for Continuous Feedback?

 Author Message ***JayD***  Distinguished Member         Group: Forum Members Posts: 17, Visits: 67 Hi all,I'm currently writing a script on Inquisit 3.0 in which participants' eye-movements determine task flow. Specifically, where they look determines whether they are correct or not and how fast they look in the correct place determines how many points they receive (which they are shown on screen after every trial).Initially, we were going to simply use a reaction time (RT) cut-off/categorical approach (e.g. / branch = [if (trial.16.latency < 250) trial.01]; / branch = [if (trial.16.latency < 500) trial.02] etc.) but now we want to try to determine RT and thus feedback continuously (i.e. from 1-4200 ms).Further, we would like to build into this continuous feedback a cut-off at 1000ms, RTs over which participants receive no points. Finally, some trials will be "low reward" and others "high reward" - the points received in the former will necessarily be lower than in the latter, even when RT is identical. The calculation will be (1000 - RT) x 0.002 x reward trial type (1 OR 10).I have never programmed anything like this before so am unsure how to do it (or even whether it can be done on Inquisit!) but have heard that expressions may be the way to go? If so, how exactly might it look in the script?I appreciate any help and advice any of you can give.Thanks,Jay Dave  Supreme Being         Group: Administrators Posts: 9.8K, Visits: 46K You'll want to do something along the following lines:/ highreward = 10/ lowreward = 1/ reward = 0/ rt = 0/ trialscore = 0/ totalscore = 0/ calcreward = max(0, (1000 - values.rt)*0.002*values.reward)/ trials = [1-10 = noreplace(highrewardtrial, lowrewardtrial)]/ stimulusframes = [1=mytext]/ ontrialbegin = [values.reward = values.highreward]/ ontrialend = [values.rt = trial.highrewardtrial.latency;     values.trialscore = expressions.calcreward;    values.totalscore = values.totalscore + expressions.calcreward]/ validresponse = (57)/ branch = [trial.feedbacktrial]/ stimulusframes = [1=mytext]/ ontrialbegin = [values.reward = values.lowreward]/ ontrialend = [values.rt = trial.lowrewardtrial.latency;     values.trialscore = expressions.calcreward;    values.totalscore = values.totalscore + expressions.calcreward]/ validresponse = (57)/ branch = [trial.feedbacktrial]/ stimulusframes = [1=fbtext]/ validresponse = (57)/ items = ("<%script.currenttrial%>")/ items = ("RT: <%values.rt%> | Trial Score: <%values.trialscore%> | Total Score: <%values.totalscore%>") ***JayD***  Distinguished Member         Group: Forum Members Posts: 17, Visits: 67 That's fantastic - Thanks a lot Dave!Best,Jay ***JayD***  Distinguished Member         Group: Forum Members Posts: 17, Visits: 67 Hi Dave,I used your last response to allow for continuous feedback in one of my tasks and it worked perfectly.However, I have just tried to apply the same example script you sent on another (very similar) script and Inquisit keeps giving me error messages.Here is some of the script for the task in which the feedback works:******************************************************** VALUES & EXPRESSIONS ********************************************************/ highreward = 10/ lowreward = 1/ reward = 0/ RT = 0/ points = 0/ totalscore = 0/ calculatereward = max (0, (1000 - values.RT) * 0.002 * values.reward)************************************************ TRIALS ********************************************************************* FEEDBACK ***********************/ stimulusframes = [1 = FBtext]/ response = timeout (1000)/ recorddata = false/ items = ("Correct! You win <%values.points%> MONEY points")/ fontstyle = ("Arial", 4.79%, false, false, false, false, 5, 0)/ position = (50,50)/ color = (0, 255, 0)/ txbgcolor = (0, 0, 0)************************/ stimulusframes = [1=error]/ response = timeout (1000)/ recorddata = false / fontstyle = ("Arial", 4.79%, false, false, false, false, 5, 0)/ items = ("Incorrect! You lose 5 MONEY points")/ position = (50,50)/ color = (255, 0, 0)/ txbgcolor = (0, 0, 0) ********************************************************* HD (RED) TRIALS ************************************************************************************* DIAMOND TOP ***************************************/ stimulustimes = [1 = fixation; 800 = Diamond_Top, Red_BR, Grey_Top_Right, Grey_Bottom, Grey_Bottom_Left, Grey_Top_Left, xdat1]/ correctresponse = (Diamond_Top)/ validresponse = (Red_BR, Diamond_Top)/ ontrialbegin = [values.reward = values.highreward]/ ontrialend = [values.RT = trial.HRT1.latency; values.points = expressions.calculatereward; values.totalscore = values.totalscore + expressions.calculatereward]/ branch = (trial.HRT1.correct, EQ, 1, feedbacktrial)/ branch = (trial.HRT1.correct, EQ, 0, 999)/ trialduration = 5000/ responsetime = 800/ responseinterrupt = trial/ stimulustimes = [1 = fixation; 800 = Diamond_Top, Red_B, Grey_Top_Right, Grey_Bottom_Right, Grey_Bottom_Left, Grey_Top_Left, xdat2]/ correctresponse = (Diamond_Top)/ validresponse = (Red_B, Diamond_Top)/ ontrialbegin = [values.reward = values.highreward]/ ontrialend = [values.RT = trial.HRT2.latency; values.points = expressions.calculatereward; values.totalscore = values.totalscore + expressions.calculatereward]/ branch = (trial.HRT2.correct, EQ, 1, feedbacktrial)/ branch = (trial.HRT2.correct, EQ, 0, 999)/ trialduration = 5000/ responsetime = 800/ responseinterrupt = trial/ stimulustimes = [1 = fixation; 800 = Diamond_Top, Red_BL, Grey_Top_Right, Grey_Bottom_Right, Grey_Bottom, Grey_Top_Left, xdat3]/ correctresponse = (Diamond_Top)/ validresponse = (Red_BL, Diamond_Top)/ ontrialbegin = [values.reward = values.highreward]/ ontrialend = [values.RT = trial.HRT3.latency; values.points = expressions.calculatereward; values.totalscore = values.totalscore + expressions.calculatereward]/ branch = (trial.HRT3.correct, EQ, 1, feedbacktrial)/ branch = (trial.HRT3.correct, EQ, 0, 999)/ trialduration = 5000/ responsetime = 800/ responseinterrupt = trialThis works perfectly. However, the following is from my next task in which I've employed almost exactly the same script and I keep getting error messages such as "Expression values.reward is invalid. Expression contains an unkown element or property name." Similar messages appear for values.RT too (and perhaps others but I haven't yet checked).******************************************************** VALUES & EXPRESSIONS ********************************************************/ normalreward = 1/ reward = 0/ RT = 0/ points = 0/ totalscore = 0/ calculatereward = max (0, (1000 - values.RT) * 0.002 * values.reward)******************************** ERROR FEEDBACK *********************************/ stimulusframes=[1=error_A]/ response = timeout(1000)/ recorddata = false / font = ("Arial", 50, 400, 0, 34)/ items = ("Incorrect! You lose 5 ALCOHOL points")/ position = (50,50)/ color = (255, 0, 0)/ txbgcolor = (0, 0, 0) *********************/ stimulusframes=[1=error_C]/ response = timeout(1000)/ recorddata = false / font = ("Arial", 50, 400, 0, 34)/ items = ("Incorrect! You lose 5 CHOCOLATE points")/ position = (50,50)/ color = (255, 0, 0)/ txbgcolor = (0, 0, 0) ***********************/ stimulusframes=[1=error_N]/ response = timeout(1000)/ recorddata = false / font = ("Arial", 50, 400, 0, 34)/ items = ("Incorrect! You lose 0 points")/ position = (50,50)/ color = (255, 0, 0)/ txbgcolor = (0, 0, 0) ******************************** POSITIVE FEEDBACK *********************************/ stimulusframes = [1 = A_FBtext]/ response = timeout (1000)/ recorddata = false/ items = ("Correct! You win <%values.points%> ALCOHOL points")/ fontstyle = ("Arial", 4.79%, false, false, false, false, 5, 0)/ position = (50,50)/ color = (0, 255, 0)/ txbgcolor = (0, 0, 0)**********************/ stimulusframes = [1 = C_FBtext]/ response = timeout (1000)/ recorddata = false/ items = ("Correct! You win <%values.points%> CHOCOLATE points")/ fontstyle = ("Arial", 4.79%, false, false, false, false, 5, 0)/ position = (50,50)/ color = (0, 255, 0)/ txbgcolor = (0, 0, 0)*********************/ stimulusframes = [1 = N_FBtext]/ response = timeout (1000)/ recorddata = false/ items = ("Correct! Your Reaction Time was <%values.RT%> ms")/ fontstyle = ("Arial", 4.79%, false, false, false, false, 5, 0)/ position = (50,50)/ color = (0, 255, 0)/ txbgcolor = (0, 0, 0)************************************* STANDARD TRIALS 1 *********************************************/ stimulustimes = [1 = fixation; 500 = yellow_up; 800 = blackleft_down, blackright_down, blackcentre_down, xdat1; 4999 = end]/ correctresponse = (blackleft_down)/ validresponse = (blackleft_down, blackright_down, blackcentre_down)/ ontrialbegin = [values.reward = values.normalreward]/ ontrialend = [values.RT = trial.1.latency; values.points = expressions.calculatereward; values.totalscore = values.totalscore + expressions.calculatereward]/ branch = (trial.1.correct, EQ, 1, C_FBtrial)/ branch = (trial.1.correct, EQ, 0, 999C)/ trialduration = 5000/ responsetime = 800/ responseinterrupt = trial/ stimulustimes = [1 = fixation; 500 = green_up; 800 = blackleft_down, blackright_down, blackcentre_down, xdat2; 4999 = end]/ correctresponse = (blackright_down)/ validresponse = (blackleft_down, blackright_down, blackcentre_down)/ ontrialbegin = [values.reward = values.normalreward]/ ontrialend = [values.RT = trial.2.latency; values.points = expressions.calculatereward; values.totalscore = values.totalscore + expressions.calculatereward]/ branch = (trial.2.correct, EQ, 1, A_FBtrial)/ branch = (trial.2.correct, EQ, 0, 999A)/ trialduration = 5000/ responsetime = 800/ responseinterrupt = trial/ stimulustimes = [1 = fixation; 500 = pink_up; 800 = blackleft_down, blackright_down, blackcentre_down, xdat3; 4999 = end]/ correctresponse = (blackcentre_down)/ validresponse = (blackleft_down, blackright_down, blackcentre_down)/ ontrialbegin = [values.reward = values.normalreward]/ ontrialend = [values.RT = trial.3.latency; values.points = expressions.calculatereward; values.totalscore = values.totalscore + expressions.calculatereward]/ branch = (trial.3.correct, EQ, 1, N_FBtrial)/ branch = (trial.3.correct, EQ, 0, 999N)/ trialduration = 5000/ responsetime = 800/ responseinterrupt = trialI can't figure out what the problem is as - as far as I can tell - both scripts seem almost identical in their feedback settings.Thanks again for any help you can give,Best Jay ***JayD***  Distinguished Member         Group: Forum Members Posts: 17, Visits: 67 Hi,I've figured out what the problem is - an additional "values" element was tucked away in the script which had gone unnoticed (it was a remnant of an earlier version of the task).Thanks,Jay Dave  Supreme Being         Group: Administrators Posts: 9.8K, Visits: 46K Indeed, multiple elements in a given script elements are not supported in Inquisit 3 (they are in Inquisit 4, though). Glad you were able to identify the issue.