PTB_Config

PTB_Config is the main configuration class for o_ptb. In your code, you would create an instance of this class like this:

ptb_cfg = o_ptb.PTB_Config();

Then you can use ptb_cfg like a structure with the only difference that all the fields are already in there. If, for instance, you want to run the experiment in window mode, you need to do:

ptb_cfg.fullscreen = false;
ptb_cfg.window_scale = 0.2;

PTB_Config only contains only a small subset of the available options. The configuration of the subsystems is done via subconfigs.

Basic Configuration

class +o_ptb.PTB_Config

Main configuration class for o_ptb.

Some configuration options for subsystems (audio and response) are in subconfigs. Some advanced options can be found in the internal_config field.

Variables
  • fullscreen (bool) – Set to true if you want the experiment run in fullscreen mode. If you set it to false, you also need to specifiy window_size. Default: true.

  • window_scale (float) – The scale of the window when fullscreen = false is specified. Default: 1.

  • draw_borders_sbg (bool) – Draws a black border around the screen. Only needed in Salzburg. (Probably) Default: true.

  • flip_horizontal (bool) – Whether to flip the output left/right. Default: true.

  • hide_mouse (bool) – Whether to hide the mouse cursor. Default: true.

  • background_color (int or array of int) – The background color. Accepts all values accepted by PTB. Default: +o_ptb.+constants.PTB_Colors.grey.

  • skip_sync_test (bool) – Whether to skip PTB’s sync test. Default: false.

  • force_datapixx (bool) – If set to true, the experiment will stop with an error if no Datapixx was found. Default: false.

  • disable_datapixx (bool) – If set to true, o_ptb will assume that no datapixx system is present. Default: false.

  • crappy_screen (bool) – If set to true, PTB will ignore if it thinks your video setup is super crappy. Don’t use this setting when really running an experiment! Default: false.

  • force_real_triggers (bool) – If set to true, the experiment will not run if no hardware based triggering system has been detected. Default: false.

  • audio_system_cutoff (float) – Cutoff frequency of the audio system in Hz. Useful for tube systems used in MEGs. This value is normally only used to fix the computation of loudness values of sounds like lufs and RMS and has no effect on the actual playback. If you want to simulate the effect of the tube system using your soundcard, see +o_ptb.PTB_subconfigs.PsychPortAudio.simulate_audio_cutoff. Defaults to 0 or the value of O_PTB_AUDIO_CUTOFF

  • psychportaudio_config (+o_ptb.+PTB_subconfigs.PsychPortAudio) – Subconfig for the Psychportaudio sound system.

  • datapixxaudio_config (+o_ptb.+PTB_subconfigs.DatapixxAudio) – Subconfig for the Datapixx sound system.

  • labjacktrigger_config (+o_ptb.+PTB_subconfigs.LabjackTriggers) – Subconfig for the Labjack trigger system.

  • lsltrigger_config (+o_ptb.+PTB_subconfigs.LSLTriggers) – Subconfig for triggering with LabStreamingLayer.

  • keyboardresponse_config (+o_ptb.+PTB_subconfigs.KeyboardResponse) – Subconfig for the Keyboard response system.

  • datapixxresponse_config (+o_ptb.+PTB_subconfigs.DatapixxResponse) – Subconfig for the Datapixx response system.

  • corticalmetrics_config (+o_ptb.+PTB_subconfigs.CorticalMetricTactile) – Subconfig for the CorticalMetrics tactile stimulation system.

  • internal_config (+o_ptb.+PTB_subconfigs.PTBInternal) – Subconfig for advanced options.

real_experiment_sbg_cdk(do_it)

Shortcut for real experiment configuration.

Sets all settings to the correct state for a real experiment run. If you have a function that does the configuration for you, some of those are going to be in “debug” mode most of the time. This method sets them all to values needed to get reliable timings etc.

Parameters

do_it (bool) – If set to true settings are changed.

real_experiment_settings()

Check whether all settings are in “real experiment” mode.

Returns

booltrue if all settings are in “real experiment” mode.

Audio Configuration

class +o_ptb.+PTB_subconfigs.DatapixxAudio

Configuration for the Datapixx audio subsystem.

The values all have sensible defaults. Normally, you do not need to change something here.

Variables
  • freq (float) – The sampling frequency. Default: 96000.

  • volume (float or array of floats) – The volume of the sounds. If it is only one number, the volume is set for both the participant’s headphones and the outside loudspeakers. If it is a vector with two elements, the first indicates the volume at the participants while the second indicates the volume at the loudspeakers at the stimulation computer. Default: 0.5.

  • buffer_address (int) – The memory address of the audio buffer within the Datapixx. If you do not know, what this means, do not touch it! Default: 90e6

class +o_ptb.+PTB_subconfigs.PsychPortAudio

Configuration of the PsychportAudio audio subsystem.

The values all have sensible defaults. Normally, you do not need to change something here.

Variables
  • freq (int) – The sampling frequency. Default: The highest possible or the value of O_PTB_PSYCHPORTAUDIO_SFREQ.

  • mode (int) – The mode of operations. 1 means only ouput. Default: 1.

  • reqlatencyclass (int) – How much the system tries to give you low latencies. Just use the default. (4).

  • device (int) – The device to use. Defaults to the first available one or the value of O_PTB_PSYCHPORTAUDIO_DEVICE.

  • simulate_audio_cutoff (bool) – If true, simulate the audio cutoff.

Trigger Configuration

class +o_ptb.+PTB_subconfigs.LabjackTriggers

Configuration for the Labjack Triggering System.

Please note that you need a recent version of python to use the Labjack!

Sensible defaults are provided for all of them, so normally you do not need to change them.

Variables
  • channel_group (+labjack.Labjack.ChannelGroup) –

    The Labjack U3 (the only one supported right now) has three different channel groups. The relevant ones for you are:

    • +labjack.Labjack.ChannelGroup.EIO: If you have the plug attached.

    • +labjack.Labjack.ChannelGroup.FIO: If you use the wires.

  • method (+labjack.Labjack.TriggerMethod) –

    There are three different methods to do the triggering: * +labjack.Labjack.TriggerMethod.MULTI: Uses

    all 8 channels of the chosen channelgroup. Values are binary coded. This is the normal mode of operation you should be familar with.

    • +labjack.Labjack.TriggerMethod.SINGLE: Uses only one bit to signal a trigger. Use the single_channel property to configure which one you want. Obviously, it is impossible to signal different values this way.

    • +labjack.Labjack.TriggerMethod.PULSEWIDTH: Uses “Pulse Width Modulation” to signal different bit values using only one channel. This is done by modulating the time, the trigger line stays up or down.

      • 10ms = 1.

      • 20ms = 0.

      The num_bits property sets the number of bits that are coded. Example: num_bits = 5 and you wan to send the trigger value 5. 5 in binary representation with 5 bits is: 00101. This would be coded like this:

      1. trigger up for 20ms

      2. trigger down for 20ms

      3. trigger up for 10ms

      4. trigger down for 20ms

      5. trigger up for 10ms

  • single_channel (int) – The channel to use for single or pulsewidth triggering.

  • num_bits (int) – The number of bits to code when using pulsewidth mode. Must be uneven.

class +o_ptb.+PTB_subconfigs.LSLTriggers

Configuration options for LabStreamingLayer based triggering.

Please be aware that you need to explicitly request using this system because it is impossible to automatically determine whether it should be used as it is not hardware based.

You also need to have a current version of liblsl-Matlab (https://github.com/labstreaminglayer/liblsl-Matlab) that you also need to configure and compile the mex files for your system.

Variables
  • liblsl_matlab_path (string) – The full path to liblsl-Matlab.

  • trigger_type (string) – Triggers can be sent as strings like <MARKER>#code</MARKER> or as 32bit integers. If you want strings, set this to string, otherwise to int. Default: string.

  • stream_id (string) – ID of the LSL stream. Default: o_ptb_marker_stream.

Response Configuration

class +o_ptb.+PTB_subconfigs.DatapixxResponse

Configuration for the Datapixx response system.

The only thing to do here is setup the mapping between the response names and the actual buttons.

Suppose, we have two possible reponses yes and no that we want to map to the blue and red button of the response box, this is how it is done:

ptb_config.datapixxresponse_config.button_mapping('yes') = ptb_config.datapixxresponse_config.Blue;
ptb_config.datapixxresponse_config.button_mapping('no') = ptb_config.datapixxresponse_config.Red;

For further details, please take a look at How to get responses.

class +o_ptb.+PTB_subconfigs.KeyboardResponse

Configuration for the Keyboard response system.

The only thing to do here is setup the mapping between the response names and the actual keys.

If necessary, you can also set the device number of the keyboard you want to use.

Suppose, we have two possible reponses yes and no that we want to map to the blue and red button of the response box, this is how it is done:

ptb_config.datapixxresponse_config.button_mapping('yes') = KbName('Right');
ptb_config.datapixxresponse_config.button_mapping('no') = KbName('Left');

For further details, please take a look at How to get responses.

Variables

device_number (int or []) – The device number of the Keyboard. Default: [].

Eyetracker Configuration

class +o_ptb.+PTB_subconfigs.DatapixxTrackPixx

Configuration for the Datapixx Eyetracker System

The values all have sensible defaults. Normally, you do not need to change something here.

Variables
  • lens (int) –

    The lens type. Default: 1. Possible values are:

    • 0: 25mm

    • 1: 50mm

    • 2: 75mm

  • distance (int) – Distance between the eye and the eyetrackerin cm. Default: 82

  • analogue_eye (int) –

    Which eye to use for analogue output. Default: 0. Possible values are:

    • 0: left

    • 1: right

  • led_intensity (int) – Intensity of the infrared LED lights. Must be between 0-8. High values work well for bright eyes while low values seem to work better for dark eyes. Default: 8

  • buffer_address (int) – The memory address of the eyetracker buffer within the Datapixx. If you do not know, what this means, do not touch it! Default: 12e6

Tactile Configuration

class +o_ptb.+PTB_subconfigs.CorticalMetricTactile

Configuration for the CorticalMetrics Tactile Stimulator.

See How to do Tactile Stimulation for details how to use it.

Variables
  • cm_dll (string) – Full path to the CM.dll.

  • stimulator_mapping (containers.Map) – Maps an arbitrary name to the serial number of the stimulator.

  • trigger_mapping (containers.Map) – Maps the name give at stimulator_mapping to the trigger port The device is connected to.

Defaults for certain stimuli

class +o_ptb.+PTB_subconfigs.Defaults

Configuration of some default values for certain stimuli.

Variables
  • text_size (float) – Default text size. Default: 46.

  • text_wrapat (int) – Number of characters in one line. Default: 80.

  • text_vspacing (float) – Vertical space between two lines of text. Default: 1.

  • text_color (int or array of ints) – Text color. Default: +o_ptb.+constants.PTB_Colors.black.

  • fixcross_size (float) – Size of the fixation cross in pixels. Default: 120.

  • fixcross_width_ratio (float) – Ratio between the length of each line of the fixation cross and its width. Default: 0.25.

o_ptb Internals

class +o_ptb.+PTB_subconfigs.PTBInternal

PTBInternal provides some advanced configuration options.

Sensible defaults are provided for all of them, so normally you do not need to change them.