PennController for IBEX › Forums › Support › Creating visual stimuli from a csv › Reply To: Creating visual stimuli from a csv
April 11, 2022 at 11:52 am
#8031

Keymaster
Hi,
At this point you’d be better off handling the shuffling part using javascript:
Template("dotmemorization.csv", row => newTrial("dot-baseline", defaultImage.size(40,40).css("border", "solid 1px gray") , newCanvas("grid", 200,200) , rs = [...new Array(25)].map((v,i)=>(i<row.nDots?true:false)) , fisherYates(rs) , rs.map((v,i)=>[ newImage('w'+i,'white.png').print(40*(i%5),40*Math.floor(i/5),getCanvas("grid"))[v?'hidden':'visible'](), newImage('b'+i,'black.png').print(40*(i%5),40*Math.floor(i/5),getCanvas("grid"))[v?'visible':'hidden']() ]) , getCanvas("grid", 200,200).center().print() , // display for X seconds newTimer("display-for-3", 3000) .start() .wait() , newCanvas("overGrid", 200,200).color("white").print(1,1,getCanvas("grid")) , newTimer("blank-for-3", 3000) .start() .wait() , (row.match=="False"?[ getImage('b'+rs.findIndex(v=>v===true)).hidden(), getImage('w'+rs.findIndex(v=>v===true)).visible(), getImage('b'+rs.findIndex(v=>v===false)).visible(), getImage('w'+rs.findIndex(v=>v===false)).hidden() ]:null) , getCanvas("overGrid").remove() , newText("prompt", "This grid matches the previous grid.") , newButton("True","True") , newButton("False","False") , newCanvas("choice", 200,200) .add(0, 0, getText("prompt")) .add(0, 50, getButton("True")) .add(50, 50, getButton("False")) .center() .print() , newVar("answer") , newSelector("choice") .add(getText("prompt")) .add(getButton("True")) .add(getButton("False")) .wait() .setVar("answer") .log() .test.selected( getButton(row.match) ) .failure( jump("no-interference") ) ) )
Note that you need to add a column named nDots
to your table, reporting how many cells on the grid should use black.png. I got rid of the Selector element, since you’re not making use of it (you’re not asking the participant to click on a cell). There also seems to be a bug with using hidden
and visible
on the Canvas element after using those same commands on the Image elements that it contains, so I resorted to printing a second, opaquely white Canvas element on top of it to mask its content
Jeremy