expyriment.control¶
The control package of expyriment.
Modules¶
Functions¶
-
expyriment.control.
end
(goodbye_text=None, goodbye_delay=None, confirmation=False, fast_quit=None, system_exit=False)[source]¶ End expyriment.
Parameters: goodbye_text : str, optional
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)[source]¶ 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)[source]¶ 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)[source]¶ 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.mouse – the main mouse
- experiment.event – the main event file
Parameters: experiment : design.Experiment, optional
the experiment to initialize
Returns: exp : design.Experiment
initialized experiment
-
expyriment.control.
is_interactive_mode
()[source]¶ Returns if Python is running in interactive mode (such as IDLE or IPthon)
Returns: interactive_mode : boolean
-
expyriment.control.
pause
()[source]¶ 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)[source]¶ 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.Mouse.wait_press
- io.SerialPort.read_line
- io.StreamingButtonBox.wait
- io.EventButtonBox.wait
- io.GamePad.wait_press
- io.TriggerInput.wait
- io.TextInput.get
- io.TouchScreenButtonBox.wait
- io.extras.CedrusResponseDevice.wait
- stimuli.Video.wait_frame
- stimuli.Video.wait_end
Parameters: function : function
the wait function
exp : design.Experiment, optional
specific experiment for which to register wait function
See also
Notes
CAUTION! If wait callback function takes longer than 1 ms to process, Expyriment timing will be affected!
-
expyriment.control.
set_develop_mode
(onoff, intensive_logging=False)[source]¶ 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 >>> expyriment.control.defaults.auto_create_subject_id = True >>> expyriment.io.defaults.outputfile_time_stamp = False
-
expyriment.control.
set_skip_wait_functions
(onoff)[source]¶ Switch on/off skip wait function. If skip-wait-functions is switch on (True) all wait functions in the experiment (i.e. all wait function in expyriment.io and the clock) will be omitted.
Parameters: onoff : bool
set skip-wait-function on (True) or off (False)
Notes
CAUTION!: This functions is only usefull for experiment test runs. Do not use skip-wait-function while real experiments.
-
expyriment.control.
start
(experiment=None, auto_create_subject_id=None, subject_id=None, skip_ready_screen=False)[source]¶ 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, optional
if True new subject id will be created automatically
subject_id : integer, optional
start with a specific subject_id; no subject id input mask will be presented; subject_id must be an integer; setting this paramter overrules auto_create_subject_id
skip_ready_screen : bool, optional
if True ready screen will be skipped (default=False)
Returns: exp : design.Experiment
The started experiment will be returned.
-
expyriment.control.
start_audiosystem
()[source]¶ Start the audio system.
Notes
The audiosystem is automatically started when initializing an Experiment!