Using E-Prime for your experiments

In the MEG lab we strongly encourage the use of E-Prime for all experiments. This is not because E-Prime is the best stimulus presentation package, because it probably isn't, but because it has good timing and we like everybody to use the same software. This will prevent us having to install countless packages on the stimulus presentation machine, and also has the additional advantage that there are many other people at the unit with E-Prime knowledge, forming a useful pool of experts.

E-Prime will only work in Windows, not in other operating systems. To garantee correct behavior it is recommended that virus scanning and Windows update are switched off when using E-Prime. E-Prime comes in two versions: 1 and 2. E-Prime 2 adds two main features: the option to record sound and the option to present video. We only use E-Prime 2 at the unit.

Basic rules when using E-Prime

The first rule when starting to use E-Prime is to resist copying other people's scripts. You can do this when your experiment is virtually identical to someone else's, but in all other cases this is both a recipe for disaster and a seriously missed opportunity to learn a new skill.

The second rule is to keep things simple. Never do something in E-Prime if it can be done outside of it. E-Prime is excellent as a trial builder and an experiment runner, but not very good at anything else.

Thirdly, for critical timing the SignalData mechanism should be used. This will only send a trigger when a stimulus is actually presented, even if there was a delay in the presentation. In the latest version there's now 'Task Events' that are supposed to replace this SignalData mechanism.

Fourth, when you need different lists of stimuli for different subjects, or for different parts of the experiment, do not ever implement this by copying your script and changing the stimuli. Do this by using more than one list of stimuli or, even better, making your script read in the stimuli from file. For this, see the next section about sequence files.

Fifth, you should always use 'Option Explicit'. This will prevent certain errors to go undetected. For this, go to the 'user script' and add the line 'Option Explicit' at the top.

Use of sequence files

The best example of simplicity is the use of sequence files, following rules 2 and 4 above. E-Prime encourages you to create your item collection within the E-Studio environment. It offers Excel-like functionality for this, including the option to copy/paste data straight from/to Excel. It is tempting to use this, but I would recommend against it in all but the most simple cases. The main problem arises when you need more than one set of stimuli in your experiment. It is possible to have more than one list of stimuli in an E-Prime script, it's not even very complicated, but I would recommend to design the script to use a single list, and read the items in from a file. That way your script is as simple as it can be, while you have the maximum flexibility at the same time. You can the use the Mix program to generate your item orders for each individual subject or experimental block. The following bit of inline code will read in a list of stimuli:

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'       InLine Object to open a file and load it into List1
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim listfilename as string

Mouse.ShowCursor True
        
listfilename$ = OpenFileName$("Open list file", "Text Files: *.TXT")

Mouse.ShowCursor False

If listfilename$ <> "" Then
        List1.LoadMethod = ebLoadMethodFile
        List1.Filename = listfilename$
        List1.Load

        List1.Reset
        
        Set List1.TerminateCondition = Cycles(1)
        Set List1.ResetCondition = Samples(List1.Deletion.Count)
else
        MsgBox("Incorrect list file chosen")
End If

Input and Output

We use parallel ports to send triggers from E-Prime to the MEG/EEG machine and to receive signals from button boxes and pulses from the MRI machine. It is also possible to use the PIO card for this, but E-Prime doesn't support the PIO card. You can still use it by using the ScannerSync library, but this will also mean that you will have to do most of the timing by hand. Unless you are an experienced E-Prime programmer it is not recommended to use the ScannerSync library: use the parallel port instead.

Do make sure to set the parallel port to 0 at the beginning of your experiment. You will need to so this in an 'inline' object by adding this line: "WritePort &378, 0". Better still would be to ask the 'ParallelPort' device for the correct addres, see SignalData for more info. The parallel port will take on any value that is written to it, and this will stay on the output until overwritten. To send a trigger you will have to make sure that the port is 0 to begin with, then send the trigger value, make sure it is present on the port for at least about 50 ms, and finally set the port back to 0 again.

One problem with the parallel port is that one of the channels is inverted, meaning that you script will respond to a RELEASE of the button connected to this channel. In time critical experiments this is clearly a big problem as the release will inevitably come hunderds of milliseconds after the pressing of the button. The solution is simple: make your script respond to 'release' in stead of 'press' for this button. To do this you need to do two things: First, make the parallel port respond to 'presses and releases' instead of just 'presses'. You need to edit the parallel port in the 'devices' tab of the experiment for this. Second, you now need to specify {-8} as a possible response. So, if you want to respond to all buttons on the right hand button box in the MEG, you need to specify '567{-8}' in the 'allowed' box of your E-Prime object. This issue has now been solved in the latest version of E-Prime 2, when using the ParallelPort input device.

Synchronising your experiment with the scanner

The MRI scanner will send pulses at the start of each volume being acquired. The pulses are send through the same interface as button presses and are available through both the PIO card and the parallel port. To make your trial wait for the scanner pulse, simply add a 'Wait' object in E-Prime that terminates when the pulse comes in.