Changing valid response of current trial based on response of previous trial.


Changing valid response of current trial based on response of previous...
Author
Message
Dylonius
Dylonius
Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)
Group: Forum Members
Posts: 7, Visits: 29
Hello, I am working on a task where participants will remember the order of a previously viewed array of faces.

During the recall trial, participants view four faces on screen and indicate the order of each face by using separate buttons for 1st, 2nd, 3rd, and 4th.  Because I want real-time feedback to show the participant which face they selected, I have separate trials for each button press so that the number they selected will appear below the corresponding face. 
I would like to make it so that once a button press has occurred, this button will not be a validresponse in during the next trial.  However, because I can't predict which button will be pressed on each trial, I can't simply change the "validresponse = (..." entry for the next trial.  Unfortunately I can't figure out a way to push this information into the next trial without creating separate trials for every situation.   Here's a sample of my code:


<trial recall1>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [0=nothing]
/response = timeout(8000)
/validresponse = (3,4,5,6)

/responsetrial = (3, response1first)
/responsetrial = (4, response2first)
/responsetrial = (5, response3first)
/responsetrial = (6, response4first)
/ontrialend = [if(response == 3)values.rsp1 = 1]
/ontrialend = [if(response == 4)values.rsp1 = 2]
/ontrialend = [if(response == 5)values.rsp1 = 3]
/ontrialend = [if(response == 6)values.rsp1 = 4]
/ontrialend = [if(response == 3)values.validres1==(1)]
/ontrialend = [if(response == 4)values.validres2==(1)]
/ontrialend = [if(response == 5)values.validres3==(1)]
/ontrialend = [if(response == 6)values.validres4==(1)]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.timeleft = 8000 - trial.recall1.elapsedtime]
/ontrialend = [values.rt1 = trial.recall1.elapsedtime]
</trial>
<trial response1first>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=onefirst]
/ontrialbegin = [trial.response1first.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (4, response2second)
/responsetrial = (5, response3second)
/responsetrial = (6, response4second)
/ontrialend = [if(response == 3)values.rsp2 = 1]
/ontrialend = [if(response == 4)values.rsp2 = 2]
/ontrialend = [if(response == 5)values.rsp2 = 3]
/ontrialend = [if(response == 6)values.rsp2 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt2 = trial.response1first.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response1first.elapsedtime]
</trial>

<trial response1second>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=onesecond]
/ontrialbegin = [trial.response1second.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (4, response2third)
/responsetrial = (5, response3third)
/responsetrial = (6, response4third)
/ontrialend = [if(response == 3)values.rsp3 = 1]
/ontrialend = [if(response == 4)values.rsp3 = 2]
/ontrialend = [if(response == 5)values.rsp3 = 3]
/ontrialend = [if(response == 6)values.rsp3 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt3 = trial.response1second.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response1second.elapsedtime]
</trial>

<trial response1third>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=onethird]
/ontrialbegin = [trial.response1second.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (4, response2fourth)
/responsetrial = (5, response3fourth)
/responsetrial = (6, response4fourth)
/ontrialend = [if(response == 3)values.rsp4 = 1]
/ontrialend = [if(response == 4)values.rsp4 = 2]
/ontrialend = [if(response == 5)values.rsp4 = 3]
/ontrialend = [if(response == 6)values.rsp4 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt4 = trial.response1third.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response1third.elapsedtime]
</trial>


<trial response1fourth>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=onefourth]
/timeout = values.timeleft
/ontrialend = [values.counter = values.counter + 1]
</trial>


<trial response2first>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=twofirst]
/ontrialbegin = [trial.response2first.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (3, response1second)
/responsetrial = (5, response3second)
/responsetrial = (6, response4second)
/ontrialend = [if(response == 3)values.rsp2 = 1]
/ontrialend = [if(response == 4)values.rsp2 = 2]
/ontrialend = [if(response == 5)values.rsp2 = 3]
/ontrialend = [if(response == 6)values.rsp2 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt2 = trial.response2first.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response2first.elapsedtime]
</trial>

<trial response2second>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=twosecond]
/ontrialbegin = [trial.response2second.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (3, response1third)
/responsetrial = (4, response2third)
/responsetrial = (5, response3third)
/responsetrial = (6, response4third)
/ontrialend = [if(response == 3)values.rsp3 = 1]
/ontrialend = [if(response == 4)values.rsp3 = 2]
/ontrialend = [if(response == 5)values.rsp3 = 3]
/ontrialend = [if(response == 6)values.rsp3 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt3 = trial.response2second.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response2second.elapsedtime]
</trial>

<trial response2third>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=twothird]
/ontrialbegin = [trial.response2third.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (3, response1fourth)
/responsetrial = (4, response2fourth)
/responsetrial = (5, response3fourth)
/responsetrial = (6, response4fourth)
/ontrialend = [if(response == 3)values.rsp4 = 1]
/ontrialend = [if(response == 4)values.rsp4 = 2]
/ontrialend = [if(response == 5)values.rsp4 = 3]
/ontrialend = [if(response == 6)values.rsp4 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt4 = trial.response2third.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response2third.elapsedtime]
</trial>

.
.
.
etc..


Any suggestions on the best way to do this?  Currently my code works, but if the participant presses the same button twice in a row, then the trial advances and they will not have the ability to order each of the four faces.    Apologies of this is unclear, I can post the code in full if needed.

Thanks!
Dylan. 


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: 104K
Dylonius - Tuesday, August 8, 2017
Hello, I am working on a task where participants will remember the order of a previously viewed array of faces.

During the recall trial, participants view four faces on screen and indicate the order of each face by using separate buttons for 1st, 2nd, 3rd, and 4th.  Because I want real-time feedback to show the participant which face they selected, I have separate trials for each button press so that the number they selected will appear below the corresponding face. 
I would like to make it so that once a button press has occurred, this button will not be a validresponse in during the next trial.  However, because I can't predict which button will be pressed on each trial, I can't simply change the "validresponse = (..." entry for the next trial.  Unfortunately I can't figure out a way to push this information into the next trial without creating separate trials for every situation.   Here's a sample of my code:


<trial recall1>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [0=nothing]
/response = timeout(8000)
/validresponse = (3,4,5,6)

/responsetrial = (3, response1first)
/responsetrial = (4, response2first)
/responsetrial = (5, response3first)
/responsetrial = (6, response4first)
/ontrialend = [if(response == 3)values.rsp1 = 1]
/ontrialend = [if(response == 4)values.rsp1 = 2]
/ontrialend = [if(response == 5)values.rsp1 = 3]
/ontrialend = [if(response == 6)values.rsp1 = 4]
/ontrialend = [if(response == 3)values.validres1==(1)]
/ontrialend = [if(response == 4)values.validres2==(1)]
/ontrialend = [if(response == 5)values.validres3==(1)]
/ontrialend = [if(response == 6)values.validres4==(1)]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.timeleft = 8000 - trial.recall1.elapsedtime]
/ontrialend = [values.rt1 = trial.recall1.elapsedtime]
</trial>
<trial response1first>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=onefirst]
/ontrialbegin = [trial.response1first.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (4, response2second)
/responsetrial = (5, response3second)
/responsetrial = (6, response4second)
/ontrialend = [if(response == 3)values.rsp2 = 1]
/ontrialend = [if(response == 4)values.rsp2 = 2]
/ontrialend = [if(response == 5)values.rsp2 = 3]
/ontrialend = [if(response == 6)values.rsp2 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt2 = trial.response1first.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response1first.elapsedtime]
</trial>

<trial response1second>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=onesecond]
/ontrialbegin = [trial.response1second.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (4, response2third)
/responsetrial = (5, response3third)
/responsetrial = (6, response4third)
/ontrialend = [if(response == 3)values.rsp3 = 1]
/ontrialend = [if(response == 4)values.rsp3 = 2]
/ontrialend = [if(response == 5)values.rsp3 = 3]
/ontrialend = [if(response == 6)values.rsp3 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt3 = trial.response1second.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response1second.elapsedtime]
</trial>

<trial response1third>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=onethird]
/ontrialbegin = [trial.response1second.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (4, response2fourth)
/responsetrial = (5, response3fourth)
/responsetrial = (6, response4fourth)
/ontrialend = [if(response == 3)values.rsp4 = 1]
/ontrialend = [if(response == 4)values.rsp4 = 2]
/ontrialend = [if(response == 5)values.rsp4 = 3]
/ontrialend = [if(response == 6)values.rsp4 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt4 = trial.response1third.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response1third.elapsedtime]
</trial>


<trial response1fourth>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=onefourth]
/timeout = values.timeleft
/ontrialend = [values.counter = values.counter + 1]
</trial>


<trial response2first>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=twofirst]
/ontrialbegin = [trial.response2first.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (3, response1second)
/responsetrial = (5, response3second)
/responsetrial = (6, response4second)
/ontrialend = [if(response == 3)values.rsp2 = 1]
/ontrialend = [if(response == 4)values.rsp2 = 2]
/ontrialend = [if(response == 5)values.rsp2 = 3]
/ontrialend = [if(response == 6)values.rsp2 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt2 = trial.response2first.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response2first.elapsedtime]
</trial>

<trial response2second>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=twosecond]
/ontrialbegin = [trial.response2second.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (3, response1third)
/responsetrial = (4, response2third)
/responsetrial = (5, response3third)
/responsetrial = (6, response4third)
/ontrialend = [if(response == 3)values.rsp3 = 1]
/ontrialend = [if(response == 4)values.rsp3 = 2]
/ontrialend = [if(response == 5)values.rsp3 = 3]
/ontrialend = [if(response == 6)values.rsp3 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt3 = trial.response2second.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response2second.elapsedtime]
</trial>

<trial response2third>
/ontrialbegin = [values.trialstarttime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/ontrialbegin = [values.tasktimetrue = expt.FaceSequenceTask.elapsedtime]
/ontrialbegin = [values.tasktime = expt.FaceSequenceTask.elapsedtime - values.taskstart]
/stimulustimes = [1=twothird]
/ontrialbegin = [trial.response2third.timeout = values.timeleft]
/validresponse = (3,4,5,6)
/responsetrial = (3, response1fourth)
/responsetrial = (4, response2fourth)
/responsetrial = (5, response3fourth)
/responsetrial = (6, response4fourth)
/ontrialend = [if(response == 3)values.rsp4 = 1]
/ontrialend = [if(response == 4)values.rsp4 = 2]
/ontrialend = [if(response == 5)values.rsp4 = 3]
/ontrialend = [if(response == 6)values.rsp4 = 4]
/ontrialend = [values.counter = values.counter + 1]
/ontrialend = [values.rt4 = trial.response2third.elapsedtime]
/ontrialend = [values.timeleft = values.timeleft - trial.response2third.elapsedtime]
</trial>

.
.
.
etc..


Any suggestions on the best way to do this?  Currently my code works, but if the participant presses the same button twice in a row, then the trial advances and they will not have the ability to order each of the four faces.    Apologies of this is unclear, I can post the code in full if needed.

Thanks!
Dylan. 


You can achieve this using /isvalidresponse and a global variable (a <values> entry) that stores the previously clicked responses. See e.g. <trial clicktrial> in this example:
https://www.millisecond.com/forums/FindPost18371.aspx

The crucial parts are

<trial clicktrial>
/ stimulusframes = [1=selectedcorner, debug]
/ validresponse = (c1,c2,c3,c4,c5,c6,c7,c8,done)
/ isvalidresponse = [!contains(values.responsestorage, trial.clicktrial.response)]
/ inputdevice = mouse
/ ontrialend = [values.responsestorage = concat(values.responsestorage, trial.clicktrial.response)]
..
</trial>

i.e.

/ isvalidresponse = [!contains(values.responsestorage, trial.clicktrial.response)]

the response is only considered valid if the given response is _not_ already contained in values.responsestorage

and

/ ontrialend = [values.responsestorage = concat(values.responsestorage, trial.clicktrial.response)]

adds the given response to the value.

Dylonius
Dylonius
Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)
Group: Forum Members
Posts: 7, Visits: 29
Thanks a ton, it works.  

For anyone else reading this thread, make sure you re-initialize your "responsestorage" variable to something not included in your desired "validresponse" after every trial. 



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search