expyriment.control

The control package of expyriment.

Functions

expyriment.control.end(goodbye_text=None, goodbye_delay=None, confirmation=False, fast_quit=None, system_exit=False)

End expyriment.

Parameters :

goodbye_text : str, obligatory

text to present on the screen when quitting

goodbye_delay : int, optional

period to show the goodbye_text

confirmation : bool, optional

ask for confirmation (default = False)

fast_quit : bool, optional

quit faster by hiding the screen before actually quitting (default = None)

system_exit : bool, optional

call Python’s sys.exit() method when ending expyriment (default = False)

Returns :

out : bool

True if Expyriment (incl. Pygame) has been quit.

expyriment.control.get_audiosystem_is_playing(channel=None)

Check if the audiosystem is busy playing sounds.

Parameters :

channel : pygame.mixer.Channel, optional

specific channel to check

Returns :

out : bool

Returns True if any sound is playing.

expyriment.control.get_defaults(search_str='', as_string=False)

Return a dictionary with all default values in the current Expyriment environment. The keys represent the variables names.

Parameters :

search_str : str, optional

search for a specific expression

as_string : bool, optional

print as string instead of dict

expyriment.control.initialize(experiment=None)

Initialize an experiment.

This initializes an experiment defined by ‘experiment’ as well as the underlying expyriment system. If ‘experiment’ is None, a new Experiment object will be created and returned. Furthermore, a screen, a clock, a keyboard and a event file are created and added to the experiment. The initialization screen is shown for a short delay to ensure that Python is fully initialized and time accurate. Afterwards, “Preparing experiment...” is presented on the screen.

After experiment initialize the following additional properties are available:

  • experiment.screen – the current screen
  • experiment.clock – the main clock
  • experiment.keyboard – the main keyboard
  • experiment.event – the main event file
Parameters :

experiment : design.Experiment, optional

the experiment to initialize

Returns :

exp : design.Experiment

initialized experiment

expyriment.control.is_idle_running()

Return True if IDLE is running.

expyriment.control.is_ipython_running()

Return True if IPython is running.

expyriment.control.pause()

Pause a running experiment.

This will show a pause screen and waits for ENTER to be pressed to continue.

expyriment.control.register_wait_callback_function(function, exp=None)

Register a wait callback function.

The registered wait callback function will be repetitively executed in all Expyriment wait and event loops that wait for an external input. That is, they are executed by the following functions (at least once!):

control.wait_end_audiosystem, misc.clock.wait, misc.clock.wait_seconds, misc.clock.wait_minutes io.keyboard.wait, io.keyboard.wait_char, io.buttonbox.wait, io.gamepad.wait_press, io.triggerinput.wait, io.mouse.wait_press, io.serialport.read_line, io.textinput.get, stimulus.video.wait_frame, stimulus.video.wait_end
Parameters :

function : function

the wait function

exp : design.Experiment, optional

specific experiment for which to register wait function

Notes

CAUTION! If wait callback function takes longer than 1 ms to process, Expyriment timing will be affected!

expyriment.control.run_test_suite()

Run the Expyriment test suite.

expyriment.control.set_develop_mode(onoff, intensive_logging=False)

Set defaults for a more convenient develop mode.

Parameters :

onoff : bool

set develop_mode on (True) or off (False)

intensive_logging : bool, optional

True sets expyriment.io.defaults.event_logging=2 (default = False)

Notes

The function set the following global variables

>>> expyriment.control.defaults.initialize_delay = 0
>>> expyriment.control.defaults.window_mode = True
>>> expyriment.control.defaults.fast_quit = True
>>> exypriment.control.defaults.auto_create_subject_id = True
>>> expyriment.io.defaults.outputfile_time_stamp = False
expyriment.control.start(experiment=None, auto_create_subject_id=None)

Start an experiment.

This starts an experiment defined by ‘experiment’ and asks for the subject number. When the subject number is entered and confirmed by ENTER, a data file is created. Eventually, “Ready” will be shown on the screen and the method waits for ENTER to be pressed.

After experiment start the following additional properties are available:

  • experiment.subject – the current subject id
  • experiment.data – the main data file
Parameters :

experiment : design.Experiment, optional (DEPRECATED)

Don’t use this parameter, it only exists to keep backward compatibility.

auto_create_subject_id : bool

if true new subject id will be created automatically

Returns :

exp : design.Experiment

The started experiment will be returned.

expyriment.control.start_audiosystem()

Start the audio system.

expyriment.control.stop_audiosystem()

Stop the audio system.

expyriment.control.unregister_wait_callback_function(exp=None)

Unregister wait function.

Parameters :

exp : design.Experiment, optional

specific experiment for which to unregister wait function

expyriment.control.wait_end_audiosystem(channel=None)

Wait until audiosystem has ended playing sounds.

Blocks until the audiosystem is not busy anymore and only returns then.

Parameters :

channel : pygame.mixer.Channel, optional

specific channel to wait for end of playing

Table Of Contents

Previous topic

expyriment

Next topic

expyriment.control.defaults

This Page