Reply To: Trial judgement and present unequal fillers

PennController for IBEX Forums Support Trial judgement and present unequal fillers Reply To: Trial judgement and present unequal fillers

#9575
Jeremy
Keymaster

Hi,

1. I’m not sure I understand: what’s wrong with the way you’re currently coding the design? (other than that you might want to remove the Canvas element instead of just the Image element, so that the Controller elements do not appear so far down on the page)

If you find it easier to code the two tasks that constitute a trial separately, you can always create two functions that each return an array of PennController commands, and call those functions inside the newTrial so the commands are executing sequentially, eg:

const pic = row => [
    newImage("pic", row.pic_name).size(720, 405).print()
    ,
    newCanvas("canvas_pic",720,405)
        .add( 0, 0, getImage("pic"))
        .center()
        .print()
    ,
    newTimer("displaytime", 2000).start()
    ,
    newKey("resp-flanker", "FJ")
        .log()
        .callback( getTimer("displaytime").stop() )
    ,
    getTimer("displaytime").wait()
    ,
    getCanvas("canvas_pic").remove()
];

const spr = row => [
    newController("DashedSentence", {s: row.sent_cont})
        .print()
        .log()
        .wait()
        .remove()
    ,
    newController("Question", {q: "Does it make sense?", as: ["Yes", "不合理"]})
        .print()
        .log()
        .wait()
        .remove()
];

Template("items.csv", row =>
    newTrial("experimental-trial",
        ...pic(row)
        ,
        ...spr(row)
    )
)

2. Do you mean that between each target trial (ie. pic+spr pair) you want to have 1-to-3 filler trials? And that you would have 20 occurrences of those filler breaks, and you want the total of filler trials to sum up to 40?

3. This will depend on the answer to question 2. If you have, say, 40 trials labeled “target” and 40 trials labeled “filler”, then rshuffle("target","filler") would give you just that: a series of 80 trials alternating between trials labeled “target” and trials labeled “filler”

On the other hand, if you have 20 target trials and 40 filler trials, and want to insert 1-to-3 filler trials after each target trial, which is how I understand your second point, then you could define this function to generate an array of random integers that sum up to a set value:

const nRandomIntsToSum = (length,minInt,maxInt,targetSum) => {
  const a = [];
  for (let i=0; i<length; i++) {
    let min = minInt, max = maxInt, remainder = targetSum-(a.reduce((x,y)=>x+y,0)+min*(length-(i+1)));
    if (remainder < maxInt) max = remainder;
    a.push( min+Math.round(Math.random()*(max-min)) );
  }
  fisherYates(a);
  return a;
}

Then you can use the custom pick function in 20 iterations, like this:

targets = randomize("target")
fillers = randomize("filler")
repetitions = nRandomIntsToSum(20,1,3,40)

Sequence(
  "instructions", 
  ...repetitions.map(n=>[ pick(targets,1),pick(fillers,n) ]).flat()
)

Jeremy