Millisecond Forums

Using "if" appropriately

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

By charlottebooth - 7/2/2015

I was wondering if someone could help me...
I have a task with four blocks, which are different due to the target characteristic, for example for one block the target is a square and for another block the target changes to a triangle.
However, the trials run in each block are exactly the same. The only difference will be whether the shapes shown are a target or not (depending on instructions at the beginning of a block).
I was wondering if I could write in each trial that the <correctresponse> = (4) if block.square, but (6) if block.triangle
I think it is possible but I don't know the appropriate text to write that Inquisit will understand.
Can anyone help??
:)

By Dave - 7/2/2015

You can do that using  /iscorrectresponse attributes in your <trial> element(s).
<expt>
/ blocks = [1-2=noreplace(square, triangle)]
</expt>

<block triangle>
/ trials = [1-4=mytrial]
</block>

<block square>
/ trials = [1-4=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=mytext]
/ validresponse = (4,6)
/ iscorrectresponse = [(script.currentblock=="triangle" && trial.mytrial.response==4) || (script.currentblock=="square" && trial.mytrial.response==6)]
</trial>

<text mytext>
/ items = ("<%script.currentblock%>")
</text>
By charlottebooth - 8/2/2015

That's great - thanks for your help! I now have another problem regarding this task.

It works great, but I'm having trouble with my output, because the blocks differ in terms of the target characteristic, yet the trials are exactly the same... the output is messy, because the outcome variables need to be calculated for each block separately in order to be correct. I only need three outcome variables to be calculated, which are whether the target was a) absent, b) local-target, c) global-target, however the type of target corresponding to the block is irrelevant.

How can I include in my script that "block.triangle and trial.triangle.square = a global-target" ; "block.triangle and trial.square.triangle = a local-target" ; "block.triangle and trial.circle.square = target-absent"?
I tried playing around with Summary Data, but it didn't seem to work.

Thanks :) 
By Dave - 8/2/2015

In the same way as before. You use conditional logic in /ontrialbegin and/or -end to update a variable (<values> entry) as needed.

<values>
/ targettype = ""
...
</values>

<trial triangle.square>
/ ontrialend = [if (script.currentblock=="triangle") values.targettype = "global"]
/ ontrialend = [if (script.currentblock=="square") values.targettype = "local"]
...
</trial>

<trial square.triangle>
/ ontrialend = [if (script.currentblock=="triangle") values.targettype = "local"]
/ ontrialend = [if (script.currentblock=="square") values.targettype = "global"]
...
</trial>

etc. and logging the value to the <data> file

<data>
/ columns = [... values.targettype... ]
...
</data>