Using previous trial response as correctresponse


Author
Message
bellreavue
bellreavue
Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)
Group: Forum Members
Posts: 5, Visits: 52
We're designing a modified flanker task where participants have to respond to the flanker stimuli and then indicate the response they made on the previous trial. In other words, participants will be presented with the stimuli ("><>"), press a button to respond to this trial, then a fixation box will appear and participants will indicate the response they made on the previous flanker stimuli trial.

This continues throughout the block with participants indicating the direction of the presented flanker stimuli, then indicating their response on the previous flanker stimuli trial when the fixation box appears. So if we start on trial 3 (flanker stimuli), trial 4 (fixation box) would have participants indicate their response from trial 1 (flanker stimuli). Then trial 5 would be flanker stimuli, and trial 6 (fixation box) would have participants indicate their response from trial 3.

We need to store the response that the participant makes on each flanker stimuli trial in order to call it back during the fixation box trial to know if the participant is correct or incorrect. Is it possible to do this with the list element? I think so, but I'm not exactly sure how. 

Thanks for any help!
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: 12K, Visits: 98K
This basically sounds like a combination of flanker and n-back. What you'll want to do is set up two global variables (<values> entries), to store the responses (key pressed) for the current and the previous flanker trial. You can then use /iscorrectresponse in the fixation trial to check the response in the fixation trial against the response given in the previous fixation trial. Quick example:

<values>
/ prev_flanker_resp = 57
/ current_flanker_resp = 57
/ current_flanker_cresp = 0
/ flankeritem = 1
</values>

<block myblock>
/ trials = [1-10 = sequence(flankertrial, fixationtrial)]
</block>

<trial flankertrial>
/ ontrialbegin = [values.flankeritem = list.flankeritemlist.nextvalue;]
/ ontrialbegin = [if (values.flankeritem == 1) values.current_flanker_cresp = 203;]
/ ontrialbegin = [if (values.flankeritem == 2) values.current_flanker_cresp = 205;]
/ ontrialbegin = [values.prev_flanker_resp = values.current_flanker_resp; values.current_flanker_resp = "n/a"]
/ ontrialend = [values.current_flanker_resp = trial.flankertrial.response;]
/ stimulusframes = [1=flankerstim, debug]
/ validresponse = (203, 205)
/ iscorrectresponse = [trial.flankertrial.response == values.current_flanker_cresp]
/ correctmessage = (correctmsg, 1000)
/ errormessage = (errormsg, 1000)
</trial>

<trial fixationtrial>
/ stimulusframes = [1=fixationstim, debug]
/ validresponse = (203, 205, 57)
/ iscorrectresponse = [trial.fixationtrial.response == values.prev_flanker_resp]
/ correctmessage = (correctmsg, 1000)
/ errormessage = (errormsg, 1000)
</trial>

<text flankerstim>
/ items = ("<", ">")
/ select = values.flankeritem
</text>

<list flankeritemlist>
/ items = (1,1,1,1,1,2,2,2,2,2)
</list>

<text fixationstim>
/ items = ("+")
</text>

<text correctmsg>
/ items = ("CORRECT")
/ txcolor = green
/ position = (50%, 90%)
</text>

<text errormsg>
/ items = ("ERROR")
/ txcolor = red
/ position = (50%, 90%)
</text>

<text debug>
/ items = ("Response in Flanker trial n: <%values.current_flanker_resp%> | Response in Flanker trial n-1: <%values.prev_flanker_resp%>")
/ position = (50%, 10%)
/ erase = false
/ size = (90%, 10%)
</text>



bellreavue
bellreavue
Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)
Group: Forum Members
Posts: 5, Visits: 52

Thank you for your response, Dave. I was wondering if you could help me again with the code for this task. I’m trying to add the four types of flanker presentations that could come up during the flanker trial (>>>, <><, <<<, ><>), so I defined the left and right arrow images as items and put conditional statements in the <trial> to select if the target and flankers are left or right arrows. When I run the task, only one arrow shows up at a time, instead of all three. I’ve pasted some of my code below, any idea what I did wrong?

<values>
/ responsekey_targetright = 77
/ responsekey_targetleft = 75
/ pictureheight = 10%
/ flankerdistance = 10%
/ numberofpracticetrials = 20
/ numberoftrials = 120
/ resttrial = 40
/ max_trialduration = 3000
/ iti = 1500
/ restduration = 60000
/ anticipatoryresponselatency = 200
/ prev_flanker_resp = 57
/ current_flanker_resp = 57
/ current_flanker_cresp = 0
/ selecttarget = 1
/ selectflanker = 1
/ trialtype = 0
</values>

<item arrow>
/ 1 = "Rarrow.bmp"
/ 2 = "Larrow.bmp"
</item>

<picture flanker1>
/ items = arrow
/ select = values.selectflanker
</picture>

<picture target>
/ items = arrow
/ select = values.selecttarget
</picture>

<picture flanker3>
/ items = arrow
/ select = values.selectflanker
</picture>

<list trialtype>
/ items = (1, 2, 3, 4)
/ replace = false
/ poolsize = values.numberoftrials
/ resetinterval = 1
</list>

<trial flankertrial>
/ ontrialbegin = [values.trialtype = list.trialtype.nextvalue;]
/ ontrialbegin = [if (values.trialtype == 1 || values.trialtype == 2) {values.current_flanker_cresp = 77}]
/ ontrialbegin = [if (values.trialtype == 3 || values.trialtype == 4) {values.current_flanker_cresp = 75}]
/ ontrialbegin = [if (values.trialtype == 1) {values.selectflanker = 1; values.selecttarget = 1; values.count_congruent += 1}]
/ ontrialbegin = [if (values.trialtype == 2) {values.selectflanker = 2; values.selecttarget = 1; values.count_incongruent += 1}]
/ ontrialbegin = [if (values.trialtype == 3) {values.selectflanker = 2; values.selecttarget = 2; values.count_congruent += 1}]
/ ontrialbegin = [if (values.trialtype == 4) {values.selectflanker = 1; values.selecttarget = 2; values.count_incongruent += 1}]
/ ontrialbegin = [values.prev_flanker_resp = values.current_flanker_resp; values.current_flanker_resp = "n/a"]
/ ontrialend = [values.current_flanker_resp = trial.flankertrial.response;]
/ stimulusframes = [1= flanker1, target, flanker3]
/ beginresponsetime = 0
/ responseinterrupt = immediate
/ validresponse = (75, 77)
/ iscorrectresponse = [trial.flankertrial.response == values.current_flanker_cresp]
</trial>

<trial fixationtrial>
/ stimulusframes = [1=fixationstim]
/ validresponse = (75, 77)
/ iscorrectresponse = [trial.fixationtrial.response == values.prev_flanker_resp]
</trial>

<block flankertest>
/ trials = [1-10 = sequence(flankertrial, fixationtrial)]
</block>
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: 12K, Visits: 98K
bellreavue - Tuesday, January 31, 2017

Thank you for your response, Dave. I was wondering if you could help me again with the code for this task. I’m trying to add the four types of flanker presentations that could come up during the flanker trial (>>>, <><, <<<, ><>), so I defined the left and right arrow images as items and put conditional statements in the <trial> to select if the target and flankers are left or right arrows. When I run the task, only one arrow shows up at a time, instead of all three. I’ve pasted some of my code below, any idea what I did wrong?

<values>
/ responsekey_targetright = 77
/ responsekey_targetleft = 75
/ pictureheight = 10%
/ flankerdistance = 10%
/ numberofpracticetrials = 20
/ numberoftrials = 120
/ resttrial = 40
/ max_trialduration = 3000
/ iti = 1500
/ restduration = 60000
/ anticipatoryresponselatency = 200
/ prev_flanker_resp = 57
/ current_flanker_resp = 57
/ current_flanker_cresp = 0
/ selecttarget = 1
/ selectflanker = 1
/ trialtype = 0
</values>

<item arrow>
/ 1 = "Rarrow.bmp"
/ 2 = "Larrow.bmp"
</item>

<picture flanker1>
/ items = arrow
/ select = values.selectflanker
</picture>

<picture target>
/ items = arrow
/ select = values.selecttarget
</picture>

<picture flanker3>
/ items = arrow
/ select = values.selectflanker
</picture>

<list trialtype>
/ items = (1, 2, 3, 4)
/ replace = false
/ poolsize = values.numberoftrials
/ resetinterval = 1
</list>

<trial flankertrial>
/ ontrialbegin = [values.trialtype = list.trialtype.nextvalue;]
/ ontrialbegin = [if (values.trialtype == 1 || values.trialtype == 2) {values.current_flanker_cresp = 77}]
/ ontrialbegin = [if (values.trialtype == 3 || values.trialtype == 4) {values.current_flanker_cresp = 75}]
/ ontrialbegin = [if (values.trialtype == 1) {values.selectflanker = 1; values.selecttarget = 1; values.count_congruent += 1}]
/ ontrialbegin = [if (values.trialtype == 2) {values.selectflanker = 2; values.selecttarget = 1; values.count_incongruent += 1}]
/ ontrialbegin = [if (values.trialtype == 3) {values.selectflanker = 2; values.selecttarget = 2; values.count_congruent += 1}]
/ ontrialbegin = [if (values.trialtype == 4) {values.selectflanker = 1; values.selecttarget = 2; values.count_incongruent += 1}]
/ ontrialbegin = [values.prev_flanker_resp = values.current_flanker_resp; values.current_flanker_resp = "n/a"]
/ ontrialend = [values.current_flanker_resp = trial.flankertrial.response;]
/ stimulusframes = [1= flanker1, target, flanker3]
/ beginresponsetime = 0
/ responseinterrupt = immediate
/ validresponse = (75, 77)
/ iscorrectresponse = [trial.flankertrial.response == values.current_flanker_cresp]
</trial>

<trial fixationtrial>
/ stimulusframes = [1=fixationstim]
/ validresponse = (75, 77)
/ iscorrectresponse = [trial.fixationtrial.response == values.prev_flanker_resp]
</trial>

<block flankertest>
/ trials = [1-10 = sequence(flankertrial, fixationtrial)]
</block>

All three <picture> elements you defined inhabit the same on-screen position

<picture flanker1>
/ items = arrow
/ select = values.selectflanker
</picture>

<picture target>
/ items = arrow
/ select = values.selecttarget
</picture>

<picture flanker3>
/ items = arrow
/ select = values.selectflanker
</picture>

so of course you are going to only "see" one. <picture flanker3>, which is the one you display last

<trial flankertrial>
...
/ stimulusframes = [1= flanker1, target, flanker3]
...
</trial>

will be drawn on top of the other two pictures and obscure them.

Use the respective <picture> elements' /position attributes to position them as needed / such that they do not overlap and obscure each other.

bellreavue
bellreavue
Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)
Group: Forum Members
Posts: 5, Visits: 52
Thanks again! After a practice run, the stimuli are being presented correctly, but I still have the issue I described in the original post. 
Right now, flanker trials and fixation trials are presented one after the other. If trials 1, 3, 5, and 7 are flanker trials, the correct response on these trials should be whatever direction the target arrow is pointing (this is working). If trials 2, 4, 6, and 8 are fixation trials, trial 2 would be a throw-away trial because there's no previous flanker, and then the correct response on trial 4 would be the participant's response from trial 1, and the correct response from trial 6 would be the participant's response from trial 3, and on and on. However, with my script it appears that the correct response for trial 4 is the participant's response from trial 3, and the correct response for trial 6 is the participant's response from trial 5.
Conceptually, each flanker trial and subsequent fixation trial are one event, so I'm trying to figure out a way to store the response from the previous flanker, which is technically two flanker trials ago with the way that my trials are set up. 



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: 12K, Visits: 98K
bellreavue - Tuesday, January 31, 2017
Thanks again! After a practice run, the stimuli are being presented correctly, but I still have the issue I described in the original post. 
Right now, flanker trials and fixation trials are presented one after the other. If trials 1, 3, 5, and 7 are flanker trials, the correct response on these trials should be whatever direction the target arrow is pointing (this is working). If trials 2, 4, 6, and 8 are fixation trials, trial 2 would be a throw-away trial because there's no previous flanker, and then the correct response on trial 4 would be the participant's response from trial 1, and the correct response from trial 6 would be the participant's response from trial 3, and on and on. However, with my script it appears that the correct response for trial 4 is the participant's response from trial 3, and the correct response for trial 6 is the participant's response from trial 5.
Conceptually, each flanker trial and subsequent fixation trial are one event, so I'm trying to figure out a way to store the response from the previous flanker, which is technically two flanker trials ago with the way that my trials are set up. 



> Conceptually, each flanker trial and subsequent fixation trial are one event, so I'm trying to figure out a way to store the response from the previous flanker, which is
> technically two flanker trials ago with the way that my trials are set up.

That -- as far as I can tell -- is addressed in my response to your original post: https://www.millisecond.com/forums/FindPost19907.aspx
You store that response in a value and check against it. In other words: I'm not sure what the problem is.

bellreavue
bellreavue
Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)Partner Member (560 reputation)
Group: Forum Members
Posts: 5, Visits: 52
Dave - Tuesday, January 31, 2017
bellreavue - Tuesday, January 31, 2017
Thanks again! After a practice run, the stimuli are being presented correctly, but I still have the issue I described in the original post. 
Right now, flanker trials and fixation trials are presented one after the other. If trials 1, 3, 5, and 7 are flanker trials, the correct response on these trials should be whatever direction the target arrow is pointing (this is working). If trials 2, 4, 6, and 8 are fixation trials, trial 2 would be a throw-away trial because there's no previous flanker, and then the correct response on trial 4 would be the participant's response from trial 1, and the correct response from trial 6 would be the participant's response from trial 3, and on and on. However, with my script it appears that the correct response for trial 4 is the participant's response from trial 3, and the correct response for trial 6 is the participant's response from trial 5.
Conceptually, each flanker trial and subsequent fixation trial are one event, so I'm trying to figure out a way to store the response from the previous flanker, which is technically two flanker trials ago with the way that my trials are set up. 



> Conceptually, each flanker trial and subsequent fixation trial are one event, so I'm trying to figure out a way to store the response from the previous flanker, which is
> technically two flanker trials ago with the way that my trials are set up.

That -- as far as I can tell -- is addressed in my response to your original post: https://www.millisecond.com/forums/FindPost19907.aspx
You store that response in a value and check against it. In other words: I'm not sure what the problem is.

Ah, I found some errors I made regarding trial and value names. The code is working now. Thank you for your help, Dave!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search