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

Thank you, thank you Dave. I got this last night, drove home to try it and of course it works beautifully.


I now have all three components of the puzzle working - distractor, congruent (over X) and incongruent trials (not over X) working and can now possibly get back to my holiday.


I am very grateful as always. Inquisit would be impossible for me without you. I struggle for obvious intellectual deficits, but also because I only get asked occasionally for help with coding as most people here use pre-existing examples or simple questionnaire type applications.


I would like to do more and although I enjoy my interaction with Sir Dave, I would like to be more self reliant too.



cheers,



Patrick


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: 103K

<counter type4ypos>
/ items = (25.0000%, 75.0000%, 25.0000%, 75.0000%)
/ select = current(type3xpos)
/ selectionrate = always
</counter>


Wrong dependency. You are also omitting the necessary reset() of certain counters /ontrialend. Please refer to my example for that.


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

Dave,


below is the code of a text based stimulli.


What  happens with this is that the target or rather one of two targets always lands where the X was. So far so good.


Then I try placing one of the distractors - good, not on X but elsewhere.


Second distractor also good


Final distractor - clashes all over the place - on top of X or other distractors ????


<defaults>
/ screencolor = (0,0,0)
/ fontstyle = ("Arial", 30pt)
/ txcolor =  white
</defaults>

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

<trial mytrial>
/ stimulustimes = [1= fixation,txt1,txt2,txt3,txt4 ;500=twotargets,distractor1,distractor2,distractor3]
/ validresponse = (anyresponse)
</trial>

<text fixation>
/ items = ("+")
/ erase = false
/ txbgcolor = black
</text>
<text txt1>
/ items = ("X")
/ txbgcolor = black
/ hposition = counter.type1xpos.selectedvalue
/ vposition = counter.type1ypos.selectedvalue
/ erase = true(black)
</text>
<text txt2>
/ items = ("H")
/ txbgcolor = black
/ hposition = counter.type2xpos.selectedvalue
/ vposition = counter.type2ypos.selectedvalue
/ erase = true(black)
</text>
<text txt3>
/ items = ("I")
/ txbgcolor = black
/ hposition = counter.type2xpos.selectedvalue
/ vposition = counter.type2ypos.selectedvalue
/ erase = true(black)
</text>
<text txt4>
/ items = ("T")
/ txbgcolor = black
/ hposition = counter.type2xpos.selectedvalue
/ vposition = counter.type2ypos.selectedvalue
/ erase = true(black)
</text>
<counter type1xpos>
/ items = (25.0000%, 25.0001%, 75.0000%, 75.0001%)
/ select = noreplace
</counter>
<counter type1ypos>
/ items = (25.0000%,75.0000%,25.0000%,75.0000%)
/ select = current(type1xpos)
</counter>
<counter type2xpos>
/ items = (25.0000%, 25.0001%, 75.0000%, 75.0001%)
/ not = (type1xpos)
/ select = noreplace
/ selectionrate = always
</counter>
<counter type2ypos>
/ items = (25.0000%, 75.0000%, 25.0000%, 75.0000%)
/ select = current(type2xpos)
/ selectionrate = always
</counter>
<counter type3xpos>
/ items = (25.0000%, 25.0001%,75.0000%,75.0001%)
/ not = (type1xpos,type2xpos)
/ select = noreplace
/ selectionrate = always
</counter>
<counter type3ypos>
/ items = (25.0000%, 75.0000%, 25.0000%, 75.0000%)
/ select = current(type3xpos)
/ selectionrate = always
</counter>
<counter type4xpos>
/ items = (25.0000%, 25.0001%,75.0000%,75.0001%)
/ not = (type1xpos,type2xpos,type3xpos)
/ select = noreplace
/ selectionrate = always
</counter>
<counter type4ypos>
/ items = (25.0000%, 75.0000%, 25.0000%, 75.0000%)
/ select = current(type3xpos)
/ selectionrate = always
</counter>
+++++++++++++++++++++++++++++++++++
target placement
+++++++++++++++++++++++++++++++++++

<item targets>
/1 = "|"
/2 = "-"
</item>
<text twotargets>
/items = targets
/ txbgcolor = black
/select = twotargetscounter
/position = (type1xpos,type1ypos)
/erase = true(black)
</text>
<list twotargetscounter>
/items = (1,2)
</list>
+++++++++++++++++++++++++++++++++
Distractor placement
+++++++++++++++++++++++++++++++++
<text distractor1>
/ items = ("/")
/ txcolor = red
/ txbgcolor = white
/select = distractorxpos
/ hposition = (counter.distractorxpos.selectedvalue)
/ vposition = (counter.distractorypos.selectedvalue)
</text>
<text distractor2>
/ items = ("/")
/ txcolor = black
/ txbgcolor = red
/select = distractorxpos2
/ hposition = (counter.distractorxpos.selectedvalue)
/ vposition = (counter.distractorypos.selectedvalue)
</text>
<text distractor3>
/ items = ("\")
/ txcolor = yellow
/ txbgcolor = green
/select = distractorxpos3
/ hposition = (counter.distractorxpos.selectedvalue)
/ vposition = (counter.distractorypos.selectedvalue)
</text>

<counter distractorxpos>
/ items = (25.0000,25.0001, 75.0000, 75.0001)
/ select = noreplace
/ not = (type1xpos)
/ selectionrate = always
</counter>
<counter distractorypos>
/ items = (25.0000%, 75.0000%,25.0000%,75.0000%)
/ select = current(distractorxpos)
</counter>
<counter distractorxpos2>
/ items = (25.0000,25.0001, 75.0000, 75.0001)
/ select = noreplace
/ not = (type1xpos,type2xpos)
/ selectionrate = always
</counter>
<counter distractorypos2>
/ items = (25.0000%, 75.0000%,25.0000%,75.0000%)
/ select = current(distractorxpos2)
</counter>
<counter distractorxpos3>
/ items = (25.0000,25.0001, 75.0000, 75.0001)
/ select = noreplace
/ not = (type1xpos,type2xpos,type3xpos)
/ selectionrate = always
</counter>
<counter distractorypos3>
/ items = (25.0000%, 75.0000%,25.0000%,75.0000%)
/ select = current(distractorxpos3)
</counter>


Note: with the /not property, i have tried using the other distractor positions to exclude,


eg /not = (type1xpos, distractorxpos, distractorxpos2) for no difference in results.


This is all for the congruent trials where the target will be positioned over the X, but in incongruent trials the target(s) must not sit over the X, and in specifying the position of the target as I have for the congruent trials there is no equivalent property of an element such as hposition = not(type1xpos) is there?


Thanks again Dave for sticking with me with this it is driving me particularly batty.


At present I am at a place with little cell phone and therefore mobile broadband connection, so I have had to  drive my car about 20km (sorry 15 miles) to another town where there is some connection.


The joys of country living in Australia.


Patrick



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: 103K

Then i need to place other distractor images  where the letters H, I, and T were but in no particuar arrangement as long as they don't land on the target image.


Note that this is exaclty the same as the initial question (placing a target, placing other elements excluding target position). I.e. the exact same solution applies:


<counter distractorxpos>
/ items = (25.0000%, 25.0001%, 75.0000%, 75.0001%)
/ select = noreplace
/ not = (type1xpos)
/ selectionrate = always
</counter>

<counter distractorypos>
/ items = (25.0000%, 75.0000%, 25.0000%, 75.0000%)
/ select = current(distractorxpos)
</counter>


with your 3 distractor elements getting their postiions from the above counters.


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: 103K

You should *not* reuse the 2nd counter. Its selection rate is set to 'always', i.e., every time you access it, a new sample will be drawn.


The code is too incomplete for me to say anything more specific about it. If you could assemble a minimal, runnable example (just enough to convey the core logic; please use <text> elements only, I don't have your picture files), I may be able to give you a more useful answer.


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 just thought Sir Dave had a nice ring to it.


Need your help again though when I really thought I was on clear water.


I need to place a target image (rather one of two over where  the X was in the first display. No problems.


Congruent images are placed over most recent position of X
Incongruent trials place the target images other than where X has last been positioned
Using list counters to position images in either congruent positions on non-congruent positions
*********************************************************
<item targets>
/1 = "target horizontal.png"
/2 = "target vertical.png"
</item>
<picture twotargets>
/items = targets
/select = twotargetscounter
/position = (type1xpos,type1ypos)
/erase = true(black)
/transparentcolor = (black)
</picture>


<list twotargetscounter>
/items = (1,2)
</list>



Then i need to place other distractor images  where the letters H, I, and T were but in no particuar arrangement as long as they don't land on the target image.


I have tried to use the picture.pic2.hposition etc to replace those positions with the new images and I have tried to use the original  counter , using counter.pics. selected values


eg.


<picture rightslash2>
/items =("Right 45 distracter.png")
/hposition = counter.type2xpos.selectedvalue
/vposition = counter.type2ypos.selectedvalue
</picture>


even using screen messages to try and match up these positions doesn't bear a relationship with the actual positions of the original H, T and I images.?


<text ipos>
/ items= (" I position = <% counter.type2xpos.selectedvalue %> ,<% counter.type2ypos.selectedvalue %>")
/ position = (20%,35%)
</text> or


<text ipos>
/ items= (" I position = <% picture.pic3.hposition %> ,<% picture.pic3.vposition %>")
/ position = (20%,35%)
</text>


nether gives reliable results.


Any ideas?



regards,


Vassal patrick


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: 103K

Sorry I was so  obtuse about getting to grips with the principles here.


Absolutely no need to be sorry. I wish I could have made what I meant clearer from the get-go, but I couldn't quite put my finger on where the actual problem / misunderstanding was (I'm still not sure, really). Anyway, if you need me to elaborate on anything, let me know.


If you were British, I would recommend you for a knight hood.


That would mean I'd have to rescue maidens and slay dragons in the process, wouldn't it? Thanks, but I'll give this a pass. I'm not good with swords... :-)


Cheers,


~Dave


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

Thank you so much Dave. Of course it works perfectly for my situation. Sorry I was so  obtuse about getting to grips with the principles here. If you were British, I would recommend you for a knight hood.


Patrick


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: 103K

Here's a short, fully functional snippet that should hopefully be helpful. It's just a straightforward extension of the original example script to two dimensions (x and y coordinates instead of x coordinates only):


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

<trial mytrial>
/ pretrialpause = 500
/ stimulusframes =  [1=type1,type2a,type2b,type2c]
/ validresponse = (57)
/ ontrialend = [reset(counter.type2xpos)]
</trial>

<text type1>
/ items = ("Type 1")
/ hposition = counter.type1xpos.selectedvalue
/ vposition = counter.type1ypos.selectedvalue
</text>

<text type2a>
/ items = ("Type 2a")
/ hposition = counter.type2xpos.selectedvalue
/ vposition = counter.type2ypos.selectedvalue
</text>

<text type2b>
/ items = ("Type 2b")
/ hposition = counter.type2xpos.selectedvalue
/ vposition = counter.type2ypos.selectedvalue
</text>

<text type2c>
/ items = ("Type 2c")
/ hposition = counter.type2xpos.selectedvalue
/ vposition = counter.type2ypos.selectedvalue
</text>

<counter type1xpos>
/ items = (25.0000%, 25.0001%, 75.0000%, 75.0001%)
/ select = noreplace
/ selectionrate = trial
</counter>

<counter type1ypos>
/ items = (25.0000%, 75.0000%, 25.0000%, 75.0000%)
/ select = current(type1xpos)
</counter>

<counter type2xpos>
/ items = (25.0000%, 25.0001%, 75.0000%, 75.0001%)
/ select = noreplace
/ not = (type1xpos)
/ selectionrate = always
</counter>

<counter type2ypos>
/ items = (25.0000%, 75.0000%, 25.0000%, 75.0000%)
/ select = current(type2xpos)
</counter>


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

Late Press:


This code produced no collisions over 20 tests:


<counter type2xpos>
/ items = (25.0001%,25.0001%,75.0001%,75.0001%)
/ not = (type1xpos,type1ypos)
/ select = noreplace
/ selectionrate = always
</counter>
<counter type2ypos>
/ items = (75.0000%,25.0000%)
/ not = (type1ypos,type1xpos)
/ select = current(type2xpos)
/ selectionrate = always
</counter>


However, extending what I thought I had "seen" to the third image co-ordinates resulted in multiple collisions again. :-(


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search