### Install Plugin from PyPI Source: https://osdoc.cogsci.nl/4.1/dev/plugin Example command for users to install your published OpenSesame plugin using pip. Replace `opensesame-plugin-example` with the actual name of your plugin package. ```bash pip install opensesame-plugin-example ``` -------------------------------- ### Install OpenSesame on Linux/Ubuntu Source: https://osdoc.cogsci.nl/4.1/download Installs necessary packages and runs the OpenSesame installation script. Ensure you have curl installed. ```bash # These packages need to be installed on Ubuntu 24.04. # Equivalent packages need to be installed on other # Linux distributions. sudo apt install curl python3-dev python3-venv libxcb-cursor0 # Download and run the OpenSesame installation script. bash <(curl -L https://github.com/open-cogsci/OpenSesame/raw/refs/heads/4.1/linux-installer.sh) --install ``` -------------------------------- ### Plugin File Structure Example Source: https://osdoc.cogsci.nl/4.1/dev/plugin Illustrates the directory and file layout for a basic OpenSesame plugin package named 'example'. ```text opensesame_plugins/ example/ __init__.py # can be empty but must exist example_plugin/ __init__.py # contains plugin information example_plugin.py # contains plugin class example_plugin.png # 16 x 16 icon (optional) example_plugin_large.png # 32 x 32 icon (optional) example_plugin.md # Help file in Markdown format (optional) ``` -------------------------------- ### Install Expyriment Backend via PyPI Source: https://osdoc.cogsci.nl/4.1/download Installs the Expyriment library, which can be used as a backend for OpenSesame. This is an alternative to PsychoPy. ```bash pip install http://files.cogsci.nl/expyriment-0.10.0+opensesame2-py3-none-any.whl ``` -------------------------------- ### Install PyGaze with pip Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/pygaze Install PyGaze on any platform using pip. ```bash pip install python-pygaze ``` -------------------------------- ### Install OpenSesame Core Dependencies via PyPI Source: https://osdoc.cogsci.nl/4.1/download Installs the core OpenSesame components and essential extensions using pip. This is a cross-platform method. ```bash pip install --pre opensesame-core opensesame-extension-sigmund opensesame-extension-osweb opensesame-extension-updater opensesame-plugin-psychopy opensesame-plugin-media_player_mpy pygame ``` -------------------------------- ### Install tobii-research library Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/tobii Install the `tobii-research` Python library. This is required for Tobii eye-tracking support and has specific Python version requirements. ```bash pip install tobii-research ``` -------------------------------- ### Create and Play a Sampler Source: https://osdoc.cogsci.nl/4.1/manual/python/sampler Create a Sampler object with a sound source and play it. This example demonstrates basic playback. ```python src = pool['bark.ogg'] my_sampler = Sampler(src, volume=.5) my_sampler.play() ``` -------------------------------- ### Install PyGaze with Anaconda Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/pygaze Install PyGaze on any platform using Anaconda. ```bash conda install python-pygaze -c cogsci ``` -------------------------------- ### Install OpenSesame and Sigmund Extension Source: https://osdoc.cogsci.nl/4.1/tutorials/beginner-sigmund Upgrade OpenSesame and install the Sigmund extension using pip. This command ensures you have the latest versions for compatibility. ```bash pip install opensesame-core opensesame-extension-sigmund --upgrade ``` -------------------------------- ### Install opensesame-plugin-titta-eyetracking Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/tobii Install the Titta eye-tracking plugin for OpenSesame. This plugin offers additional functionality and stability for Tobii eye-tracking. ```bash pip install opensesame-plugin-titta-eyetracking ``` -------------------------------- ### Install PyGaze on Ubuntu (Python 2) Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/pygaze Use this command to install PyGaze on Ubuntu if you are using Python 2. ```bash sudo add-apt-repository ppa:smathot/cogscinl sudo apt-get update sudo apt-get install python-pygaze ``` -------------------------------- ### Complete Form Example with Validation and Filtering Source: https://osdoc.cogsci.nl/4.1/manual/forms/validation This example demonstrates setting up a form with both a custom validator for overall form completion and a key filter for a specific text input to accept only digits. Widgets are defined, configured, and then placed within the form layout. ```python # Define all widgets button_ok = Button(text='Ok') label_gender= Label('Your gender') checkbox_male = Checkbox(text='Male', group='gender', var='gender') checkbox_female = Checkbox(text='Female', group='gender', var='gender') label_age = Label('Your age') # Specify a key filter so that only digits are accepted as text input input_age = TextInput(stub='Age here …', var='age', key_filter=filter_digits) # Build the form. Specify a validator function to make sure that the form is # completed. my_form = Form(validator=my_form_validator, rows=[1,1,1], cols=[1,1,1]) my_form.set_widget(label_gender, (0, 0)) my_form.set_widget(checkbox_male, (1, 0)) my_form.set_widget(checkbox_female, (2, 0)) my_form.set_widget(label_age, (0, 1)) my_form.set_widget(input_age, (1, 1), colspan=2) my_form.set_widget(button_ok, (1, 2)) my_form._exec() ``` -------------------------------- ### Install PyGaze on Ubuntu (Python 3) Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/pygaze Use this command to install PyGaze on Ubuntu if you are using Python 3. ```bash sudo add-apt-repository ppa:smathot/cogscinl sudo apt-get update sudo apt-get install python3-pygaze ``` -------------------------------- ### Run OpenSesame from Command Line Source: https://osdoc.cogsci.nl/4.1/download Executes the OpenSesame application after installation. This command is used to launch the main interface. ```bash opensesame ``` -------------------------------- ### Install Audio Low Latency Plugin Source: https://osdoc.cogsci.nl/4.1/manual/response/soundrecording Install the recommended Audio Low Latency plugins using pip. These plugins are essential for accurate and precise audio recording. ```bash pip install opensesame-plugin-audio-low-latency ``` -------------------------------- ### Define Item Example in OpenSesame Script Source: https://osdoc.cogsci.nl/4.1/manual/opensesame-script Defines a 'keyboard_response' item, setting its allowed responses, description, timeout, and flush behavior. ```opensesame define get_key keyboard_response set allowed_responses "a;x" set description "Collects keyboard responses" set timeout "infinite" set flush "yes" ``` -------------------------------- ### Install Audio Low Latency Plugins Source: https://osdoc.cogsci.nl/4.1/manual/stimuli/sound Install the necessary plugins for low-latency audio playback and recording using pip. This package provides enhanced audio capabilities. ```bash pip install opensesame-plugin-audio-low-latency ``` -------------------------------- ### Install PyGaze for Eye Tracking via PyPI Source: https://osdoc.cogsci.nl/4.1/download Installs the PyGaze library for eye tracking functionality. Ensure you are using a compatible Python version. ```bash pip install https://github.com/smathot/PyGaze/releases/download/prerelease%2F0.8.0a3/python_pygaze-0.8.0a3-py3-none-any.whl ``` -------------------------------- ### Install PsychoPy Dependencies via PyPI Source: https://osdoc.cogsci.nl/4.1/download Installs PsychoPy and its related sound and vision modules, required for the default psycho backend. May require troubleshooting on some systems. ```bash pip install psychopy psychopy_sounddevice psychopy_visionscience ``` -------------------------------- ### OpenSesame Script Comment Example Source: https://osdoc.cogsci.nl/4.1/manual/opensesame-script Demonstrates how to add comments in OpenSesame script using the hash symbol. ```opensesame # This is a comment ``` -------------------------------- ### Install EyeLink Display Software on Ubuntu Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/eyelink Installs the EyeLink display software, PyLink, and related tools like the edf2asc converter on Ubuntu systems. This method uses SR Research's apt repository. ```bash sudo add-apt-repository 'deb [arch=amd64] https://apt.sr-research.com SRResearch main' sudo apt-key adv --fetch-keys https://apt.sr-research.com/SRResearch_key sudo apt-get update sudo apt-get install eyelink-display-software ``` -------------------------------- ### eyetracker.status_msg Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/pygaze Sends a status message to the eye tracker's GUI, visible on the experimenter's PC. This is primarily for EyeLink setups. The message can be formatted, for example, to display trial numbers. ```APIDOC ## function **eyetracker.status_msg**(msg) Sends a status message to the eye tracker, which is displayed in the tracker's GUI (only available for EyeLink setups). **Arguments:** * `msg` -- A string that is to be displayed on the experimenter PC, e.g.: "current trial: %d" % trialnr. * Type: str, unicode ``` -------------------------------- ### Create a simple 'Hello World' experiment programmatically Source: https://osdoc.cogsci.nl/4.1/manual/python/nogui Initializes the experiment window, prepares a stimulus canvas and keyboard, shows the canvas, waits for a key press, and ends the experiment. Requires explicit imports from libopensesame.python_workspace_api. ```python from libopensesame.python_workspace_api import \ Experiment, Canvas, Keyboard, Text # Initialize the experiment window using the legacy backend exp, win, clock, log = Experiment(canvas_backend='legacy') # Prepare a stimulus canvas and a keyboard cnv = Canvas() cnv += Text('Hello world') kb = Keyboard() # Show the canvas, wait for a key press, and then end the experiment cnv.show() kb.get_key() exp.end() ``` -------------------------------- ### Using the SR Box from Python inline code Source: https://osdoc.cogsci.nl/4.1/manual/response/srbox Demonstrates how to use the srbox object within an inline_script item to start the SR Box, get button presses with specified allowed buttons and timeouts, and stop the SR Box. ```APIDOC ## Using the SR Box from Python inline code The `srbox` object is available when the srbox plugin is used in an OpenSesame experiment. It allows for direct interaction with the SR Box hardware. ### Example: ```python t0 = clock.time() srbox.start() button, t1 = srbox.get_button_press(allowed_buttons=[1, 2], require_state_change=True) if button == 1: response_time = t1 - t0 print(f'Button 1 was pressed in {response_time} ms!') srbox.stop() ``` ``` -------------------------------- ### Using SR Box in Python Inline Code Source: https://osdoc.cogsci.nl/4.1/manual/response/srbox Collect button presses from the SR Box using Python inline code. Ensure the SR Box is started before attempting to get a button press and stopped afterward. Explicitly specifying the device is recommended to avoid experiment freezes. ```python t0 = clock.time() srbox.start() button, t1 = srbox.get_button_press(allowed_buttons=[1, 2], require_state_change=True) if button == 1: response_time = t1 - t0 print(f'Button 1 was pressed in {response_time} ms!') srbox.stop() ``` -------------------------------- ### Create a Sampler with Default Playback Keywords Source: https://osdoc.cogsci.nl/4.1/manual/python/sampler Initialize a Sampler with default playback settings like volume. These settings can be overridden during playback. ```python src = pool['bark.ogg'] my_sampler = Sampler(src, volume=.5) ``` -------------------------------- ### Install OpenSesame OSF Extension via Pip Source: https://osdoc.cogsci.nl/4.1/manual/osf Install the OpenScienceFramework extension for OpenSesame using pip. This is the standard method for installing Python packages. ```bash pip install opensesame-extension-osf ``` -------------------------------- ### Creating a Sampler Source: https://osdoc.cogsci.nl/4.1/manual/python/sampler Demonstrates how to create a Sampler object, optionally setting default playback keywords like volume. ```APIDOC ## Creating a Sampler You generally create a `Sampler` with the `Sampler()` factory function, which takes the full path to a sound file as the first argument. ```python src = pool['bark.ogg'] my_sampler = Sampler(src) ``` Optionally, you can pass Playback keywords to `Sampler()` to set the default behavior: ```python src = pool['bark.ogg'] my_sampler = Sampler(src, volume=.5) ``` ``` -------------------------------- ### Sequence item execution order Source: https://osdoc.cogsci.nl/4.1/manual/prepare-run This demonstrates the prepare-run sequence for items within a 'trial_sequence'. Preparation occurs for all items before any are run. ```opensesame prepare fixation_sketchpad prepare target_sketchpad prepare keyboard_response prepare logger run fixation_sketchpad run target_sketchpad run keyboard_response run logger ``` -------------------------------- ### Create a Sampler with Default Source Source: https://osdoc.cogsci.nl/4.1/manual/python/sampler Instantiate a Sampler object using a sound file path from the pool. This is the basic way to create a sampler. ```python src = pool['bark.ogg'] my_sampler = Sampler(src) ``` -------------------------------- ### Create and Execute a Form with Widgets (Python) Source: https://osdoc.cogsci.nl/4.1/manual/forms/widgets Demonstrates how to create a basic form with specified dimensions, margins, and theme using Python. Includes setting a button widget and executing the form. ```python form = Form( cols=2, rows=2, spacing=10, margins=(100, 100, 100, 100), theme='gray', timeout=None, clicks=False, validator=None ) button = Button(text='Ok!') form.set_widget(button, (0, 0)) form._exec() ``` -------------------------------- ### Install parallel_port_trigger plugin Source: https://osdoc.cogsci.nl/4.1/manual/devices/parallel Install the `parallel_port_trigger` plugin using pip. This is a third-party plugin for sending stimulus synchronization triggers. ```bash pip install pip install opensesame-plugin-parallel_port_trigger ``` -------------------------------- ### Keyboard Class Initialization Source: https://osdoc.cogsci.nl/4.1/manual/python/keyboard Demonstrates how to create a Keyboard object, optionally with default response keywords like timeout and keylist. ```APIDOC ## Keyboard() You generally create a `Keyboard` with the `Keyboard()` factory function. ```python my_keyboard = Keyboard() ``` Optionally, you can pass Response keywords to `Keyboard()` to set the default behavior: ```python my_keyboard = Keyboard(timeout=2000) ``` ``` -------------------------------- ### Run Expyriment Test Suite Source: https://osdoc.cogsci.nl/4.1/manual/timing Use this inline script to launch the Expyriment test suite within your OpenSesame experiment. Ensure the expyriment backend is selected. ```python import expyriment expyriment.control.run_test_suite() ``` -------------------------------- ### Load and Run an Experiment File Source: https://osdoc.cogsci.nl/4.1/manual/python/common Loads an experiment from a specified .osexp file and runs it. Requires importing the Experiment class. ```python from libopensesame.python_workspace_api import Experiment exp, win, clock, log = Experiment(osexp_path='my_experiment.osexp', subject_nr=2) exp.run() ``` -------------------------------- ### Get Pool Folder Path in Python Source: https://osdoc.cogsci.nl/4.1/manual/python/pool Returns the full path to the main pool folder, which is usually a temporary directory that gets deleted after the experiment. ```python print(f'The pool folder is here: {pool.folder()}') ``` -------------------------------- ### Install OpenSesame OSF Extension via Conda Source: https://osdoc.cogsci.nl/4.1/manual/osf Install the OpenScienceFramework extension for OpenSesame within an Anaconda environment. This command uses the 'cogsci' channel for the package. ```bash conda install -c cogsci opensesame-extension-osf ``` -------------------------------- ### Prepare and Run an Item Source: https://osdoc.cogsci.nl/4.1/manual/python/items Prepares an item by executing its prepare phase and then runs it by executing its run phase. This is useful for sequential execution of item phases. ```python items.prepare('target_sketchpad') items.run('target_sketchpad') ``` -------------------------------- ### Get and Set Experimental Variables Source: https://osdoc.cogsci.nl/4.1/manual/python/about Use this to retrieve the current value of an experimental variable or to set a new value. Ensure the variable is defined before attempting to get it. ```python print('my_variable is: %s' % my_variable) # Set an experimental variable my_variable = 'my_value' ``` -------------------------------- ### OpenSesame 3.0.7 Python 3.4.3 Windows Packaging Source: https://osdoc.cogsci.nl/4.1/notes/307 Lists the software versions included in the experimental Python 3.4 release for Windows packaging of OpenSesame 3.0.7. This includes Python version, OpenCV, QProgedit, Expyriment, IPython, NumPy, PIL, PsychoPy, PyAudio, PyGame, PyGaze, Pyglet, PyOpenGL, PyQt, PySerial, python-bidi, python-markdown, and SciPy. ```text OpenSesame 3.0.7 Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] OpenCV is not available OpenCV 2 is not available QProgedit 3.2.2 Expyriment is not available (or version is unknown) IPython 4.0.0 NumPy 1.9.3 PIL is available (version is unknown) PsychoPy not available (or version is unknown) PyAudio 0.2.9 PyGame 1.9.2a0 PyGaze is not available Pyglet not available (or version is unknown) PyOpenGL 3.1.1b1 PyQt 4.11.4 PySerial 2.7 python-bidi 0.4.0 python-markdown 2.6.2 SciPy 0.16.1 ``` -------------------------------- ### OpenSesame 3.0.7 Python 2.7.10 Windows Packaging Source: https://osdoc.cogsci.nl/4.1/notes/307 Lists the software versions included in the Python 2.7 release for Windows packaging of OpenSesame 3.0.7. This includes Python version, OpenCV, QProgedit, Expyriment, IPython, NumPy, PIL, PsychoPy, PyAudio, PyGame, PyGaze, Pyglet, PyOpenGL, PyQt, PySerial, python-bidi, python-markdown, and SciPy. ```text OpenSesame 3.0.7 Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] OpenCV is not available OpenCV2 3.0.0 QProgedit 3.2.2 Expyriment (Python 2.7.10) IPython 3.2.0 NumPy 1.9.2 PIL is available (version is unknown) PsychoPy 1.82.01 PyAudio 0.2.8 PyGame 1.9.1release PyGaze 0.6.0a10 Pyglet 1.2.3 PyOpenGL 3.1.0 PyQt 4.11.4 PySerial 2.7 python-bidi 0.3.4 python-markdown 2.6.2 SciPy 0.15.1 ``` -------------------------------- ### Display Text with Expyriment Backend Source: https://osdoc.cogsci.nl/4.1/manual/backends This snippet demonstrates how to create and present a simple text line using the Expyriment library directly. Ensure the 'xpyriment' backend is selected in OpenSesame to use this functionality. ```python from expyriment import stimuli text = stimuli.TextLine('This is expyriment!') text.present() ``` -------------------------------- ### Get Current Timestamp and Sleep using clock Source: https://osdoc.cogsci.nl/4.1/important-changes-3 Access time-related functions through the `clock` object. Use `clock.time()` to get the current timestamp and `clock.sleep()` to pause execution. ```python print('Current timestamp: %s' % clock.time()) clock.sleep(1000) # Sleep for 1 s ``` -------------------------------- ### Basic Pool Operations Source: https://osdoc.cogsci.nl/4.1/manual/python/pool Demonstrates common operations like getting file paths, checking for file existence, deleting files, iterating through files, and getting the pool size. ```APIDOC ## Basic Pool Operations ### Description Demonstrates common operations like getting file paths, checking for file existence, deleting files, iterating through files, and getting the pool size. ### Code Example ```python # Get the full path to a file in the file pool print(f'The full path to img.png is {pool["img.png"]}') # Check if a file is in the file pool if 'img.png' in pool: print('img.png is in the file pool') # Delete a file from the file pool del pool['img.png'] # Walk through all files in the file pool. This retrieves the full paths. for path in pool: print(path) # Check the number of files in the file pool print(f'There are {len(pool)} files in the file pool') ``` ``` -------------------------------- ### Initialize Keyboard with default keylist and timeout Source: https://osdoc.cogsci.nl/4.1/manual/python/keyboard Creates a Keyboard object pre-configured with a keylist accepting 'a' or 'b' and a 5000 ms timeout. Retrieves two key presses using these defaults. ```python # Get two key A or B presses with a 5000 ms timeout my_keyboard = Keyboard(keylist=[u'a', u'b'], timeout=5000) key1, time1 = my_keyboard.get_key() key2, time2 = my_keyboard.get_key() ``` -------------------------------- ### Install SR Research EyeLink Plugins for OpenSesame Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/eyelink Installs SR Research's official EyeLink plugins for OpenSesame. These plugins offer functionality similar to PyGaze but with additional features. ```bash pip install opensesame-plugin-eyelink ``` -------------------------------- ### Basic OpenSesame Plugin Class Structure Source: https://osdoc.cogsci.nl/4.1/dev/plugin This is a fundamental example of an OpenSesame plugin class. It inherits from `libopensesame.item.Item` and includes essential methods like `reset`, `prepare`, and `run`. Use this as a template for your own plugins. ```python from libopensesame.py3compat import * from libopensesame.item import Item from libqtopensesame.items.qtautoplugin import QtAutoPlugin from openexp.canvas import Canvas class ExamplePlugin(Item): """An example plugin that shows a simple canvas. The class name should be the CamelCase version of the folder_name and file_name. So in this case both the plugin folder (which is a Python package) and the .py file (which is a Python module) are called example_plugin, whereas the class is called ExamplePlugin. """ def reset(self): """Resets plug-in to initial values.""" # Here we provide default values for the variables that are specified # in __init__.py. If you do not provide default values, the plug-in # will work, but the variables will be undefined when they are not # explicitly # set in the GUI. self.var.checkbox = 'yes' # yes = checked, no = unchecked self.var.color = 'white' self.var.option = 'Option 1' self.var.file = '' self.var.text = 'Default text' self.var.spinbox_value = 1 self.var.slider_value = 1 self.var.script = 'print(10)' def prepare(self): """The preparation phase of the plug-in goes here.""" # Call the parent constructor. super().prepare() # Here simply prepare a canvas with a fixatio dot. self.c = Canvas(self.experiment) self.c.fixdot() def run(self): """The run phase of the plug-in goes here.""" # self.set_item_onset() sets the time_[item name] variable. Optionally, # you can pass a timestamp, such as returned by canvas.show(). self.set_item_onset(self.c.show()) ``` -------------------------------- ### Create Sampler with Default Playback Keywords Source: https://osdoc.cogsci.nl/4.1/manual/python/sampler Instantiate a Sampler with default playback keywords like volume and pan. These settings are applied upon creation and affect all subsequent playbacks. ```python src = pool['bark.ogg'] my_sampler = Sampler(src, volume=.5, pan='left') my_sampler.play() ``` -------------------------------- ### eyetracker.wait_for_fixation_start Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/pygaze Returns the starting time and position of a fixation. A fixation is considered started when gaze position remains stable within `self.pxfixtresh` for five consecutive samples. Detection can be PyGaze-based or native. ```APIDOC ## function **eyetracker.wait_for_fixation_start**() Returns starting time and position when a fixation is started; function assumes a 'fixation' has started when gaze position remains reasonably stable (i.e. when most deviant samples are within self.pxfixtresh) for five samples in a row (self.pxfixtresh is created in self.calibration, based on self.fixtresh, a property defined in self.**init**). Detection based on Dalmaijer et al. (2013) if EVENTDETECTION is set to 'pygaze', or using native detection functions if EVENTDETECTION is set to 'native' (NOTE: not every system has native functionality; will fall back to ;pygaze' if 'native' is not available!) **Returns:** A `time, gazepos` tuple. Time is the starting time in milliseconds (from expstart), gazepos is a (x,y) gaze position tuple of the position from which the fixation was initiated. * Type: tuple ``` -------------------------------- ### Efficient Stimulus Presentation (Python) Source: https://osdoc.cogsci.nl/4.1/manual/timing This example shows the recommended approach for stimulus presentation by preparing all stimuli in advance. This ensures a consistent and accurate interval between stimuli, as stimulus preparation time is not included in the critical timing. ```python # Prepare canvas 1 and 2 canvas1 = Canvas() canvas1 += Text('This is the first canvas') canvas2 = Canvas() canvas2 += Text('This is the second canvas') # Show canvas 1 t1 = canvas1.show() # Sleep for 95 ms to get a 100 ms delay clock.sleep(95) # Show canvas 2 t2 = canvas2.show() # The actual delay will be 100 ms, because stimulus ``` -------------------------------- ### Complex Conditional Logic Examples Source: https://osdoc.cogsci.nl/4.1/manual/variables Use these examples for more complex conditions involving multiple checks. Ensure variables like 'correct', 'response_time', 'max_response_time', and 'min_response_time' are defined and updated appropriately in your experiment. ```python correct == 1 and response_time > 2000 ``` ```python correct != 1 or response_time > max_response_time or response_time < min_response_time ``` -------------------------------- ### OpenSesame 3.0.7 Mac OS Packaging Source: https://osdoc.cogsci.nl/4.1/notes/307 Lists the software versions included in the Mac OS packaging of OpenSesame 3.0.7. This includes Python version, OpenCV, QProgedit, Expyriment, IPython, NumPy, PIL, PsychoPy, PyAudio, PyGame, PyGaze, Pyglet, PyOpenGL, PyQt, PySerial, python-bidi, python-markdown, and SciPy. ```text OpenSesame 3.0.7 Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:57:58) [GCC 4.2.1 (Apple Inc. build 5577)] OpenCV is not available OpenCV2 3.1.0 QProgedit 3.2.2 Expyriment 0.8.0-41-g147b7d7 (Python 2.7.11) IPython 4.1.2 NumPy 1.10.4 PIL is available (version is unknown) PsychoPy 1.82.01 PyAudio 0.2.7 PyGame 1.9.2a0 PyGaze is not available Pyglet 1.2.4 PyOpenGL 3.1.1a1 PyQt 4.11.4 PySerial 3.0.1 python-bidi 0.4.0 python-markdown 2.6.5 SciPy 0.17.0 ``` -------------------------------- ### Install DLPortIO Driver on Windows 7 Source: https://osdoc.cogsci.nl/4.1/manual/devices/parallel Follow these steps to install the DLPortIO driver on Windows 7, which requires bypassing digital signature enforcement. Ensure you run scripts and programs with administrator privileges. ```bash DLPortIO_install.bat ``` -------------------------------- ### Build Main Experiment Structure with Sigmund Source: https://osdoc.cogsci.nl/4.1/tutorials/intermediate-sigmund Use this prompt to create the basic hierarchical structure of an experiment in OpenSesame. It defines sequences, loops, and sketchpads without adding content. ```text Hi Sigmund! I’d like to build a visual search experiment. Please create this structure without adding content yet: - experiment (sequence) - instructions (sketchpad) - experimental_loop (loop) - block_sequence (sequence) - end_message (sketchpad) ``` -------------------------------- ### Install PyLink from SR Research PyPi Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/eyelink Use this command to install the PyLink library from SR Research's private PyPi repository. Ensure you are using a compatible Python version (3.12 or earlier). ```bash pip install --index-url=https://pypi.sr-research.com sr-research-pylink ``` -------------------------------- ### Programmatically Implement an Experiment Source: https://osdoc.cogsci.nl/4.1/manual/python/common Initializes an experiment programmatically, creates a canvas with text, displays it, waits for a key press, and ends the experiment. Requires importing Experiment, Canvas, Text, and Keyboard. ```python from libopensesame.python_workspace_api import ( Experiment, Canvas, Text, Keyboard) exp, win, clock, log = Experiment(canvas_backend='legacy') c = Canvas() c += Text('Press any key') c.show() kb = Keyboard() kb.get_key() exp.end() ``` -------------------------------- ### PyGaze example in Python inline_script Source: https://osdoc.cogsci.nl/4.1/manual/eyetracking/pygaze This example demonstrates how to use PyGaze in a Python inline script to create a gaze-contingent fixation dot. It requires initialization of a keyboard and canvas, and assumes an 'eyetracker' object is available. ```python # Create a keyboard and a canvas object my_keyboard = Keyboard(timeout=0) my_canvas = Canvas() my_canvas['dot'] = Circle(x=0, y=0, r=10, fill=True) # Loop ... while True: # ... until space is pressed key, timestamp = my_keyboard.get_key() if key == 'space': break # Get gaze position from pygaze ... x, y = eyetracker.sample() # ... and draw a gaze-contingent fixation dot! my_canvas['dot'].x = x + my_canvas.left my_canvas['dot'].y = y + my_canvas.top my_canvas.show() ``` -------------------------------- ### init_sound(experiment) Source: https://osdoc.cogsci.nl/4.1/manual/python/sampler Initializes the pygame mixer before the experiment begins. ```APIDOC ## init_sound(experiment) Initializes the pygame mixer before the experiment begins. **Parameters** * **experiment** : The experiment object. ``` -------------------------------- ### OpenSesame 2.8.2 Environment Information Source: https://osdoc.cogsci.nl/4.1/notes/282 This output provides a snapshot of the libraries and their versions included with the OpenSesame 2.8.2 Windows package. It is useful for verifying the environment and identifying potential compatibility issues. ```text OpenSesame 2.8.2 Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] OpenCV is not available OpenCV2 2.4.9 QProgedit 1.3.2 Expyriment 0.7.0 (Revision 7a6b73d; Python 2.7.6) NumPy 1.8.1 PIL is available (version is unknown) PsychoPy 1.80.05-opensesame-1 PyAudio 0.2.7 PyGame 1.9.1release Pyglet 1.1.4 PyOpenGL 3.0.2 PyQt 4.10.4 PySerial 2.7 python-bidi 0.3.4 python-markdown 2.4 SciPy 0.13.3 ``` -------------------------------- ### Basic Pool Operations in Python Source: https://osdoc.cogsci.nl/4.1/manual/python/pool Demonstrates common operations with the pool object, including getting file paths, checking for file existence, deleting files, iterating through all files, and getting the total number of files. ```python # Get the full path to a file in the file pool print(f'The full path to img.png is {pool["img.png"]}') # Check if a file is in the file pool if 'img.png' in pool: print('img.png is in the file pool') # Delete a file from the file pool del pool['img.png'] # Walk through all files in the file pool. This retrieves the full paths. for path in pool: print(path) # Check the number of files in the file pool print(f'There are {len(pool)} files in the file pool') ``` -------------------------------- ### Creating a Mouse Object Source: https://osdoc.cogsci.nl/4.1/manual/python/mouse Demonstrates how to create a Mouse object, optionally with default response keywords. ```APIDOC ## Creating a Mouse You generally create a `Mouse` with the `Mouse()` factory function: ```python my_mouse = Mouse() ``` Optionally, you can pass Response keywords to `Mouse()` to set the default behavior: ```python my_mouse = Mouse(timeout=2000) ``` ``` -------------------------------- ### Set Timeout Example in OpenSesame Script Source: https://osdoc.cogsci.nl/4.1/manual/opensesame-script Sets the 'timeout' variable to 1000 milliseconds. ```opensesame set timeout 1000 ``` -------------------------------- ### synonyms(button) Source: https://osdoc.cogsci.nl/4.1/manual/python/mouse Gives a list of synonyms for a mouse button. For example, 1 and 'left_button' are synonyms. ```APIDOC ## synonyms(button) ### Description Gives a list of synonyms for a mouse button. For example, 1 and 'left_button' are synonyms. ### Parameters * **button** - A button value. ### Returns * A list of synonyms. ``` -------------------------------- ### Configure Face Sketchpad Elements Source: https://osdoc.cogsci.nl/4.1/tutorials/iat Sets the duration to 0ms and draws a face image, category text for 'YOUNG', and category text for 'OLD'. Use this to set up the initial display elements. ```opensesame set duration 0 set description "Displays stimuli" draw image center=1 file="of1.jpg" scale=1 show_if=always x=0 y=0 z_index=0 draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=30 html=yes show_if=always text="YOUNG
" x=-320 y=-192 z_index=0 draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=30 html=yes show_if=always text=OLD x=320 y=-192 z_index=0 ```