Reply To: Switching between multiple tasks

PennController for IBEX Forums Support Switching between multiple tasks Reply To: Switching between multiple tasks

#8144
Jeremy
Keymaster

Hello,

In the demo that you shared, there is a single newTrial which includes both task types. It is my understanding from what you said (that two tasks of the same type can follow each other) that you want to decouple the two, ie. not have them inside a single newTrial command. That would also mean no longer associating specific sentences with specific sets of flanker images the way your table is currently set up. The most convenient way to start on that would be to use two different CSV tables for each task type

Then you can create different newTrials inside different Template commands, giving different labels to trials of each task type. Once you have such labeled trials, you can define a custom predicate function to shuffle your trials as you’d like, for example:

const popAelseB = (a,b) => a.pop()||b.pop()
function LatinMix(a, b) {
    this.args = [a,b];

    this.run = function(arrays) {
        assert(arrays.length == 2, "Wrong number of arguments (or bad argument) to LatinMix");
        let as = arrays[0];
        let bs = arrays[1];
        let newArray = [];
        let i = 0;
        while (as.length || bs.length){
            newArray.push( [
                i%2 ? popAelseB(as,bs) : popAelseB(bs,as),
                (i+1)%4<2 ? popAelseB(as,bs) : popAelseB(bs,as)
            ] );
            i++;
        }
        fisherYates(newArray);
        return newArray.flat();
    }
}
function latinMix(a, b) { return new LatinMix(a, b); }

You can use the function in Sequence like this:

Sequence( latinMix(randomize("sentence"),randomize("flanker")) )

Template("flanker.csv", row => newTrial("flanker", /* ... */ ) )
Template("sentence.csv", row => newTrial("sentence", /* ... */ ) )

Jeremy