Count Button Presses in Trial with Fixed Duration


Author
Message
Pete
Pete
Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)
Group: Forum Members
Posts: 2, Visits: 6
Hi everyone,

I'm trying to create a trial lasting 3 min in which participants have to press the spacebar every time they come up with an idea. I would like to count how many times the participant presses the spacebar and if possible at what exact points in time during the 3 min interval the presses took place. 

I would really appreciate any help as I seem to be stuck.
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
Pete - Monday, November 20, 2017
Hi everyone,

I'm trying to create a trial lasting 3 min in which participants have to press the spacebar every time they come up with an idea. I would like to count how many times the participant presses the spacebar and if possible at what exact points in time during the 3 min interval the presses took place. 

I would really appreciate any help as I seem to be stuck.

You can achieve this using /isvalidresponse:

<block ideablock>
/ trials = [1=ideatrial]
</block>

<trial ideatrial>
/ stimulusframes = [1=ideatext]
/ validresponse = (57)
/ isvalidresponse = [if (trial.ideatrial.response == 57) {values.spacebarcount +=1; values.keypresstimes = concat(concat(values.keypresstimes, trial.ideatrial.latency), ";"); false}]
/ timeout = 30000
</trial>

<values>
/ spacebarcount = 0
/ keypresstimes = ""
</values>

<text ideatext>
/ items = ("Press the spacebar whenever you have an idea.")
</text>

<data>
/ columns = [date time subject group blocknum blockcode trialnum trialcode stimulusitem response latency
    values.spacebarcount values.keypresstimes]
/ separatefiles = true
</data>

You'll find the total number of spacebar presses logged in values.spacebarcount; you'll find a list of the exact times when the presses occurred in values.keypresstimes (in milliseconds, measured from the start of the trial).

Pete
Pete
Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)Associate Member (289 reputation)
Group: Forum Members
Posts: 2, Visits: 6
Thank you very much! Works perfectly!


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search