Placing images randomly without collision and retrieving the position of one image dynamically


Placing images randomly without collision and retrieving the position...
Author
Message
patruvius
patruvius
Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)
Group: Forum Members
Posts: 57, Visits: 1

I have tried to modify a script posted by Dave on this topic and despite using the list element and the counter element have not been able to find a solution.


Using the counter I get overlap of images despite my use of the not operator so possibly some simple error on my behalf - script below.


Using the list element I can get flawless displays, but cannot find out how to determine where the X image is placed on each iteration, so that I can use that to attach a target image in the second phase of the trial.


Counter Script:


<defaults>
/ screencolor = (0,0,0)
/ fontstyle = ("Arial", 20pt)
</defaults>

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

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Trial presents one type 1 stimulus and four type 2 stimuli
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<trial mytrial>
/ stimulustimes = [1= fixation,pic1,pic2,pic3,pic4,xpos]
/ validresponse = (anyresponse)
/ ontrialend = [reset(counter.type1xpos,counter.type1ypos,counter.type2xpos,counter.type2ypos,counter.type3xpos,counter.type3ypos,counter.type4xpos,counter.type4ypos)]
</trial>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 There will 16 possible displays for a 2x2 matric with 4 different images
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<text fixation>
/ items = ("+")
/ color = white
/ txbgcolor = (0,0,0)
/ fontstyle = ("Arial", 30pt)
/ erase = false
</text>
<picture pic1>
/items= ("letter X.png")
/ vposition = counter.type1xpos.selectedvalue
/ hposition = counter.type1ypos.selectedvalue
</picture>
<picture pic2>
/items= ("letter H.png")
/ vposition = counter.type2xpos.selectedvalue
/ hposition = counter.type2ypos.selectedvalue
</picture>
<picture pic3>
/items= ("letter I.png")
/ vposition = counter.type3xpos.selectedvalue
/ hposition = counter.type3ypos.selectedvalue
</picture>
<picture pic4>
/items= ("letter T.png")
/ vposition = counter.type4xpos.selectedvalue
/ hposition = counter.type4ypos.selectedvalue
</picture>


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Four candidate positions for pic1 stimulus (25% & 75%)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<counter type1xpos>
/ items = (25%,25%,75%,75%)
/ select = noreplace
</counter>
<counter type1ypos>
/ items = (25%,25%,75%,75%)
/ select = noreplace
</counter>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Candidate positions for pic2 stimuli (all positions but *not* the
 one already chosen for pic1  stimulus)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<counter type2xpos>
/ items = (25%,25%,75%,75%)
/ not = (type1xpos)
/ select = noreplace
/ selectionrate = always
</counter>
<counter type2ypos>
/ items = (25%,25%,75%,75%)
/ not = (type1ypos)
/ select = noreplace
/ selectionrate = always
</counter>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Candidate positions for pic3 stimuli (all positions but *not* the
 ones already chosen for pic1 or pic2 stimulus)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<counter type3xpos>
/ items = (25%,25%,75%,75%)
/ not = (type1xpos,type2xpos)
/ select = noreplace
/ selectionrate = always
</counter>
<counter type3ypos>
/ items = (25%,25%,75%,75%)
/ not = (type1ypos,type2ypos)
/ select = noreplace
/ selectionrate = always
</counter>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Candidate positions for pic3 stimuli (all positions but *not* the
 ones already chosen for pic1, pic2 or pic3 stimulus)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<counter type4xpos>
/ items = (25%,25%,75%,75%)
/ not = (type1xpos,type2xpos,type3xpos)
/ select = noreplace
/ selectionrate = always
</counter>
<counter type4ypos>
/ items = (25%,25%,75%,75%)
/ not = (type1ypos,type2ypos,type3ypos)
/ select = noreplace
/ selectionrate = always
</counter>
***********************
debug message
*************************

<text xpos>
/ items= (" X hposition = <% picture.pic1.hposition %> and vpos is <% picture.pic1.vposition %>")

</text>


List controlled counter


<defaults>
/ screencolor = (0, 0, 0)
/ fontstyle = ("Arial", 20pt)
</defaults>
***************************
Display Items
****************************
<text fixation>
/ items = ("+")
/ color = white
/ txbgcolor = (0,0,0)
/ fontstyle = ("Arial", 30pt)
/ erase = false
</text>

<item fourdistractors >
/1 = "letter X.png"
/1 = "letter H.png"
/2 = "letter I.png"
/3 = "letter T.png"
</item>
<picture fourd01>
/items = fourdistractors
/select = fourd01counter
/position = (25%,25%)
/erase = true(black)
/transparentcolor = (black)
</picture>

<picture fourd02>
/items = fourdistractors
/select = fourd02counter
/position = (25%,75%)
/erase = true(black)
/transparentcolor = (black)
</picture>

<picture fourd03>
/items = fourdistractors
/select = fourd03counter
/position = (75%,25%)
/erase = true(black)
/transparentcolor = (black)
</picture>

<picture fourd04>
/items = fourdistractors
/select = fourd04counter
/position = (75%,75%)
/erase = true(black)
/transparentcolor = (black)
</picture> 

***********************
Counters for 4 distractors
***********************
<list fourd01counter>
/items = (1,2,3,4)
</list>

<list fourd02counter>
/items = (1,2,3,4)
/not = (fourd01counter)
</list>

<list fourd03counter>
/items = (1,2,3,4)
/not = (list.fourd01counter.nextvalue, list.fourd02counter.nextvalue)
</list>

<list fourd04counter>
/items = (1,2,3,4)
/not = (list.fourd01counter.nextvalue, list.fourd02counter.nextvalue,list.fourd03counter.nextvalue)
/ selectionrate = trial
</list>

*************************
Trials
****************************
<trial displayone>
/ stimulustimes = [0=fixation; 500=fourd01,fourd02,fourd03,fourd04]
/ timeout= 3500
</trial>


*******************************
Blocks
********************************
<block jayblockone>
/ trials = [1=displayone]
/ bgstim = (fixation)
</block>




****************************
Experiment
****************************

<expt>

/ blocks = [1=jayblockone]

</expt>
********************************
debugging messages
********************************


With thanks,


Patrick


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
patruvius - 11 Years Ago
patruvius - 11 Years Ago
Dave - 11 Years Ago
patruvius - 11 Years Ago
                     [quote]<counter type2xpos> / items = ( 25.0000% ,25.0001%...
Dave - 11 Years Ago
                         Thanks again Dave.
I feel you are teaching the village idiot how...
patruvius - 11 Years Ago
                             Late Press:
This code produced no collisions over 20 tests:...
patruvius - 11 Years Ago
                                 Here's a short, fully functional snippet that should hopefully be...
Dave - 11 Years Ago
                                     Thank you so much Dave. Of course it works perfectly for my situation....
patruvius - 11 Years Ago
                                         [quote] Sorry I was so obtuse about getting to grips with the...
Dave - 11 Years Ago
                                             I just thought Sir Dave had a nice ring to it.
Need your help...
patruvius - 11 Years Ago
                                                 You should *not* reuse the 2nd counter. Its selection rate is set to...
Dave - 11 Years Ago
                                                     Dave,
below is the code of a text based stimulli.
What...
patruvius - 11 Years Ago
                                                         [quote]<counter type4ypos > / items = (25.0000%, 75.0000%,...
Dave - 11 Years Ago
                                                             Thank you, thank you Dave. I got this last night, drove home to try it...
patruvius - 11 Years Ago
                                                 [quote]Then i need to place other distractor images where the letters...
Dave - 11 Years Ago

Reading This Topic

Explore
Messages
Mentions
Search