Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
MR_Riley

Junior Member
Registered:
Posts: 8
Reply with quote  #1 
Hello all,

I am having some difficulties with creating a manual function to change blocks during a session. I'd like to be able to change the blocks after the subject completes a series of correct trials in a row on the same block (right now 4 trials). I used the previous website's Trial Record and task submenu pages in addition to searching here, but I couldn't find a good example to base my script off of.

Here is the function in its entirety.

function BlockChange=performance_based_block_change(TrialRecord)
neededcorrecttrials=4;
if TrialRecord.CurrentTrialNumber==1
    BlockChange=1;
else
    StateCodes=TrialRecord.TrialErrors;
    BlocksRun=TrialRecord.CurrentBlock;
    TrialNumber=TrialRecord.CurrentTrialNumber;
    if length(StateCodes)>10
        if sum(StateCodes(TrialNumber-(neededcorrecttrials-1)):StateCodes(TrialNumber))==0
            if sum(BlocksRun((TrialNumber-(neededcorrecttrials-1)):BlocksRun(TrialNumber)))/neededcorrecttrials==BlocksRun(TrialNumber)
                if BlocksRun(TrialNumber)==length(BlocksToRun)
                    BlockChange=1;
                else
                    %  BlockChange=BlocksRun(obj.CurrentTrialNumber)+1;
                    BlockChange=1;
                end
            else
                BlockChange=0;
            end
        else
            BlockChange=0;
        end
    elseif length(TrialRecord.TrialErrors)==1
        BlockChange=1;
    else
        BlockChange=0;
    end
end

Whenever I run a task with this, it defaults to the first block as it should, but does not switch after 10 trials if I have 4 in a row correct.

If anyone could assist me in figuring out what I did wrong, I would greatly appreciate it.
0
Jaewon

Administrator
Registered:
Posts: 615
Reply with quote  #2 
Your intention is not clear.

Do you want to change the block when the last 4 trials were correct in a row or when 4 trials were correct in a row out of the last 10 trials?

If you count them for 10 trials, do you need to do that every 10 trials (like at the 10th, the 20th, the 30th, ...) or every trial from the 10th (like 1-10, 2-11, 3-12, ...)
0
MR_Riley

Junior Member
Registered:
Posts: 8
Reply with quote  #3 
Quote:
Originally Posted by Jaewon
Your intention is not clear.

Do you want to change the block when the last 4 trials were correct in a row or when 4 trials were correct in a row out of the last 10 trials?

If you count them for 10 trials, do you need to do that every 10 trials (like at the 10th, the 20th, the 30th, ...) or every trial from the 10th (like 1-10, 2-11, 3-12, ...)


The former: when the last four trials are correct in a row.

I kept the 10 trials as a initial barrier so that this would be after the first 10 trials of the session. After 10 trials, it's fine if it switches every four trials or so.
0
Jaewon

Administrator
Registered:
Posts: 615
Reply with quote  #4 
I think this will do the work. The result of each trial should be being registered with the trialerror() function in your timing script. The first block change will occur at the 11th trial, if Trial 7-10 are correct.

function BlockChange=performance_based_block_change(TrialRecord)

BlockChange = false;
if 10<=length(TrialRecord.TrialErrors) && 4==sum(0==TrialRecord.TrialErrors(end-3:end))
    BlockChange = true;
end

end
0
MR_Riley

Junior Member
Registered:
Posts: 8
Reply with quote  #5 
When I tried that code with my script, it began pausing the session after every trial, and said that it exceeded the desired ITI. I've attached the pause screen with this reply as well as the inputs that I've been using from the GUI to ensure that I'm using it in the appropriate place.

Attached Images
jpeg ML error report.jpg (104.96 KB, 3 views)
jpeg ML error report inputs.jpg (209.42 KB, 3 views)

0
Jaewon

Administrator
Registered:
Posts: 615
Reply with quote  #6 
On the main menu, you set "Total # of blocks to run" to 2 and all your trials from Trial 2 were correct. When Trial 10 was finished, 4 trials (Trial 7-10) succeeded in a row, so Block 2 began at Trial 11. When Trial 11 was finished, 4 trials (Trial 8-11) succeeded in a row again and Block 3 was supposed to start from Trial 12, but "Total # of blocks to run" was 2, so ML paused the task there.

"Desired IT exceeded" showed up just because the pausing time was added to the ITI and you forced the task to resume.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.