branching


Author
Message
nc
nc
nc
posted 9 Years Ago HOT
Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)
Group: Forum Members
Posts: 39, Visits: 108
Hello,

I'm trying to figure out how to set up branching for a block

I'd like to start my block with a single trial, and then determine the subsequent trial based on the user's response.

Currently, I have something like this set up, where I define the first two trials, but would like the block to dynamically move on to subsequent trials based on the user's responses. Unfortunately, what I'm running into is that only the trials I define at the <block> level will play - nothing will branch. Can you advise? I've included the except of my code for reference.


<block BearPractice>
/bgstim = (zebra,panda,sheep,cow,bear_selected)
/trials = [1=bear_comprehension_check; 2=bear_practicegiving]
</block>

<trial bear_comprehension_check>
/validresponse=(lbuttondown)
</trial>

<trial bear_practicegiving>
/stimulustimes =[2000=sticker;10000=bell,blankRight,blankLeft]
/validresponse=(zebra,panda,sheep,cow,blankRight,blankLeft)
/branch = [if (trial.selection.response == zebra && picture.zebra.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.selection.response == panda && picture.panda.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.selection.response == sheep && picture.sheep.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.selection.response == cow && picture.cow.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.bear_practicegiving.response == blankRight) trial.bear_practicegiving2]
/branch = [if (trial.bear_practicegiving.response == blankLeft) trial.bear_practicegiving2]
</trial>

<trial bear_practicegiving2>
/stimulustimes =[1=sticker;10000=bell,blankRight,blankLeft]
/validresponse=(zebra,panda,sheep,cow)
/branch = [if (trial.selection.response == zebra && picture.zebra.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.selection.response == panda && picture.panda.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.selection.response == sheep && picture.sheep.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.selection.response == cow && picture.cow.hposition == 10%) trial.beargivestoA]
</trial>

<trial beargivestoA>
/stimulusframes =[1=sticker_movestoA,zebra,panda,sheep,cow,bear_selected]
/validresponse=(lbuttondown)
</trial>
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: 105K
<trial bear_practicegiving>
...
/branch = [if (trial.selection.response == "zebra" && picture.zebra.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.selection.response == "panda" && picture.panda.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.selection.response == "sheep" && picture.sheep.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.selection.response == "cow" && picture.cow.hposition == 10%) trial.beargivestoA]
/branch = [if (trial.bear_practicegiving.response == "blankRight") trial.bear_practicegiving2]
/branch = [if (trial.bear_practicegiving.response == "blankLeft") trial.bear_practicegiving2]
</trial>

The response values need to be enclosed in double-quotes for this to work, as in the below simple example:

<block myblock>
/ trials = [1-6=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=a_stim, b_stim, c_stim]
/ inputdevice = mouse
/ validresponse = (a_stim, b_stim, c_stim)
/ branch = [if(trial.mytrial.response == "a_stim") trial.a]
/ branch = [if(trial.mytrial.response == "b_stim") trial.b]
/ branch = [if(trial.mytrial.response == "c_stim") trial.c]
</trial>

<trial a>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 2000
</trial>

<trial b>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 2000
</trial>

<trial c>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 2000
</trial>

<text mytext>
/ items = ("<%script.currenttrial%>")
</text>

<text a_stim>
/ items = ("A")
/ position = (25%, 50%)
</text>

<text b_stim>
/ items = ("B")
/ position = (50%, 50%)
</text>

<text c_stim>
/ items = ("C")
/ position = (75%, 50%)
</text>


nc
nc
Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)
Group: Forum Members
Posts: 39, Visits: 108
Thank you!! That fixed the issue.


One more question: For some reason, these parts of my script won't branch:

/branch = [if (trial.selection.response == "zebra" && picture.zebra.hposition == 15%) trial.beargivestoA]

Do you know if there's something wrong with the picture.zebra.hposition portion of the script?
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: 105K
Since I have no way of knowing what the actual position of <picture zebra> is, I cannot answer the question.

I would, however, assume that you are simply referencing the *wrong* trial element. I.e.

<trial bear_practicegiving>
...
/branch = [if (trial.selection.response == "zebra" && picture.zebra.hposition == 10%) trial.beargivestoA]
...
/branch = [if (trial.bear_practicegiving.response == "blankRight") trial.bear_practicegiving2]
/branch = [if (trial.bear_practicegiving.response == "blankLeft") trial.bear_practicegiving2]
</trial>

obvisously does not match. You'd be branching based on the response given in a completely different <trial> element. It should probably read

<trial bear_practicegiving>
...
/branch = [if (trial. bear_practicegiving.response == "zebra" && picture.zebra.hposition == 10%) trial.beargivestoA]
...
/branch = [if (trial.bear_practicegiving.response == "blankRight") trial.bear_practicegiving2]
/branch = [if (trial.bear_practicegiving.response == "blankLeft") trial.bear_practicegiving2]
</trial>




nc
nc
Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)Esteemed Member (2.4K reputation)
Group: Forum Members
Posts: 39, Visits: 108
Hi Dave,

thanks for the reply. Here's the problem, though.

I made 4 pictures to appear randomly in one of four positions.

I did this by doing the following. I set up a counter:

<counter positioncounter1>
/items =(15%,40%,65%,90%)
/select = noreplace
/ selectionrate = always
/ allowrepeats = false

I then had each picture select from the counter. For example:

<picture panda>
/items = panda_pic
/hposition = counter.positioncounter1.selectedvalue
/size=(150,150)
/vposition = 15%
</picture>


Then, I made blocks that displayed all four pictures. Here's an example:

<block BearPractice>
/bgstim = (zebra,panda,sheep,cow,bear_selected)
/trials = [1=bear_comprehension_check; 2=bear_practicegiving]


Then, within this block, I had branching based on where the picture appeared. Here's the example:


<trial bear_practicegiving2>
/stimulustimes =[1=sticker;3000=bell,blankRight,blankLeft]
/validresponse=(zebra,panda,sheep,cow,blankRight,blankLeft)
/branch = [if (trial.bear_practicegiving2.response == "zebra" && picture.zebra.hposition == 15%) trial.beargivestoA]
/branch = [if (trial.bear_practicegiving2.response == "panda" && picture.panda.hposition == 15%) trial.beargivestoA]
/branch = [if (trial.bear_practicegiving2.response == "sheep" && picture.sheep.hposition == 15%) trial.beargivestoA]
/branch = [if (trial.bear_practicegiving2.response == "cow" && picture.cow.hposition == 15%) trial.beargivestoA]
/branch = [if (trial.bear_practicegiving2.response == "blankRight") trial.bear_practicegiving2]
/branch = [if (trial.bear_practicegiving2.response == "blankLeft") trial.bear_practicegiving2]


Is it that my code can't seem to read the randomly selected hposition of the picture? If so, is there another way to branch based on where the picture has appeared? Thanks again for your help.
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: 105K
If I'm not mistaken, the problem is due to having /selectionrate=always in the counter *in combination* with using the counter's selectedvalue property *directly* in the <picture>s' /hposition attributes.

Basically what happens is that everytime you query the a given <picture>'s hposition property, a *new* value will be returned from the counter -- which will not necessarily be the same one that's been selected when the image was first displayed by your block.

Instead, set up four values to store the pictures' horizontal positions:

<values>
/ panda_hpos = 0%
/ zebra_hpos = 0%
...
</values>

Populate those values with items selected from the <counter> /onblockbegin

<block BearPractice>
/ onblockbegn = [values.panda_hpos = counter.positioncounter1.selectedvalue;
values.zebra_hpos = counter.positioncounter1.selectedvalue; ...]
...
</block>

and use the values in the respective <picture>s' /select attributes

<picture panda>
/items = panda_pic
/hposition = values.panda_hpos
/size=(150,150)
/vposition = 15%
</picture>

That way the hposition property will always return the correct value, i.e. that position an image has actually been displayed in by your block.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search