Most experiments consist of various phases. In order to break these phases up into their logical pieces and control the flow of your program from one phase to another task functions are extremely helpful. Tasks (created with the viztask module) control the order of events by pausing and waiting for specific conditions to be met, like a key press or an action to end, before they proceed. In this way, when one phase of the experiment is done, another can be set in motion.
Our experiment will have the following phases:
First we'll take this information and build a framework for our script using viztask. After that we'll go through these phases one by one and add the code to make each one a working component.
The following code takes our outline from above and translates it into the main viztask function (i.e. experiment). As you can see, the flow of the program is easy to read. Each phase is contained within a subtask function (i.e. participantInfo, learnPhase, testPhase). Both participantInfo and testPhase return data that will be saved to a text file.
Next, definitions for each subtask are added. Place the following code at the end of your script. The pass statements are placeholders we'll soon replace with code to make each subtask a functional component of the program.