Set position of shape in a list?


Author
Message
nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
Thanks that worked. 
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: 108K
> 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>

nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
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>



nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
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.

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: 108K
> 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.

nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
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?

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: 108K
> 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 :(

nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
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?


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: 108K
> 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?

nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
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.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search