Getting started / Making an experiment

Online experiments

You can export PsychBench experiments for upload to VPixx Pack&Go to run online. This is a third party service that, among other things, specializes in running MATLAB + Psychtoolbox experiments online, and so make a good platform for PsychBench experiments too. Experiments are free to test in Pack&Go and there are fees for deploying to.

Limitations

There are not many limitations as to what experiments can be exported. Almost any visual stimuli as well as keyboard and mouse input work. Generally it is easier to list what is known to not work:

  • Visual stimuli relying on MATLAB toolboxes, e.g. the convolution property which requires the Image Processing Toolbox. However, the custom kernel option does work since it doesn't require the toolbox.
  • Auditory stimuli currently (but on the to-do list).
  • Quit & Resume experiments
  • Custom element types that use code requiring MATLAB versions later than R2020b, which is the current version in the Pack&Go. All element types that come with PsychBench are compatible, so if you don't use custom element type code, you don't need to worry about this.

Other than the above, the limitations of online experiments are just the obvious ones: reduced timing precision and control over physical setting and subjects, and of course no access to devices beyond the basic screen/keyboard/mouse or trackpad.

Exporting – exportOnlineExperiment

To export an experiment, first make the experiment just like you would to run locally, using either the coding method or visual method. Test and debug it locally since that is a lot faster and easier than online—though Pack&Go does allow free testing and you should do a final round of testing on the Pack&Go server when ready. When you are ready to export, use the tool exportOnlineExperiment. Type help exportOnlineExperiment at the MATLAB command line for usage.

When you export, Pack&Go requires the experiment files to be organized in a certain way and a few simple rules to be followed:

  • All files for the experiment must be in one folder with nothing else in the folder. All MATLAB program files (.m or .p) must be in that root folder. Other files (e.g. stimulus files, the experiment Excel file if using the visual method, etc.) can be there or in subfolders, whatever you like. (Do not include copies of PsychBench, Psychtoolbox, or MATLAB in the folder, only files specific to the experiment.)
  • Any references to files you make in the experiment script or object properties must use relative paths from the experiment folder. For example, no path means the experiment folder, <cds>"media/"<cds> means subfolder media, etc. If you don't do this you will get file not found errors in Pack&Go.
  • Pack&Go runs on a Linux server, so use / as file/folder separator if needed. If you want to test on Windows locally and don't want to change \ to /, you can use MATLAB filesep.
  • You must include one main MATLAB .m script that builds the experiment in memory and runs it. This is the single script Pack&Go will call for each subject. If you use the coding method then this is just the experiment script. If you use the visual method, just write a little script that calls loadExperiment targeting your Excel file. Either way the script should end with a call to runExperiment.

When you call exportOnlineExperiment select the main script. By definition the folder containing it is the experiment folder, and exportOnlineExperiment packs that folder into a zip file for upload.

exportOnlineExperiment includes a mini copy of PsychBench in the zip file. You don't need to worry about this except to know that the exported experiment is fixed at whatever version of PsychBench you export from. (However, MATLAB and Psychtoolbox are hosted at Pack&Go and updated there at some interval.)

Distance units

In online experiments PsychBench uses a different method to scale visual angle degrees and other units to pixels on the subject's screen. It automatically runs a short task at experiment startup where the subject is asked to adjust the size of a rectangle on screen until its width matches the width of a standard wallet card (e.g. credit card or driver's license). They are also asked whether they are on a desktop or laptop. PsychBench uses this information to estimate physical screen size and distance (cm). You can tweak how this works by adding a screen object and setting its property calibrateDeg.

Experiment results output

For each online run runExperiment automatically writes .mat and .csv results files and Pack&Go saves them for you to download.