Skip to content

Useful functions

roelandheerema edited this page Feb 23, 2023 · 8 revisions

Analysis scripts

There are currently no analysis scripts for decision-making data acquired with the OTG toolbox. These scripts will, however, gradually be added to the toolbox. For now, a convenient function is BEC_Compute_AUC.m that requires the 6 parameters (muPhi) as its input and computes the positive area under the indifference curve as its output (a value between 0 and 1, where larger values denote increased willingness to accept costly options for greater reward). Taking the AUC is a good starting point to analyze your data.

Convenience functions

The OTG toolbox includes a few functions that are typically useful for any Psychtoolbox-based experiment:

  1. Fixation cross with BEC_Fixation puts a fixation cross on screen of which the visual appearance is controlled in the exp_settings structure. The participant has the opportunity to leave the experiment while the fixation cross is on screen by pressing ESCAPE.

  2. Monitor a specific keypress with BEC_WaitForKeyPress. Enter the name of one or more keys, and the function will only output when the selected key or keys are pressed. It also has an arbitrary timeout time if no keys are pressed for a very long time.

  3. Show instruction figures with BEC_InstructionScreens. You can store instructions in the Stimuli folder saved as .PNG figures. This function creates a screen and puts the slides on screens. You enter either the names of the instructions (as specified in exp_settings) or you simply enter their numbers. Often, you will want to show multiple slides, say slides 5 to 8. This function allows the participant to browse back and forth through these slides with the arrow keys, avoiding that they miss some information when they accidentally press a key before having fully read an instruction.
    See BEC_Demo_DEER_Multisession.m for an example of how instructions were shown in a demo experiment. Similarly, the function BEC_Show_Another_Example.m asks if you would like to see another example (e.g. of a choice trial), and you can answer yes/no by pressing on the button keys (or by swiping on a tablet). This function is useful in a while-loop that you can break out of once you've seen enough examples.

  4. Exit the experiment with BEC_ExitExperiment.m. When this function is called, data is saved, everything is properly closed (e.g. the Psychtoolbox window) and any plugins are safely disconnected.

Ratings

We did a number of studies where participants rated feelings with a slider on one or multiple analog scales presented on a screen by the function BEC_RateEmotion.m. The settings in exp_settings.ratings.(which_rating) allow for controlling how many analog scales appear on screen, the dimensions (e.g. "mood"), their extreme values (e.g. "0" and "10"), and guidance labels (e.g. "very bad" and "very good"). You can present just one scale or multiple scales on screen (see image below). The 'active' cursor will oscillate and its position must be controlled with the cursor or by sliding it on a touchscreen (note: you must slide it on the tablet; mere tapping does not work!) A rating must be confirmed by pressing the [OK] button. If you want to correct a previous rating, simply select a previously positioned cursor to make it active again, slide to a new position, and click [OK] to re-confirm.

rating screen demonstration

Demo code
Below are some lines of code to set up a mood rating screen. You will make use of the settings in the BEC_Settings structure, which you can of course alter to suit your needs. The screenshot above was generated by entering 'emotions' as input.

%Input for the rating function
    AllData.exp_settings = BEC_Settings; %toolbox settings structure
    AllData.gender = 'm'; %for the french rating declinations
    AllData.plugins = []; %no further plugins needed
%Set up the Psychtoolbox window
    Screen('Preference', 'SkipSyncTests', 1); %Skip sync tests: yes
    Screen('Preference', 'VisualDebugLevel', 1); %Visual debug level
    Screen('Preference', 'SuppressAllWarnings', 1);
    KbName('UnifyKeyNames'); %unify across platforms
    window = Screen('OpenWindow',0,AllData.exp_settings.backgrounds.default); %0 for Windows Desktop screen
%Rating screen
    [Ratings,timings,exitflag] = BEC_RateEmotion(window,AllData,'mood'); %in this example, give a mood rating
%Exit
    sca
Clone this wiki locally