Welcome! Log In Create A New Profile

Advanced

cond_selector not randomizing condition on first trial

Posted by cfeigen90 
cond_selector not randomizing condition on first trial
March 06, 2025 04:29PM
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
Re: cond_selector not randomizing condition on first trial
March 07, 2025 12:51AM
I do not see such a problem during my tests. The condition of the first trial in each block is as random as it can get on my computer.

What you need to check is whether the condition assigned in the selector function and the current condition in your timing script are the same. If so, there is nothing wrong in getting the first condition at the beginning of each block. Using randi() does not exclude the possibility that the first condition in the block is chosen when a new block begins, although it should not happen "always".

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.