Millisecond Forums

Random Time Interval Generation as task for Inquisit

https://forums.millisecond.com/Topic11512.aspx

By pawelstrojny - 10/22/2013

Hi,


I need to write a simple (?) script in which subjects will be asked to push one button (lets say "b") for some amount of time (lets say 10s = 10000ms) as "randomly"/arrhythmical as possible.


The one and only thing I need from this script is to measure response time of every push


- e.g. if subject pushed 3 times; (1st in t1; 2nd in t2; 3rd in t3)


script should record 3 response times (t1 - start; t2 - t1 and t3 - t2) -


basically I need the time gap between every two reactions.


I tried to write it like below, but I don't know how to make it record every push (not only the first one).


****script*****


<expt LoseFail>
/ blocks = [
                1 = Instruction;
                2 = Task;
                3 = End_Debriefing

            ]
</expt>

***Blocks***

<block instruction>
/ trials = [1=instruction]
</block>

<block task>
/ trials = [1=task]
</block>

<block end_debriefing>
/ trials = [1=debriefing]
</block>

***Trials***

<trial instruction>
/ stimulusframes = [1=instructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial task>
/ stimulustimes = [0 = start]
/ validresponse = ("b")
/ responsetime = 0
/ trialduration = 10000
</trial>

<trial debriefing>
/ stimulusframes = [1=debriefing]
/ validresponse = (" ")
/ recorddata = false
</trial>

***Items***

<text instructions>
/ items = ("instructions")
/ size = (75%, 75%)
/ hjustify = left
</text>

<text start>
/ items = ("Please push "b" as random as you can")
/ erase = false
/ size = (75%, 75%)
/ hjustify = left
</text>

<text debriefing>
/ items = ("debriefing")
/ size = (75%, 75%)
/ hjustify = left
</text>


*********


Could you please help me with that?

By Dave - 10/22/2013

<values>
/ start = 0
/ timeoflastresponse = 0
/ timebetweenresponses = 0
</values>


<expt LoseFail>
/ blocks = [
                1 = Instruction;
                2 = Task;
                3 = End_Debriefing

            ]
</expt>

***Blocks***

<block instruction>
/ trials = [1=instruction]
</block>

<block task>
/ trials = [1=task]
/ timeout = 10000
</block>

<block end_debriefing>
/ trials = [1=debriefing]
</block>

***Trials***

<trial instruction>
/ stimulusframes = [1=instructions]
/ validresponse = (" ")
/ recorddata = false
</trial>

<trial task>
/ ontrialbegin = [if(trial.task.trialcount==0)values.start=script.elapsedtime
    else values.start=values.timeoflastresponse]
/ ontrialend = [values.timeoflastresponse=script.elapsedtime]
/ ontrialend = [values.timebetweenresponses=values.timeoflastresponse-values.start]

/ stimulustimes = [0 = start]
/ validresponse = ("b")
/ responsetime = 0
/ branch = [trial.task]
</trial>

<trial debriefing>
/ stimulusframes = [1=debriefing]
/ validresponse = (" ")
/ recorddata = false
</trial>

***Items***

<text instructions>
/ items = ("instructions")
/ size = (75%, 75%)
/ hjustify = left
</text>

<text start>
/ items = ("Please push ~"b~" as random as you can")
/ erase = false
/ size = (75%, 75%)
/ hjustify = left
</text>

<text debriefing>
/ items = ("debriefing")
/ size = (75%, 75%)
/ hjustify = left
</text>

<data>
/ columns = [trialnum, values.start, values.timeoflastresponse, values.timebetweenresponses]
</data>

By pawelstrojny - 10/22/2013

Thank you!

By pawelstrojny - 10/30/2013

Hi,


Basing on Dave's solution I prepared script but something isn't working properly.


Problematic script elements:


<block practice>
/ trials = [1=practice]
</block>


which refers to:


<trial practice>
/ timeout = 10000
/ ontrialbegin = [if(trial.practice.trialcount==0)values.start=script.elapsedtime
    else values.start=values.timeoflastresponse]
/ ontrialend = [values.timeoflastresponse=script.elapsedtime]
/ ontrialend = [values.timebetweenresponses=values.timeoflastresponse-values.start]
/ stimulustimes = [0 = start]
/ validresponse = ("b")
/ responsetime = 0
/ branch = [trial.practice]
/ recorddata = false
</trial>


When I test only trial element (blue "play" triangle) - everything works, when I test block (again blue triangle) or a whole script - trial doesn't ends after 10 seconds (the message is being displayed until I reset script by Alt+Esc)


Where is the mistake?

By Dave - 10/30/2013

The /timeout needs to be at the <block> level just as in the example I gave you.

By pawelstrojny - 10/30/2013

So if I want to have sequence in block (eg. task - feedback) I need to use two blocks?



I mean:


<block block1>
/ trials = [1=task; 2=control]
</block>


referring to:


<trial task>
/ timeout = 10000
/ ontrialbegin = [if(trial.task.trialcount==0)values.start=script.elapsedtime
    else values.start=values.timeoflastresponse]
/ ontrialend = [values.timeoflastresponse=script.elapsedtime]
/ ontrialend = [values.timebetweenresponses=values.timeoflastresponse-values.start]
/ stimulustimes = [0 = start]
/ validresponse = ("b")
/ responsetime = 0
/ branch = [trial.task]
</trial>


and


<survey control>
/ pages = [1=control]
/ itemspacing = 2%
/ showpagenumbers = false
/ responsefontstyle = ("Arial", 1.1%, false, false, false, false, 5)
/ itemfontstyle = ("Arial", 1.5%, false, false, false, false, 5)
/ pagefontstyle = ("Arial", 1.8%, false, false, false, false, 5)
</survey>


And I want to have 10 sec task and then survey element.

By Dave - 10/30/2013

Yes, of course.

By pawelstrojny - 10/30/2013

Ok, so I can do that.


But in documentation about trial element the "timeout" command is present...

By Dave - 10/30/2013

Yes it is (and it works as expected), but that's irrelevant to your problem. With <trial>-level /timeout, the specified /timeout *applies to every instance of the given trial* -- whenever a new trial starts, that trial has 10 secs to complete. That's the way it should be. And your script will run an infinite amount of trials due to the /branch, it'll never stop (and it should not).

By pawelstrojny - 12/8/2013

Hi,


I have one more question:


I need to verify if subjects are pressing the button more than 5 times (to calculate the level of randomness later), I figured out that I need to add branch which will decide about the feedback (if he pressed less than 6 times - feedback "you need to press more" or if 6 or more  - no feedback).


Which I don't know is how can I make Inquisit count the number of valid responses in a trial?


Because I need an expression in branch (e.g.) ... [responsecount] > 5 ... Am I correct?

By Dave - 12/8/2013

You can do that using <values> and/or <expressions> as well as a bit of conditional logic via event attribiutes (/ontrialbegin, /ontrialend, etc.).

By pawelstrojny - 12/8/2013

Yes, I know that.



I have something like that:


<trial task>
/ ontrialbegin = [if(trial.task.trialcount==0)values.start=script.elapsedtime
    else values.start=values.timeoflastresponse]
/ ontrialbegin = [values.bcount = 0]
/ ontrialend = [values.timeoflastresponse=script.elapsedtime]
/ ontrialend = [values.timebetweenresponses=values.timeoflastresponse-values.start]
/ ontrialend = [values.bcount = what should I type here?]
/ stimulustimes = [0 = start]
/ validresponse = ("b")
/ responsetime = 0
/ branch = [trial.task]
</trial>


But don't know what to write in place of "what..."

By Dave - 12/8/2013

<trial task>
/ ontrialbegin = [if(trial.task.trialcount==0)values.start=script.elapsedtime
    else values.start=values.timeoflastresponse]
/ ontrialbegin = [values.bcount = 0]
/ ontrialend = [values.timeoflastresponse=script.elapsedtime]
/ ontrialend = [values.timebetweenresponses=values.timeoflastresponse-values.start]
/ ontrialend = [values.bcount = what should I type here?]
/ stimulustimes = [0 = start]
/ validresponse = ("b")
/ responsetime = 0
/ branch = [trial.task]
</trial>


#1: You *don't* want to reset that value to zero in every trial. You'll want to reset it at the beginning of a block (if at all).


<trial task>
/ ontrialbegin = [if(trial.task.trialcount==0)values.start=script.elapsedtime
    else values.start=values.timeoflastresponse]
/ ontrialbegin = [values.bcount = 0]
/ ontrialend = [values.timeoflastresponse=script.elapsedtime]
/ ontrialend = [values.timebetweenresponses=values.timeoflastresponse-values.start]
/ ontrialend = [values.bcount = what should I type here?]
/ stimulustimes = [0 = start]
/ validresponse = ("b")
/ responsetime = 0
/ branch = [trial.task]
</trial>


#2: Simply increase it by one:


/ontrialend = [values.bcount += 1]