Millisecond Forums

Set position of shape in a list?

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

By nashby - 5/31/2014

I am trying to design a simple change detection task where a flash say what quadrant participants need to remember items from and then random colored boxes (with no repetition) are flashed in that quadrant of the screen and then return (sometimes the same colored boxes, sometimes different).  I am having a hard time trying to define where the positions of the boxes are. So far I have this which creates a list with the random colored boxes and then adds them into the memory and test trials, but I cannot seem to define the locations of the list items which is important as I need to say for instance that the first two items in the list show up in locations X1 and X2, while the next items show up in a different quadrant. 

I have tried things like this:
shape.list.cb1.item.1.hposition =
list.cb1.item.1.hposition =

but these do not work. Getting quite frustrated as I cannot find any documentation or examples to help with this (been stuck on it about a week now).

Any help would be greatly appreciated. 

<trial Set1>
/ trialduration = 500
/ ontrialbegin = [trial.set1.clearstimulusframes()]
/ ontrialbegin = [trial.set1.insertstimulusframe(shape.FlashUR, 1)]
/ ontrialbegin = [trial.memory.clearstimulusframes()]
/ ontrialbegin = [list.cb1.clearitems()]
/ ontrialbegin = [list.cb1.insertitem(counter.colorboxes.selectedvalue, 1); list.cb1.insertitem(counter.colorboxes.selectedvalue, 2); list.cb1.insertitem(counter.colorboxes.selectedvalue, 3);]


/ ontrialbegin = [{trial.memory.insertstimulusframe(list.cb1.items.1, 1); trial.Memory.insertstimulusframe(list.cb1.items.2, 2);}]
/ ontrialbegin = [{trial.test.insertstimulusframe(list.cb1.items.1, 1); trial.test.insertstimulusframe(list.cb1.items.2, 2);}]

</trial>
By Dave - 5/31/2014

> I have tried things like this:
> shape.list.cb1.item.1.hposition =
> list.cb1.item.1.hposition =

list elements don't have any position properties, the underlying shape elements do. You thus need to manipulate those element's position.

shape.someshape.hposition = ...
By nashby - 5/31/2014

Hey Dave thanks for the response. I know how to define a shape position but that will not work for this purpose as it would require me to know the name of the shape which I dont as it needs to be random. Basically I am adding boxes to a list randomly using a counter. I then need to define that the first item in a list go to location X Y, while the second go to location X2 Y2. Is there no way to do this? 
By nashby - 5/31/2014

I have also tried this which doesnt break the code but doesnt set the locations either.
/ ontrialbegin = [shape.{list.cb1.items.1}.hposition = (counter.locationsx.selectedvalue );shape.{list.cb1.items.1}.vposition = (counter.locationsy.selectedvalue );]

By Dave - 5/31/2014

I'm pretty sure there is a way to do this, however, the few code snippets you posted don't convey sufficient detail re. your setup. Can you provide a simplified, concise, self-contained (i.e. runnable) example?

As to this:

"I have also tried this which doesnt break the code but doesnt set the locations either.
/ ontrialbegin = [shape.{list.cb1.items.1}.hposition = (counter.locationsx.selectedvalue );shape.{list.cb1.items.1}.vposition = (counter.locationsy.selectedvalue );]"

It's invalid syntax and should not be expected to work.
By nashby - 5/31/2014

Here is the experiment I am trying to program (http://www.geocities.ws/maro_g_machizawa/documents/Nature2005.pdf) its experiment 2.

This is the design in a nutshell:
I have 7 different colored boxes. On each trial a quadrant ( if two items) or side of the screen (if 4 items) is indicated as being the area where participants need to remember what is flashed. Then, either 2 (in the same quadrant) or 4 (2 in upper quadrant, 2 in lower quadrant) non repeating randomly selected colored boxes from the list of 7 are flashed within that quadrant or side, but at random locations which do not overlap. Following the flash there is a brief blank screen and then the colored boxes come back in the same locations as before but on 50% of trials one of the colored boxes changes color. Participants task is to say whether they are the same or different. 


By Dave - 5/31/2014

As a starting point, consider the below minimal example. Suppose you have two shapes A and B, both to be presented in a given trial at different times in random order. You want the 1st shape presented to always be on the left side, the 2nd always on the right side -- regardless of whether the 1st shape displayed is A or B:

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

<trial mytrial>
/ posttrialpause = 500
/ stimulustimes = [0=list.shapelist; 1000=list.shapelist]
/ validresponse = (57)
</trial>

<list shapelist>
/ items = (shape.a, shape.b)
/ selectionmode = random
/ selectionrate = always
</list>

<shape a>
/ shape = rectangle
/ size = (5%, 5%)
/ color = (red)
/ vposition = 50%
/ hposition = list.hposlist.nextvalue
</shape>

<shape b>
/ shape = rectangle
/ size = (5%, 5%)
/ color = (blue)
/ vposition = 50%
/ hposition = list.hposlist.nextvalue
</shape>

<list hposlist>
/ items = (25%, 75%)
/ selectionrate = always
/ selectionmode = sequence
</list>

Note that you need not know a shape's name to achieve the positioning.
By nashby - 5/31/2014

But how do I then get the same items to show in the same locations in the next trial which is the test array? Also, wouldnt I then have to define each shape multiple times just to get it to be able to show up in each specific quadrant? And then how do I get the same shape to not show up in different quadrants? 

I guess I am just not getting how to get this to work.
By Dave - 5/31/2014

> But how do I then get the same items to show in the same locations in the next trial which is the test array?

Store the positions in a list and replay in sequence.

> Also, wouldnt I then have to define each shape multiple times just to get it to be able to show up in each specific quadrant?

 No, why? Referring back to the example in my previous reply, you'll notice that neither shape A nor shape A is defined multiple times and yet they show up in different screen halves (can be easily extended to quadrants or whatever).

> And then how do I get the same shape to not show up in different quadrants? 

You sample from the set of shapes without replacement?
By nashby - 5/31/2014

Ok I get the storing but what a lot of work for what should be really simple.


Also I need exactly 2 items to go to quadrant 1 which can have a total of say 30 locations, and need 2 items to go to quadrant 2 which can have 30 locations. The way the above code looks I could not control what quadrant for each shape drawn?

By Dave - 5/31/2014

> Ok I get the storing but what a lot of work for what should be really simple.

I'm probably missing something, but I don't understand how that amounts to more work than doing this stuff:

/ ontrialbegin = [shape.{list.cb1.items.1}.hposition = (counter.locationsx.selectedvalue );shape.{list.cb1.items.1}.vposition = (counter.locationsy.selectedvalue );]

> Also I need exactly 2 items to go to quadrant 1 which can have a total of say 30 locations, and need 2 items to go to quadrant 2 which can have 30 locations. The way the above code looks I could not control what quadrant for each shape drawn?

I'm afraid I absolutely do not understand what you're getting at here :(
By nashby - 5/31/2014

I guess its just more work than any other programming language I have used but maybe thats just because I dont get the logic. It just seems it would be easier if you could define where items in an array went, rather than having to store them to keep them in the same order and locations.

Ok I will try to explain again. I have 4 quadrants of the screen. I need 2 colored boxes to go to the upper right and 2 colored boxes to the lower right. The upper right has 30 positions the lower right has 30 positions. The colored boxes that go to each quadrant need to be randomly determined. So sometimes a blue and red will be in the upper and a green and purple in the lower, and sometimes the reverse, and sometimes another variation.

Is there really no way to define where an item in a list goes? Cant I somehow call the name of item 1 on a given list and use that to define the location it will go?
By Dave - 5/31/2014

> I have 4 quadrants of the screen. I need 2 colored boxes to go to the upper right and 2 colored boxes to the lower right.

Then you should need no more than exactly 4 shape elements. Assign a (random) color to each, assign a random position, done.

You frankly shouldn't need any list to select the shape elements at all. All you need is lists for colors and positions.
By nashby - 5/31/2014

Ok I think I get what you are saying. Define colors and locations to each shape randomly, rather than defined shapes to locations. Just a really counter intuitive way of programming if you have used anything else in the past. I will give it a shot.

Thanks for the help.
By nashby - 5/31/2014

Alright so I have gotten the code to work, almost (and I am sure it could be more concise). It now has two issues which I am unsure how to get around and both are related. The problem is that the code below sometimes presents items on the same locations (e.g., uses the same y position for both items), sometimes presents the same color for both items (e.g., makes both shapes blue), and other times when replacing shape2 for different trials it does not change color, or changes color to the color of shape1. I assume this is because I am drawing randomly on each pass instead of randomly without replacement on each pass?  Any suggestions on how to remedy this? It is very important that each color is unique and each location is unique. 

**************************************************************************************************************
**************************************************************************************************************
Change detection & filtering
**************************************************************************************************************
**************************************************************************************************************

**************************************************************************************************************
**************************************************************************************************************
                                    DEFAULT SCREEN SETTING
**************************************************************************************************************
**************************************************************************************************************
requires Inquisit 4.0.0.0

<defaults>
/ minimumversion = "4.0.0.0"
/ inputdevice = mouse
/ fontstyle = ("Arial", 3.5%, false, false, false, false, 5, 0)
/ displaymode = (800, 600, 0)
</defaults>
**************************************************************************************************************
**************************************************************************************************************
                                             VALUES
**************************************************************************************************************
**************************************************************************************************************
****************
****************      

<values>
/ correct = 0
/ wrong = 0
/ falarm = 0
/ miss = 0
/ condition = 0
</values>


**************************************************************************************************************
                                             DATA
**************************************************************************************************************
**************************************************************************************************************

********************
raw data
********************
<data>
/file = "HLOnline.iqdat"
/ columns = [subject, values.samples,  response, latency, values.outcome, values.side, values.condition, values.ran, trialcode, expt.main.totalsumlatency, values.kickem]
/separatefiles = true
</data>

**************************************************************************************************************
**************************************************************************************************************
                                 INSTRUCTIONS ELEMENTS
**************************************************************************************************************
**************************************************************************************************************

<item instructions>
/ 1 = "In the task that follows you will be asked to remember colored boxes which appear briefly on the screen. Before the colored boxes are shown the upper (lower) left or right side of the screen will flash red. This flash indicates the area in which any colored boxes shown you must remember. For example, if the red flash is in the upper right side of the screen you will need to remember all of the colored boxes that appear in that area. If instead the flash is on the bottom left side of the screen then you would be tasked with remembering all the colored boxes that appear on the bottom left side of the screen. If the whole right side of the screen flashed you would need to remember any colored boxes that show up on the right side.

After indication arrow is shown colored boxes will flash briefly on the screen. Sometimes colored boxes will appear in locations which the arrow did not point to and you can simply ignore those boxes. After the colored boxes flash on the screen there will be a brief pause and then the colored boxes will return and your task will be to say if the colored boxes are the same colors as they were when they were first flashed on the screen. If they are all the same colors you will click the same button, if one of them is now a different color (i.e., one box has changed color) you will click the different button. Importantly, if there is a change in color it will happen to one box (i.e., there will only ever be one change).

When you are ready to begin the task please click the begin button"

/ 2 = "Please indicate whether the colored box shown is the same color it was during the preceding flash."

/ 3 = "Thank you for participating. Please click the next button to move on to the next task."

</item>



****************************************************Text/Stimuli**********************
<text Intro>
/ items = instructions
/ select = 1
/ position = (50%, 0%)
/ size = (100%, 110%)
/ hjustify = left
/ valign = top
/ txcolor = (black)
/ txbgcolor = (yellow)
</text>

<text Task>
/ items = instructions
/ select = 2
/ position = (50%, 2.5%)
/ hjustify = left
/ valign = top
/ txcolor = (black)
/ txbgcolor = (transparent)
</text>


<text Done>
/ items = instructions
/ select = 3
/ position = (50%, 10%)
/ hjustify = left
/ valign = top
/ txcolor = (black)
/ txbgcolor = (transparent)
</text>

<text Begin>
/ items = ("Begin")
/ position = (50%, 95%)
/ fontstyle = ("Arial", 3%, false, false, true, false, 5, 0)
/ txcolor = blue
/ txbgcolor = (transparent)
</text>

<text Go>
/ items = ("Next")
/ position = (50%, 75%)
/ txbgcolor = (150, 150, 150)
/ txcolor = black
</text>


<text Same>
/ items = ("Same")
/ position = (25%, 95%)
/ txcolor = black
</text>

<text Different>
/ items = ("Different")
/ position = (75%, 95%)
/ txcolor = black
</text>



**************************************************************************************************************
**************************************************************************************************************
                                          STIMULI
**************************************************************************************************************
**************************************************************************************************************
<shape S1>
/ shape = rectangle
/ size = (65, 65)
</shape>

<shape S2>
/ shape = rectangle
/ size = (65, 65)
</shape>

<shape S3>
/ shape = rectangle
/ size = (65, 65)
</shape>

<shape S4>
/ shape = rectangle
/ size = (65, 65)
</shape>



<shape FlashUR>
/ shape = rectangle
/ size = (50%, 50%)
/ color = (0, 0, 0)
/ position = (75%, 25%)
</shape>

<shape FlashLR>
/ shape = rectangle
/ size = (50%, 50%)
/ color = (0, 0, 0)
/ position = (75%, 75%)
</shape>

<shape FlashUL>
/ shape = rectangle
/ size = (50%, 50%)
/ color = (0, 0, 0)
/ position = (25%, 25%)
</shape>

<shape FlashLL>
/ shape = rectangle
/ size = (50%, 50%)
/ color = (0, 0, 0)
/ position = (25%, 75%)
</shape>

<shape FlashL>
/ shape = rectangle
/ size = (50%, 100%)
/ color = (0, 0, 0)
/ position = (25%, 50%)
</shape>

<shape FlashR>
/ shape = rectangle
/ size = (50%, 100%)
/ color = (0, 0, 0)
/ position = (75%, 50%)
</shape>


<list x1>
/ items = (60%, 65%, 70%, 75%, 80%, 85%, 90%)
/ selectionrate = always
/ selectionmode = random

</list>

<list y1>
/ items = (10%, 15%, 20%, 25%, 30%, 35%, 40%)
/ selectionrate = always
/ selectionmode = random
</list>

<list x2>
/ items = (60%, 65%, 70%, 75%, 80%, 85%, 90%)
/ selectionrate = always
/ selectionmode = random
</list>

<list y2>
/ items = (10%, 15%, 20%, 25%, 30%, 35%, 40%)
/ selectionrate = always
/ selectionmode = random
</list>

<list Colors>
/ items = (red, blue, green, yellow, violet, black, grey)
/ selectionrate = always
/ selectionmode = random
</list>




**************************************************************************************************************
**************************************************************************************************************
                                          MAIN TRIALS
**************************************************************************************************************
**************************************************************************************************************
<trial Instructions>
/ stimulusframes = [1=intro, begin]
/ validresponse = (begin)
/ recorddata = false
</trial>

<trial Memory>
/ trialduration = 1000
</trial>

<trial ISI>
/ trialduration = 900
</trial>


<trial Set1>
/ trialduration = 500
/ ontrialbegin = [trial.set1.clearstimulusframes()]
/ ontrialbegin = [trial.set1.insertstimulusframe(shape.FlashUR, 1)]
/ ontrialbegin = [trial.memory.clearstimulusframes()]
/ ontrialbegin = [trial.test.resetstimulusframes();]
/ ontrialbegin = [trial.test2.resetstimulusframes();]

/ ontrialbegin = [shape.s1.hposition = list.x1.nextvalue; shape.s1.vposition = list.y1.nextvalue; shape.s2.hposition = list.x1.nextvalue; shape.s2.vposition = list.y1.nextvalue;]
/ ontrialbegin = [shape.s1.color = list.colors.nextvalue; shape.s2.color = list.colors.nextvalue;]


/ ontrialbegin = [{trial.memory.insertstimulusframe(shape.s1, 1); trial.Memory.insertstimulusframe(shape.s2, 1);}]
/ ontrialbegin = [{trial.test.insertstimulusframe(shape.s1, 1); trial.test.insertstimulusframe(shape.s2, 1);}]
/ ontrialbegin = [{trial.test2.insertstimulusframe(shape.s1, 1); trial.test2.insertstimulusframe(shape.s2, 1);}]

</trial>



<trial ISI2>
/ trialduration = 500
</trial>



<trial Test>
/ stimulusframes = [1=Task, Same, Different]
/ validresponse = (Same, Different)
</trial>

<trial Test2>
/ stimulusframes = [1=Task, Same, Different]
/ validresponse = (Same, Different)
/ ontrialbegin = [shape.s2.color = list.colors.nextvalue]
</trial>

<trial Exit>
/ stimulusframes = [1=Done, Go]
/ validresponse = (Go)
</trial>



**************************************************************************************************************

**************************************************************************************************************
<block Instructions>
/ trials = [1=Instructions]
</block>

<block Task1>
/ trials = [1= Set1; 2= Memory; 3 = ISI; 4 = Test; 5 = ISI2]
/ ontrialbegin = [values.condition = 1]
</block>

<block Task2>
/ trials = [1= Set1; 2 = Memory; 3 = ISI; 4 = Test2; 5 = ISI2]
/ ontrialbegin = [values.condition = 2]
</block>


<block End>
/ trials = [1 = exit]
</block>








**************************************************************************************************************
**************************************************************************************************************
                                          EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************
<expt main>
/ blocks = [1 = Instructions;  2-251 = noreplace(Task1, Task2); 252 = End;]
</expt>


By Dave - 5/31/2014

> The problem is that the code below sometimes presents items on the same locations (e.g., uses the same y position for both
> items), sometimes presents the same color for both items (e.g., makes both shapes blue), and other times when replacing
> shape2 for different trials it does not change color, or changes color to the color of shape1. I assume this is because I am drawing
> randomly on each pass instead of randomly without replacement on each pass?  Any suggestions on how to remedy this?

No, you *are* sampling from your lists without replacement. But think about what is bound to happen as you keep doing so across trials. Let's take color as example. You have

<list Colors>
/ items = (red, blue, green, yellow, violet, black, grey)
/ selectionrate = always
/ selectionmode = random
</list>

i.e, 7 colors to draw from. In every round you draw 2 of those

/ ontrialbegin = [shape.s1.color = list.colors.nextvalue; shape.s2.color = list.colors.nextvalue;]

This means, after the 1st round, there'll be 5 unsampled colors left, after the 2nd round, there'll be 3 left, after the 3rd, there'll only be 1 unsampled color left. In the 4th round then, the single previously unsampled item will be assigned to shape.s1. Since no more unsampled items are left after that, the list's selection pool must be *reset*, thus returning *all 7 items* to the pool -- shape.s2 then, of course, can potentially be assigned the same color as shape.s1.

The position issue is in essence identical. The solution for both, then, is to properly call a list reset() between rounds

<trial set1>
/ ontrialbegin = [list.colors.reset(); ...]
...
</trial>
By nashby - 6/1/2014

Thanks that worked.