Home Examples Error Trials: Repeating and/or Reporting
Coding Tips

Error Trials: Repeating and/or Reporting

This example demonstrates how a trial can be forced to be repeated. In this context, an error trial is a trial in which the subject has done something incorrectly (e.g. did not reach to a target). In this example, we set up the task to both repeat and record the error, however, only one or the other need be done. In other words they are independent from each other, so if both types of functionality are desired, then both need to be implemented.

In order to potentially repeat the trial (which will occur at the end of the current block), the Repeat_Trial_Flag input of the GUI Control block is used. This input is only available if Show repeat trial flag has been checked in the GUI Control dialog. Its purpose being to allow the option for a trial to be repeated if desired. However, in order to understand what will actually occur during a task, it is important to realize that Repeat Error Trials control in Dexterit-E is multi-tiered. Dexterit-E allows an operator to choose whether or not the Repeat_Trial_Flag is ignored using the Repeat Error Trials checkbox from within the Task Protocol editor. The table below shows the combinations under which a trial is or is not repeated.

Table 10.2: Conditions for Repeating a Trial

Repeat_Trial_Flag value sent to GUI Control block
Repeat_Trial_Flag=0 Repeat_Trial_Flag=1
Repeat Error Trials checkbox in Dexterit-E protocol editor checked Not repeated Repeated
unchecked Not repeated Not repeated

In order to report a trial as being an error trial to the Dexterit-E User Interface, a Task Event Code has to be created to report the error and that Task Event Code needs to be defined as error-reporting. Task Event Codes can be set as error-reporting in the Parameter Table Dfn block by setting the Options field to error for the Task Event Code. Multiple error-reporting Task Event Codes can be defined for a single task. If any error-reporting Task Event Code occurs during a trial, Dexterit-E records that trial as an error-trial and the percent correct statistics in the Dexterit-E window are updated appropriately.

Figure 10.18: Parameter Table Defn Block Error – Reporting Task Event Code

Figure 10.19: Dexterit-E Trial Statistics Window

Note: If your task does not have any Task Event Codes defined with the error option, then the Trial Statistics window will be hidden.

10.12.1   Simulink Code for Error Trials: Repeating and/or Reporting Example

In this example, a connection is made from the Stateflow chart to the Repeat_Trial_Flag input of the GUI Control block, after checking Show repeat trial flag input.

Figure 10.20: Simulink Code for Error Trials: Repeating and/or Reporting Example

10.12.2     Stateflow Chart for Error Trials Repeating or Reporting Example

In order to repeat an error trial, the new Stateflow output repeat_trial must be set as desired from within Stateflow (e.g. if something does not occur as desired, then set repeat_trial=1). In the example shown below, repeat_trial is set =0 at the start of each trial. If the subject does not reach to the second target before a given time has expired (i.e. from tickCount = Trial_Protocol(REACH_TIMEOUT)), then repeat_trial=1 is set.

If the subject does not reach to the second target before a given time has expired then event_code=E_REACH_TIMEOUT is also set. This Task Event Code will be stored as part of the trial’s data file and so can be used by subsequent data analysis to indicate that this trial was an error trial. Stateflow Code for 10.12 Error Trials: Repeating and/or Reporting.

Figure 10.21: Stateflow Chart for Error Trials: Repeating and/or Reporting Example

Related Tasks

Coding Tips
Persistent Variables
Persistent variables are ones that hold their value between calls to the embedded MATLAB code they are defined in.
Coding Tips
Custom Control of the Trial Protocol Order
Normally, Dexterit-E manages and controls the order in which Trial Protocols (TPs) execute based on what is defined in the block table of the Task Protocol (see the Dexterit-E User Guide for more details).