Psychtoolbox-3

repository·master·Indexed 19 days ago

https://github.com/psychtoolbox-3/psychtoolbox-3

A suite of tools for stimulus presentation and data acquisition in psychological and neuroscience research. It includes a high-quality FTGL-based text rendering plugin for anti-aliased Unicode text, support for research-grade NVidia Optimus timing on Linux, and integration with ARToolkit, freeglut, and libdc1394 for video capture and image processing.

Tokens
4.5K
Snippets
8
Records
26
Agent score
67%

What's inside Psychtoolbox-3

  1. Understanding the modesetting_drv.so variants

    master

    The repository provides two versions of the modified modesetting driver, which are built from X-Server 1.19.0 source code with specific patches applied:

    1. modesetting_drv.so: This version has both patches applied. It provides both the custom UDP Prime Sync protocol (for timestamping) and low-lag optimizations (for frame lag reduction).
    2. modesetting_drv.so_highlag: This version only has the first patch applied (0001-modesetting-Add-custom-UDP-Prime-Sync-protocol-for-P.patch). It provides timestamping functionality but does not include the frame lag reduction optimizations.
  2. Configure ARToolkit libraries for Windows builds

    master

    When building PsychCV on Windows, you need to manage the ARToolkit libraries provided in the .zip file within this directory:

    • Static Linking: PsychCV links statically against other AR libraries. You only need to copy the .lib files into your build environment's libs folder; a full user installation of ARToolkit is not required.
    • DLLs: You must copy the .dll files to your machine's system32/ folder.
    • MSVC Runtimes: If the libraries require redistributable MSVC runtimes, these are conveniently located in Psychtoolbox/PsychContributed/ARToolkit/.
  3. PortAudio library availability for PsychPortaudio builds

    master

    The PsychSourceGL/Cohorts/PortAudio/ directory contains the static and import libraries required to build the PsychPortaudio component for different platforms. These libraries are derived from upstream Portaudio V19.7.0+.

    Platform-specific build files:

    • macOS (64-Bit Intel): Use libportaudio_osx_64.a for static linking.
    • Windows (64-Bit MATLAB): Use portaudio_x64.lib to build PsychPortaudio.mexw64.
    • Windows (64-Bit Octave 4.4+): Use MinGW64/portaudio_x64.lib to build PsychPortaudio.mex.
    • Linux: No local libraries are provided; Psychtoolbox dynamically builds and links against the Portaudio shared libraries (version 19.7.0+) installed on your distribution.
  4. Build PsychCV mex files with ARToolkit

    master

    The PsychCV mex file utilizes ARToolkit's image processing and tracking capabilities. Note that the PsychCV mex file is provided exclusively for use with GNU/Octave; it is not intended for use with the Mathworks proprietary Matlab environment.

    To build PsychCV on Windows, you must manually place the ARToolkit precompiled libraries and DLLs into the appropriate system directories as described below.

    # Requirements for Windows build:
    1. Copy .lib files to your build environment's /lib folder.
    2. Copy .dll files to the system32/ folder of your machine.
  5. Configure an MSVC project for 32-bit freeglut

    master

    To compile a 32-bit freeglut application using Microsoft Visual C++ (MSVC), follow these configuration steps in your project properties:

    1. Project Setup: Create a new Win32 C++ project using the 'Win32 Application Wizard'. Choose 'Windows application' and check the 'Empty project' box.
    2. Apply to All Configurations: In Project Properties, select 'All Configurations' to ensure settings apply to both Debug and Release builds.
    3. C/C++ Settings: Under the C/C++ -> General section, add your freeglut folder to the Additional Include Directories. Note: If multiple GLUT packages exist, ensure the freeglut folder appears above others in the list.
    4. Linker Settings:
      • Under Linker -> General, add your freeglut folder to the Additional Library Directories.
      • Under Linker -> Advanced, set the Entry Point to mainCRTStartup. This is required because GLUT uses main instead of WinMain.
    5. Dependencies: While freeglut.lib and opengl32.lib are required, the freeglut headers typically handle these dependencies automatically.
    /* Include headers in your source files */
    
    // For standard GLUT compatibility:
    #include <GL/glut.h>
    
    // For freeglut-specific extensions:
    #include <GL/freeglut.h>
  6. Use libusb-1.0 on macOS

    master

    For macOS, a 64-Bit Intel libusb-1.0.dylib is provided in the main folder of this subfolder to support building the PsychHID.pyex Python extension without external dependencies.

    • For Python: The provided dylib is intended to prevent build failures. weak_linking is recommended so that runtime libraries are not mandatory for rarely used functionality.
    • For Octave and Matlab: These builds expect a /usr/local/ installation, which can be provided via Homebrew.
  7. Set up the Oculus SDK for Psychtoolbox-3

    master

    To build PsychOculusVRCore mex files, you must provide the Oculus SDK (version 0.5.0.1). Because of GitHub file size limits, only the Linux version is included in this repository. For OSX and Windows, you must download the original files from the Oculus VR website (select Platform: "PC" and Version "0.5.0.1-beta").

    OS-Specific Setup Instructions

    Linux

    1. Unpack the SDK into a folder.
    2. Follow the SDK's specific build instructions.
    3. The built SDK should install header files into /usr/local/include and the static library into /usr/local/lib. These will be statically linked into the Linux PsychOculusVRCore mex files. Note: A prebuilt static version libOVR.a is provided for 64-Bit Linux on 64-Bit Intel.

    OSX

    1. Unpack the SDK into a folder.
    2. Copy the included LibOVR.framework into the /Library/Frameworks/ directory as LibOVR.framework.
    3. The resulting mex file will statically link against a LibOVR shim, which dynamically loads the OSX runtime on the HMD computer.

    Windows

    1. Unpack the SDK into the same parent directory where your Psychtoolbox-3 root folder is located.
    2. Rename the unpacked SDK folder to OculusSDKWin.
    3. Ensure Psychtoolbox-3 and OculusSDKWin are siblings in the parent folder.
    4. The resulting mex file will statically link against a LibOVR shim, which will runtime load/link against the installed 0.5 runtime.
    # Example Windows Directory Structure:
    /path/to/parent/
    ├── Psychtoolbox-3/
    └── OculusSDKWin/
  8. Locate libusb-1.0 runtime DLLs for Windows

    master

    Depending on the bitness of your software (Octave, Matlab, or Python) on MS-Windows, you must use the corresponding libusb-1.0.dll provided in the Psychtoolbox distribution:

    • For 32-Bit versions (Octave, Matlab R2007a+, and Python): Use Psychtoolbox/PsychContributed/libusb-1.0.dll.
    • For 64-Bit versions (Octave, Matlab R2014b+, and Python): Use Psychtoolbox/PsychContributed/x64/libusb-1.0.dll.