Using a script with superlab

There are some situations where complex, dynamic control over stimulus sequences is required, and this is something that is sometimes difficult or impossible to do with Superlab. With Superlab 4.0.6, there is an option to write results to the logfile after every trial. This option allows a coprocess, such as a script, to examine the results of the previous trial and copy new images and/or sounds into the files specified in the scripts for the next trial(s). This method allows arbitrary, results-driven sequences of stimuli to be used with superlab.

I decided to create an example script and scenario, basically as a kind of proof of concept. The result is in the attached .tgz file. I did it on a Mac; different methods would be required under Windows.

This is pretty primitive, and it isn’t for the scripting novice.

Greg Shenaut

tryscript.tgz (141 KB)


It just occurred to me that a named pipe would be much easier to use than the method I used in the above script to monitor the online status of a SL experiment, so I tried it out. I set up a simple superlab experiment, and I used mkfifo(1) to create a fifo called “sl4fifo”. I started a trivial Korn Shell loop:

((i=0)) ; while read line ; do print $((++i)) date: $line ; done < sl4fifo

When I started running the experiment, SL complained about overwriting the file and I said “replace”. It wrote as expected to the fifo, and lo and behold, in my terminal window was the SL logfile with numbered, timestamped lines. I haven’t used this yet for anything, but I think this facility (combined with the keystroke emulation of the script attached to this item) will give an even better way to communicate with (and control) SL at run time. (Of course, the option to have logged data written out after each trial is critical.)

None of this is surprising, I just didn’t think of using a named pipe as the output logile before.