Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
fadidehvar

Junior Member
Registered:
Posts: 4
Reply with quote  #1 
Hi
is it possible to access to "total number of trials to run" for defining a trial selection function?
i use a userloop mfile and want to count only correct trial as number of trial to run.
0
Jaewon

Administrator
Registered:
Posts: 424
Reply with quote  #2 
"Total # of trials to run" is defined in MLConfig, but MLConfig cannot be overwritten, unlike TrialRecord. Any change you make to MLConfig will be reverted when a trial ends. In addition, "Total # of trials to run" does not distinguish correct trials from others, so it is not what you want, I think.

If you want to pause (or quit) the task when the subject correctly completes a certain number of trials, first register the result of each trial by calling trialerror() in the timing file. Then the history of the results will be kept in TrialRecord.TrialErrors, so you can count the number of correct trials like sum(0==TrialRecord.TrialErrors). You can use it to pause (or quit) the task in two ways.

The first method is to add a command like the following at the end of the timing file.

if max_trial==sum(0==[TrialRecord.TrialErrors TrialErrorOfCurrentTrial]), TrialRecord.Pause = true; end  % or TrialRecord.Quit = true;

TrialRecord has the information until the last trial, so, to take the current trial into account, you need to add the current result to the sum.

The other way is to do it in the alert_function.m.

switch hook
    case 'task_start'
    case 'block_start'
    case 'trial_start'
    case 'trial_end'
        if max_trial==sum(0==TrialRecord.TrialErrors), TrialRecord.Pause = true; end  % or TrialRecord.Quit = true;
    case 'block_end'

    case 'task_end'
    case 'task_paused'
    case 'task_resumed'
    case 'task_aborted'
end

The alert function is called after the information of the current trial is added to TrialRecord, so counting just TrialRecord.TrialErrors is fine. If you need a separate alert_function for different tasks, make a copy of it in the task directory and edit the copy.
0
fadidehvar

Junior Member
Registered:
Posts: 4
Reply with quote  #3 
thanks Jaewon for your reply.
i want to resume task until the number of correct trial is equal to number of trials to run.
to do that, i should choose a large number for number of trial to run and then use the solution you suggest or there is an other way to resume task even if the number of trial is equal to number of trial to run?

 
0
Jaewon

Administrator
Registered:
Posts: 424
Reply with quote  #4 
Once "Total # of trials to run" is reached, the task will pause every trial thereafter. So you need to do it in the first way you said. Set a large number for "Total # of trials to run" and count correct trials as I suggested.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.