PennController for IBEX › Forums › Support › Counterbalancing issues › Reply To: Counterbalancing issues
April 20, 2022 at 11:43 am
#8088
Jeremy
Keymaster
Hi Mieke,
As reported in the Errors tab of the debugger, you are creating multiple Image elements with the same name, which causes problems when you refer back to them later (eg. getImage("Topleft_image").visible()
). See explanations here
Here is a possible solution, let me know if it works as you expect:
FillerDisplays = ["A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C", "C", "D", "D", "D", "D", "D", "D"]; TargetDisplays = ["A", "A", "A", "B", "B", "B", "C", "C", "C", "D", "D", "D"]; fisherYates(FillerDisplays) fisherYates(TargetDisplays) DisplayMap = { A: {TopLeft: "CorAgent", TopRight: "FoilAgent", BottomRight: "CorTheme", BottomLeft: "FoilTheme"}, B: {TopLeft: "FoilAgent", TopRight: "CorAgent", BottomRight: "CorTheme", BottomLeft: "FoilTheme"}, C: {TopLeft: "CorAgent", TopRight: "FoilAgent", BottomRight: "FoilTheme", BottomLeft: "CorTheme"}, D: {TopLeft: "FoilAgent", TopRight: "CorAgent", BottomRight: "FoilTheme", BottomLeft: "CorTheme"} } Template("trials.csv", row => newTrial("Trials", defaultImage.hidden() , newVar("dropped", 0) , newFunction( ()=> $("body").css({width: '100vw',height: '100vh'}) ).call() , getVar("nTrials") .log() .test.is(18) .success( newHtml("HalfWay", "Halfway.html") .center() .cssContainer({"width":"720px"}) .print("center at 50%", "middle at 50%") , newButton("continue", "Continue to the next trial") .center() .print("center at 50%", "middle at 80%") .wait() , fullscreen() , clear() ) , newFunction( ()=> $("body").css('cursor','none') ).call() , newImage("Al", "Al.png") .size("15vw", "20vh") .print("center at 50%", "middle at 50%") , newImage("Speaker", "speaker_green.png") .size("7vw", "7vw") .print("center at 50%", "middle at 50%") , newAudio("TestSentence", row.TestSentence) , displayGroup = (row.StimulusType=="Target"?TargetDisplays.pop():FillerDisplays.pop()) , defaultImage.log().size("30vw","30vh") , newImage("Topleft_image", row[DisplayMap[displayGroup].TopLeft]).print("center at 25%", "middle at 25%") , newImage("Topright_image", row[DisplayMap[displayGroup].TopRight]).print("center at 75%", "middle at 25%") , newImage("Bottomright_image", row[DisplayMap[displayGroup].BottomRight]).print("center at 75%", "middle at 75%") , newImage("Bottomleft_image", row[DisplayMap[displayGroup].BottomLeft]).print("center at 25%", "middle at 75%") , newAudio("Topleft_audio", row[DisplayMap[displayGroup].TopLeft+"_sound"]) , newAudio("Topright_audio", row[DisplayMap[displayGroup].TopRight+"_sound"]) , newAudio("Bottomright_audio", row[DisplayMap[displayGroup].BottomRight+"_sound"]) , newAudio("Bottomleft_audio", row[DisplayMap[displayGroup].BottomLeft+"_sound"]) , newText("Display_"+displayGroup).print() , getImage("Al").visible() , newAudio(IntroSentence[Math.floor(Math.random() * 3)]).play().log().wait() , getImage("Topleft_image").visible() , getAudio("Topleft_audio").play().log().wait() , newTimer(300).start().wait() , getImage("Topright_image").visible() , getAudio("Topright_audio").play().log().wait() , newTimer(300).start().wait() , getImage("Bottomright_image").visible() , getAudio("Bottomright_audio").play().log().wait() , newTimer(300).start().wait() , getImage("Bottomleft_image").visible() , newAudio(And[Math.floor(Math.random() * 12)]).play().log().wait() , getAudio("Bottomleft_audio").play().log().wait() , newTimer(500).start().wait() , getImage("Al").hidden() , newTimer(200).start().wait() , getImage("Speaker").visible().log() , getAudio("TestSentence").play().log().wait() , newTimer(200).start().wait() , getImage("Speaker").hidden().log() , getImage("Al").visible().log() , newKey(" ").wait() , clear() , getVar("nTrials").set( v => v+1) // increase nTrials ) .log("Quantifier", row.Quantifier) .log("Version", row.Version) .log("Item", row.Item) .log("StimulusType", row.StimulusType) .log("Group", row.Group) .log("Sentence", row.Sentence) .log("Verb", row.Verb) .log("CorAgent", row.CorAgent) .log("FoilAgent",row.FoilAgent) .log("CorTheme",row.CorTheme) .log("FoilTheme",row.FoilTheme) .log("TestSentence",row.TestSentence) .log("CorAgent_sound",row.CorAgent_sound) .log("FoilAgent_sound",row.FoilAgent_sound) .log("CorTheme_sound",row.CorTheme_sound) .log("FoilTheme_sound",row.FoilTheme_sound) .log("DisplayGroup", displayGroup) )
Jeremy