Welcome! Log In Create A New Profile

Advanced

Using a conditions selection function and block selection function

Posted by cfeigen90 
Using a conditions selection function and block selection function
July 19, 2023 06:35PM
Hello,

I am trying to get my conditions and block selection functions to work together. They work properly when used separately. I believe the issue is that my conditions are spread over several blocks (i.e. conds 1-4 are block 1, conds 5-8 are block 2 etc). When the block selector appropriately switches from block 1 to block 2, monkeylogic throws an error " Condition # 1 does not exist". This only happens when I use the block selector in tandem with the conditions selector.
Here is the code for both

function cond_change = cond_selector(TrialRecord)
this_trial = TrialRecord.CurrentTrialNumber;
if this_trial == 1
cond_change=1;
return
end
condOptions = TrialRecord.User.CondThisBlock;
cond_change = randsample(condOptions,1);

function NextBlock = block_selector(TrialRecord)
if TrialRecord.User.allDone==100
NextBlock = 1; % proceed to next block
else
NextBlock = 0; % continue current block
end

Thank you in advance!
Re: Using a conditions selection function and block selection function
July 20, 2023 05:11PM
Since you switched from Block1 to Block2, your conditions selector should have returned a number between 5 and 8, but it returned 1, which was not in Block2.
Re: Using a conditions selection function and block selection function
July 20, 2023 05:34PM
Ok, thank you. I will attempt to fix this by reading in the conditions file and telling the condition selector to select possible conditions based on blocks.
Re: Using a conditions selection function and block selection function
July 20, 2023 06:06PM
See this manual page. The conditions that you can choose in the current block is in TrialRecord.ConditionsThisBlock.
https://monkeylogic.nimh.nih.gov/docs_TrialRecordStructure.html

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.