How PsyToolkit generally works
The information below is mostly aimed at people who want to know some of the mechanisms behind PsyToolkit. If you merely wish to learn the scripting language, you can skip this.PsyToolkit has two different ways to create an experiment:
- Using the scripting language. This is the easiest and recommended way.
- Using the C library. There are few situation where you would need this.
Please note: PsyToolkit helps you to create executable files, which are based on C code. Thus, even though PsyToolkit uses a scripting language, PsyToolkit is not an interpreted language, because interpretation is not done at the time of execution. PsyToolkit does not have some of the potential disadvantages associated with interpreted languages for time-sensitive projects.
The scripting language
The scripting language is sufficient for many experiments. If it is still not flexible enough for your objectives, you can code your experiment directly with in C, using the psylib library.Here are the steps you would take to go from an idea of an experiment to running it:
- Design an experiment:
- Which stimuli do you need? Create stimuli as bitmaps.
- Which tasks do you need? Write down sequences and blocks you may need.
- Write the script using a text editor and save the file.
- Call psycc with the script file as an argument.
- Use the resulting executable file to run the experiment.
These are the steps:
- The script is interpreted by a program written in Ruby (note that as a user of the PsyToolkit, you don't need to know anything about Ruby). The Ruby code reads the script line for line, and translates it into C code. Currently, it does not report all syntax errors, thus if you make an error in the script, it is possible that it will not be reported in this first step.
- The C code is save in a temporary file and is then compiled (using the Gnu gcc compiler) into an executable program called 'experiment' (it is possible to keep the C file with the -k option).
The psylib library
If the scripting language cannot satisfy your needs, you can use the psylib in C code. Currently, the scripting language is so powerful, that it is most likely that you can use the scripting language (you can even use the C language within the script in a very simple way; this can be very handy for using mathematical and logical functions).In order to use the C library or C calls in a script, you must know the C language. All library functions are explained elsewhere in this documentation.