Consecutive Responses within a Trial


Author
Message
Sean_Hughes
Sean_Hughes
Partner Member (698 reputation)Partner Member (698 reputation)Partner Member (698 reputation)Partner Member (698 reputation)Partner Member (698 reputation)Partner Member (698 reputation)Partner Member (698 reputation)Partner Member (698 reputation)Partner Member (698 reputation)
Group: Forum Members
Posts: 6, Visits: 16
Dave - Friday, January 27, 2017
Dave - Friday, January 27, 2017
Dave - Friday, January 27, 2017
Sean_Hughes - Friday, January 27, 2017
Dave - Friday, January 27, 2017
Sean_Hughes - Friday, January 27, 2017
Dave - Thursday, January 26, 2017
Sean_Hughes - Thursday, January 26, 2017
Dave - Wednesday, January 25, 2017
Sean_Hughes - Wednesday, January 25, 2017
Hi,
     Quick question. I need a participant to click 3 times on a certain image within a trial (Image A). Once this happens another image on the screen should then change from one state to another (Image B should change). Is this possible to achieve with Inquisit 4 at all?

Any help would be very appreciated.

Thanks,
Sean 

Yes, this is certainly possible. However, your description is a bit too vague to give a concrete example. The easiest way would be to simply run a <trial> that collects a single click on image A three times in a row, and then follow that up with another, different <trial> that displays the changed image B.

Thanks Dave for the speedy reply. Below you can find the code I've tried to implement to solve my problem. To quickly summarize, I would like participants to press "button 3" multiple times. Once this happens the Purple card should turn yellow. I can do this for a single trial (by using the correctstreak option). But my problem is that I need to present the first trial 30 times per block. So I need to reset the correctstreak variable each time the participant returns to the first trial. At the moment I don't know how to achieve this... 

<trial Card_Presentation_Blue_Purple_Green>
/ inputdevice = mouse
/ correctresponse = (button_3)
/ validresponse = (Blue_Card_Left, Purple_Card_Center, Green_Card_Right, button_3)
/ stimulustimes = [0 = total_points, Stage, button_1, button_2, button_3, Blue_Card_Left, Purple_Card_Center, Green_Card_Right]

/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.correctstreak < 3) trial.Card_Presentation_Blue_Purple_Green]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.correctstreak > 2) trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule]

/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Blue_Card_Left") trial.Feedback_Avoid_Spiders_Blue_Card_Presentation_Blue_Purple_Yellow]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Purple_Card_Center") trial.Feedback_Loss_Points_Purple_Card_Presentation_Blue_Purple_Yellow]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Green_Card_Right") trial.Feedback_Loss_Points_Green_Card_Presentation_Blue_Purple_Green]
</trial>

<trial Card_Presentation_Blue_Purple_Yellow_Follow_Rule>
/ inputdevice = mouse
/ correctresponse = (Yellow_Card_Right)
/ validresponse = (Blue_Card_Left, Purple_Card_Center, Yellow_Card_Right)
/ stimulustimes = [0 = total_points, Stage, button_1, button_2, button_3, Blue_Card_Left, Purple_Card_Center, Yellow_Card_Right]

/ branch = [if (trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule.response == "Blue_Card_Left") trial.Feedback_Avoid_Spiders_Blue_Card_Presentation_Blue_Purple_Yellow]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule.response == "Purple_Card_Center") trial.Feedback_Loss_Points_Purple_Card_Presentation_Blue_Purple_Yellow]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule.response == "Yellow_Card_Right") trial.Feedback_Spider_Money_Yellow_Card_Presentation_Blue_Purple_Yellow]
</trial>

Note if there is a better way to solve my issue I'm all ears! 

Best,
Sean 

You shouldn't use correctstreak here. Set up a global variable (<values> entry) to count the clicks. /branch when the variable equals 3. Reset the variable back to 0 at the end of the "round" in <trial Card_Presentation_Blue_Purple_Yellow_Follow_Rule. I.e.

<values>
/ clickcount = 0
</values>

<trial Card_Presentation_Blue_Purple_Green>
...
/ ontrialend = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Yellow_Card_Right) values.clickcount += 1]
...
/ branch = [if (values.clickcount> 2) trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule]
...
</trial>


<trial Card_Presentation_Blue_Purple_Yellow_Follow_Rule>
...
/ ontrialend = [values.clickcount = 0]
...
</trial>

Hope this helps.

Works like a charm! Many thanks Dave. One last question: 

I want each block to be comprised of 15 trials. However, when using the above solution, I now only get five trials per block. This is because when I click on Image A three times the script increments the total trial count every time (i.e., each click counts as a trial). Is there any way of subtracting 3 from the total trial count at the end of trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule (i.e., after the participant clicks three times on the image)? 



> I want each block to be comprised of 15 trials. However, when using the above solution, I now only get five trials per block.

I don't know how you've set up the respective <block>(s) (the code snippets you posted do not include any <block> elements), so I'm not sure how to answer that. I'd need more info here.

> Is there any way of subtracting 3 from the total trial count

Here too, I'm not entirely sure what you are referring to with "total trial count". A built-in property? How / where do you use that property? Also, why not triple the amount of trials instead (i.e., 3 x 15 = 45)?

Thanks.


Apologies - below you can find a code snippet for both trial and block: 

<trial Card_Presentation_Blue_Purple_Green>
/ inputdevice = mouse
/ correctresponse = (button_3)
/ validresponse = (Blue_Card_Left, Purple_Card_Center, Green_Card_Right, button_1, button_2, button_3)
/ stimulustimes = [0 = total_points, Stage, button_1, button_2, button_3, Blue_Card_Left, Purple_Card_Center, Green_Card_Right]

/ ontrialend = [if (trial.Card_Presentation_Blue_Purple_Green.response == "button_3") values.click_count += 1]
/ branch = [if (values.click_count > 2) trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule]

/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Button_1") trial.Card_Presentation_Blue_Purple_Green]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Button_2") trial.Card_Presentation_Blue_Purple_Green]

/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Blue_Card_Left") trial.Feedback_Avoid_Spiders_Blue_Card_Presentation_Blue_Purple_Green]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Purple_Card_Center") trial.Feedback_Loss_Points_Purple_Card_Presentation_Blue_Purple_Green]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Green_Card_Right") trial.Feedback_Loss_Points_Green_Card_Presentation_Blue_Purple_Green]
</trial>

<trial Card_Presentation_Blue_Purple_Yellow_Follow_Rule>
/ inputdevice = mouse
/ correctresponse = (Yellow_Card_Right)
/ validresponse = (Blue_Card_Left, Purple_Card_Center, Yellow_Card_Right)
/ stimulustimes = [0 = total_points, Stage, button_1, button_2, button_3, Blue_Card_Left, Purple_Card_Center, Yellow_Card_Right]

/ ontrialend = [values.click_count = 0]

/ branch = [if (trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule.response == "Blue_Card_Left") trial.Feedback_Avoid_Spiders_Blue_Card_Presentation_Blue_Purple_Yellow]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule.response == "Purple_Card_Center") trial.Feedback_Loss_Points_Purple_Card_Presentation_Blue_Purple_Yellow]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Yellow_Follow_Rule.response == "Yellow_Card_Right") trial.Feedback_Spider_Money_Yellow_Card_Presentation_Blue_Purple_Yellow]
</trial>

and Block: 

<block Training_Block_1>
/ screencolor = white
/ trials = [1-15 = noreplacenorepeat(Card_Presentation_Blue_Purple_Green)]
</block>


In explaining my problem I originally over simplified. Basically there are three buttons that participants can push (A,B,C). There are three playing cards participants can also choose (Blue, Purple, Green). If participants press a certain button three times (Button C) then one of the cards (Green) changes color (Yellow). 

Now if participants choose a Green, Blue, or Purple playing card the trial number increments by +1 (i.e., this is working fine). However, if participants do what I want them to do (i.e., press Button C three times then click on the Yellow card) then the script counts this as four trials. So what I want is this: if people click three times on Button C then choose the Yellow Card the script counts this as "one trial". This way participants can repeat this same behavior 15 times.

In short, I need a way to have my Inquisit script either (a) treat three presses on Button C followed by a Yellow Card selection as a single trial (and thus do this 15 times) or (b) count this as four trials (i.e., three button presses and a card selection = 4 trials) and then subtract 3 from the total trial count after a Yellow Card selection so that it only *technically* counts as a "single trial". 

I hope this is clear. If not, just let me know. 

Best,
Sean 


> Now if participants choose a Green, Blue, or Purple playing card the trial number increments by +1

Which trial number? I don't see any trial number used anywhere in the script snippet.

Also, I think there's a misunderstanding.

<block Training_Block_1>
...
/ trials = [1-15 = noreplacenorepeat(Card_Presentation_Blue_Purple_Green)]
...
</block>

instructs the block to run 15 instances of <trial Card_Presentation_Blue_Purple_Green> via the /trials attribute.

Any instances you invoke via /branch as in

<trial Card_Presentation_Blue_Purple_Green>
...
/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Button_1") trial.Card_Presentation_Blue_Purple_Green]
/ branch = [if (trial.Card_Presentation_Blue_Purple_Green.response == "Button_2") trial.Card_Presentation_Blue_Purple_Green]
...
<trial>

are *in addition* to that.

One more thing: I'm not clear on how you actually want to use values.clickcount. Suppose the participant clicks button_3 twice, i.e. values.clickcount is increased to 2, and then the participant clicks button_2. What is supposed to happen with values.clickcount? Is it to remain at the value 2 or is it supposed to go back to 0? If the latter, that logic is missing currently.

Perhaps a simple example will help: This runs 10 rounds. A round advances to the next once three consecutive clicks on the object A have occurred.

<values>
/ round = 0
/ a_consecutiveclickcount = 0
</values>


<block example>
/ trials = [1-10 = startround]
</block>

<trial startround>
/ ontrialbegin = [values.round += 1;
    values.a_consecutiveclickcount = 0;
    text.a.textbgcolor = grey;]
/ branch = [trial.a_or_b]
/ trialduration = 0
</trial>

<trial a_or_b>
/ stimulusframes = [1=a,b,debug]
/ validresponse = (a,b)
/ inputdevice = mouse
/ ontrialend = [if (trial.a_or_b.response == "a") values.a_consecutiveclickcount += 1]
/ ontrialend = [if (trial.a_or_b.response != "a") values.a_consecutiveclickcount = 0]
/ branch = [if (values.a_consecutiveclickcount > 2) trial.a_change else trial.a_or_b]
</trial>

<trial a_change>
/ ontrialbegin = [text.a.textbgcolor = green;]
/ stimulusframes = [1=a,b,debug]
/ inputdevice = mouse
/ validresponse = (a)
</trial>

<text a>
/ items = ("A")
/ erase = false
/ position = (40%, 50%)
/ size = (10%, 10%)
/ vjustify = center
/ txbgcolor = grey
</text>

<text B>
/ items = ("B")
/ erase = false
/ position = (60%, 50%)
/ size = (10%, 10%)
/ vjustify = center
/ txbgcolor = grey
</text>

<text debug>
/ items = ("Round #<%values.round%> | Consecutive clicks on A: <%values.a_consecutiveclickcount%>")
/ erase = false
/ size = (60%, 10%)
/ position = (50%, 10%)
</text>



Perfect - thanks for the advice. I finally got it working! 

Best,
Sean 
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search