PennController for IBEX › Forums › Support › Creating visual stimuli from a csv › Reply To: Creating visual stimuli from a csv

Hi Inthat,
You might be interested in this guide on using Javascript in your code: you don’t need to create Var elements to execute different code depending on the value of the cells from the current row
Other than that, most of your trials do show a black square, but in some cases a white square is printed over the black square. For example, when r5c1
is 1 you print a black square at the bottom-left corner of the grid, and when r5c5
is 0 you also print a white square at the exact same position, resulting in a visually blank grid
Independently of that, I suspect that you mean to create 25 Image elements (one per cell on your grid) but you currently create two Image elements that you move around with each test
. My suggestion is, use Javascript ternary conditionals to create an Image element with the appropriate file for each cell:
Template("dotmemorization.csv", row => newTrial("experimental-trial-pic", newSelector("input") , defaultImage.size(40,40).css("border", "solid 1px gray").selector("input") , newCanvas("grid", 200,200) // row 1 .add( 0, 0, row.r1c1==1?newImage("black.png"):newImage("white.png") ) .add( 40, 0, row.r1c2==1?newImage("black.png"):newImage("white.png") ) .add( 80, 0, row.r1c3==1?newImage("black.png"):newImage("white.png") ) .add(120, 0, row.r1c4==1?newImage("black.png"):newImage("white.png") ) .add(160, 0, row.r1c5==1?newImage("black.png"):newImage("white.png") ) // row 2 .add( 0, 40, row.r2c1==1?newImage("black.png"):newImage("white.png") ) .add( 40, 40, row.r2c2==1?newImage("black.png"):newImage("white.png") ) .add( 80, 40, row.r2c3==1?newImage("black.png"):newImage("white.png") ) .add(120, 40, row.r2c4==1?newImage("black.png"):newImage("white.png") ) .add(160, 40, row.r2c5==1?newImage("black.png"):newImage("white.png") ) // row 3 .add( 0, 80, row.r3c1==1?newImage("black.png"):newImage("white.png") ) .add( 40, 80, row.r3c2==1?newImage("black.png"):newImage("white.png") ) .add( 80, 80, row.r3c3==1?newImage("black.png"):newImage("white.png") ) .add(120, 80, row.r3c4==1?newImage("black.png"):newImage("white.png") ) .add(160, 80, row.r3c5==1?newImage("black.png"):newImage("white.png") ) // row 4 .add( 0, 120, row.r4c1==1?newImage("black.png"):newImage("white.png") ) .add( 40, 120, row.r4c2==1?newImage("black.png"):newImage("white.png") ) .add( 80, 120, row.r4c3==1?newImage("black.png"):newImage("white.png") ) .add(120, 120, row.r4c4==1?newImage("black.png"):newImage("white.png") ) .add(160, 120, row.r4c5==1?newImage("black.png"):newImage("white.png") ) // row 5 .add( 0, 160, row.r5c1==1?newImage("black.png"):newImage("white.png") ) .add( 40, 160, row.r5c2==1?newImage("black.png"):newImage("white.png") ) .add( 80, 160, row.r5c3==1?newImage("black.png"):newImage("white.png") ) .add(120, 160, row.r5c4==1?newImage("black.png"):newImage("white.png") ) .add(160, 160, row.r5c5==1?newImage("black.png"):newImage("white.png") ) .print() , newButton("press") .print() .wait() ) )
Jeremy