PennController for IBEX › Forums › Support › Problems inserting locations from table for selector › Reply To: Problems inserting locations from table for selector
October 21, 2020 at 1:14 pm
#6230
Keymaster
Hello,
I think your code is a little more complex than it needs to be, and maybe doesn’t do exactly what you want it to do. Keep in mind that PennController executes the trial’s script in a linear top-down stream unless you use special commands (such as callback). Your design seems perfectly adapted to a linear execution, so I rewrote your code like this:
Template( variable =>
newTrial( "trialin" ,
// Start by creating the image, but don't print it yet
// Its width will adapt to the screen width (75%)
newImage("imagefile", variable.Imagein).size("75vw", "auto")
,
newSelector("choice").log()
,
// All images below this will be 2vw x 2vw, hidden, and in the selector
defaultImage.size("2vw","2vw").hidden().selector("choice")
,
// 75% screen width, 75% screen height
newCanvas("images", "75vw", "75vh")
// Place the main image at the center of the Canvas
.add("center at 50%", "middle at 50%", getImage("imagefile") )
// Now place the 6 (hidden) AOIs on the Canvas
.add("center at 25%", "middle at 70%", newImage("aoiLM", "square.png") ) //left.middle
.add("center at 75%", "top at 90%", newImage("aoiRL", "square.png") ) //right low
.add("center at 80%", "middle at 70%", newImage("aoiRM", "square.png") ) //right middle
.add("center at 27%", "middle at 90%", newImage("aoiLL", "square.png") ) //left low
.add("center at 27%", "middle at 40%", newImage("aoiLH", "square.png") ) //left high
.add("center at 75%", "middle at 40%", newImage("aoiRH", "square.png") ) //right high
// Finally, place a button at the top of the Canvas
.add("center at 50%", "middle at 0%", newButton("start") )
// Use print here only, it will display the Canvas' (non-hidden) content
.print()
,
// Script will stay on this line until button is clicked, then remove it
getButton("start").wait().remove()
,
// Button has been clicked: play the audio
newAudio("audiofile", variable.Audio).play()
,
// Start mouse-tracking right away (no wait on Audio)
newMouseTracker("mouse").log().start()
,
// Show this trial's AOIs
getImage(variable.aoiactive1).visible(),
getImage(variable.aoiactive2).visible(),
getImage(variable.aoiactive3).visible()
,
// Script will stay on this line until an AOI is clicked
getSelector("choice").wait()
,
// Stop the mouse tracker once an AOI is clicked
getMouseTracker("mouse").stop()
,
// Stop the audio early in case it hasn't fully played yet
getAudio("audiofile").stop()
)//trial end
)//template end
And here are the first two lines of my table:
Audio,Imagein,aoiactive1,aoiactive2,aoiactive3 audio.wav,lees.png,aoiLH,aoiRM,aoiRL
Hopefully the script and setup above are self-explanatory, but please let me know if you have questions
Jeremy