Change duration of a trial depending on participant response.


Author
Message
kev_dent
kev_dent
Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)
Group: Forum Members
Posts: 47, Visits: 153
Hi,

I would like to create an experiment where participants view images.
I would like to be able to have a participant increase or decrease the amount of time the stimulus is shown to them for by pressing keys.
Press one key to increase the stimulus duration, press another key to decrease it.
What would be the best way to implement this with inquisit?

Thanks
Kevin
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: 97K
kev_dent - 12/6/2023
Hi,

I would like to create an experiment where participants view images.
I would like to be able to have a participant increase or decrease the amount of time the stimulus is shown to them for by pressing keys.
Press one key to increase the stimulus duration, press another key to decrease it.
What would be the best way to implement this with inquisit?

Thanks
Kevin

You want that for the currently running trial (i.e, the image is already on-screen) or you want that sometime before any image(s) are displayed? Give a concrete example.
kev_dent
kev_dent
Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)
Group: Forum Members
Posts: 47, Visits: 153
Ok sure here is some toy code to illustrate what I want to do.
Default duration of the stimulus is 4000ms if the participant presses z every press of z adds 100 ms on to this time.
If the participant presses n every press of n increases the stimulus duration by 100 milliseconds.
The keypresses should occur whilst the stimulus is on the screen.
The sequence of keypresses and their timing relative to the start of the trial should also be recorded.
Thanks
Kevin

<trial t>
/ stimulustimes = [0=t]
/ beginresponsetime = 0
/ inputdevice = keyboard
/ validresponse = (44,49)
/ responseinterrupt = trial
/ isvalidresponse = [
    if(trial.t.response == 44) {trial.t.trialduration = trial.t.trialduration + 100; false} else if
  (trial.t.response == 49) {trial.t.trialduration = trial.t.trialduration + 100;false}
]
/trialduration = 4000
</trial>


<text t>
/items =("X")
/ erase = false
</text>
kev_dent
kev_dent
Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)
Group: Forum Members
Posts: 47, Visits: 153
Let me try that again.

Default duration of the stimulus is 4000ms if the participant presses z every press of z adds 100 ms on to this time.
If the participant presses n every press of n decreases the stimulus duration by 100 milliseconds.
The keypresses should occur whilst the stimulus is on the screen.
The sequence of keypresses and their timing relative to the start of the trial should also be recorded.
Thanks
Kevin

<trial t>
/ stimulustimes = [0=t]
/ beginresponsetime = 0
/ inputdevice = keyboard
/ validresponse = (44,49)
/ responseinterrupt = trial
/ isvalidresponse = [
  if(trial.t.response == 44) {trial.t.trialduration = trial.t.trialduration + 100; false} else if
(trial.t.response == 49) {trial.t.trialduration = trial.t.trialduration - 100;false}
]
/trialduration = 4000
</trial>


<text t>
/items =("X")
/ erase = false
</text>
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: 97K
kev_dent - 12/6/2023
Let me try that again.

Default duration of the stimulus is 4000ms if the participant presses z every press of z adds 100 ms on to this time.
If the participant presses n every press of n decreases the stimulus duration by 100 milliseconds.
The keypresses should occur whilst the stimulus is on the screen.
The sequence of keypresses and their timing relative to the start of the trial should also be recorded.
Thanks
Kevin

<trial t>
/ stimulustimes = [0=t]
/ beginresponsetime = 0
/ inputdevice = keyboard
/ validresponse = (44,49)
/ responseinterrupt = trial
/ isvalidresponse = [
  if(trial.t.response == 44) {trial.t.trialduration = trial.t.trialduration + 100; false} else if
(trial.t.response == 49) {trial.t.trialduration = trial.t.trialduration - 100;false}
]
/trialduration = 4000
</trial>


<text t>
/items =("X")
/ erase = false
</text>

Actually, scratch what I posted previously. It won't work reliably that way. The fundamental problem is that a trial's duration really isn't meant to be changed once it's underway, for obvious performance and timing reasons. So, back to the drawing board. Not sure this can be done, or done well, i.e. without incurring serious timing hiccups

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: 97K
Dave - 12/6/2023
kev_dent - 12/6/2023
Let me try that again.

Default duration of the stimulus is 4000ms if the participant presses z every press of z adds 100 ms on to this time.
If the participant presses n every press of n decreases the stimulus duration by 100 milliseconds.
The keypresses should occur whilst the stimulus is on the screen.
The sequence of keypresses and their timing relative to the start of the trial should also be recorded.
Thanks
Kevin

<trial t>
/ stimulustimes = [0=t]
/ beginresponsetime = 0
/ inputdevice = keyboard
/ validresponse = (44,49)
/ responseinterrupt = trial
/ isvalidresponse = [
  if(trial.t.response == 44) {trial.t.trialduration = trial.t.trialduration + 100; false} else if
(trial.t.response == 49) {trial.t.trialduration = trial.t.trialduration - 100;false}
]
/trialduration = 4000
</trial>


<text t>
/items =("X")
/ erase = false
</text>

Actually, scratch what I posted previously. It won't work reliably that way. The fundamental problem is that a trial's duration really isn't meant to be changed once it's underway, for obvious performance and timing reasons. So, back to the drawing board. Not sure this can be done, or done well, i.e. without incurring serious timing hiccups

Alright, the following should work reasonably well:

<values>
/ tduration = 0
/ up_responses = 0
/ down_responses = 0
/ latency = 0
/ stimonset = null
/ timeleft = 0
</values>

<block myblock>
/ trials = [1-4 = trial.t]
</block>

<trial t>
/ ontrialbegin = [
    values.tduration = 4000; // set default duration
    values.up_responses = 0; // count up responses in current trial
    values.down_responses = 0; // count down responses
    values.latency = 0;
    values.timeleft = 0;
]
/ ontrialend = [
    values.stimonset = text.t.timestamp; // store stimulus timestamp
]
/ stimulustimes = [0=clearscreen, t]
/ validresponse = (0)
/ trialduration = 0
/ branch = [
    return trial.t_adjust;
]
</trial>

<trial t_adjust>
/ ontrialbegin = [
    values.timeleft = values.tduration - values.latency;
]
/ ontrialend = [
    values.latency = script.elapsedtime - values.stimonset; // calculate latency relative to stimulus onset
    if (trial.t_adjust.response == 44) { // up response
        values.tduration += 100;
        values.up_responses += 1;
    } else if (trial.t_adjust.response ==49) { // down response
        values.tduration -= 100;
        values.down_responses += 1;
    };
]
/ validresponse = (44, 49)
/ beginresponsetime = -1
/ timeout = values.timeleft
/ branch = [
    if (trial.t_adjust.response == 0) {
        return trial.iti;
    } else {
        return trial.t_adjust;
    };
]
</trial>

<trial iti>
/ stimulustimes = [0=clearscreen]
/ trialduration = 500
/ validresponse = (0)
/ recorddata = false
</trial>

<text t>
/ items = ("T")
/ erase = false
</text>

<data>
/ columns = (date time subject group session blocknum blockcode trialnum trialcode response responsetext latency
    values.tduration values.up_responses values.down_responses values.latency values.timeleft)
</data>

kev_dent
kev_dent
Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)Partner Member (520 reputation)
Group: Forum Members
Posts: 47, Visits: 153
Thanks for your help Dave.
I will have a play with this code.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search