I wrote a condition selector that is functioning properly except that the random integer generator for selecting the first trial condition fails to assign the condition. I tested the condition selector and the variable being assigned using the randi function is getting registered (i.e. for randi(5) CurrentCondition does get set to some value 1:5). Nevertheless, the first trial of every block is always the first condition listed for that block in the conditions file when ML is run. Here is the script for the cond_selector:
function CurrentCondition = cond_selector( TrialRecord )
if TrialRecord.CurrentTrialWithinBlock == 1
CurrentCondition = TrialRecord.ConditionsThisBlock( randi(5) );
else
whichRow = TrialRecord.User.novelsByBlock{ TrialRecord.CurrentBlock };
if TrialRecord.User.novelsByBlock{ whichRow, 5 } == 1 % this is true after completion of bonus trials
CurrentCondition = -1;
else
condOptions = TrialRecord.User.CondThisBlock;
CurrentCondition = randsample( condOptions, 1 );
end
end