Stimulus Presentation Solutions
TIMING: Stimulus Presentation Challenges  describes the constraints that the refresh rate and the vertical blank event impose on the ability to precisely control display durations. The first five solutions described in this article, both individually and collectively, work with the physical constraints of the video card and monitor to control, as precisely as possible, the duration of stimulus displays. The features that are examined here are all set on the Display Device dialog box and are shown in Figure 1. To view these features within E-Studio, select “Experiment” from the “Edit” menu, select the “Devices” tab, and then select “Edit” with the Display selected.
Set the Display Resolution
The refresh rates that are available on a given system are determined by both the monitor and the video card. The display resolution also affects the refresh rates that are available. While most low- to mid-range video cards and monitors will be able to run in the highest resolution at the highest refresh rate supported by the card and monitor, there may be some combinations that are not supported. For higher-end video cards and monitors, there is a greater likelihood that some combinations are not supported. Therefore, the first step in selecting the display properties for your experiment is to select the screen resolution.
To set the screen resolution, navigate to the Edit Display Device dialog box as described above and select values from the Width and Height dropdown boxes. The default screen resolution is 1024 x 768, which is a lower resolution for graphic files. However, it was deliberately selected because it is almost universally supported across video cards and monitors. Further, you should use the lowest screen resolution possible. For example, there is no reason to run in the HD resolution of 1900 x 1080 if you are only displaying a text-based cross fixation that takes up a 10 by 10 pixel area.
There are several important cautions and notes regarding the display resolution. First, if you are using a graphics package to create visual stimuli, set your computer to the screen resolution to be used while running the experiment before creating or editing your stimulus files. Select a screen resolution that is fairly common and supported by the majority of computers. Lastly, test each laboratory computer to confirm that it supports your specified screen mode. At this point, once you have confirmed the screen resolution on the data collection computer(s), you can create or edit the graphic files in your editor of choice, such as Adobe Photoshop.
If your set of stimulus files were not generated or saved in a common resolution, then we strongly recommend that you standardize them in a third party graphics package. While the size and appearance of graphic files can be manipulated somewhat within E-Prime by manipulating the Frame settings, such as Stretch, StretchMode, MirrorLeftRight, and MirrorUpDown, this practice is not recommended. Any image manipulation that is performed by E-Prime introduces some timing delay, which will be reflected in the OnsetDelay for the object that is presenting the image.
Also, if you are running on a wide screen monitor and use a 4:3 display resolution, then the screen will either show black bars on the sides, or the image will stretch to fill the screen. This is a function of the video card and wide-screen monitor and is not configurable by E-Prime. Therefore, you should select your aspect ratio first, prior to generating any visual stimuli.
We generally recommend that you do not match the desktop resolution at runtime. The “match desktop resolution” feature may be selected in E-Prime, but its default value is not selected. However, there is one scenario where you may want to have E-Prime match the monitor to the desktop resolution: when you have multiple display devices active for a single experimental session. E-Prime has the ability to add additional displays and direct output to them1. In some cases, E-Prime has difficulty determining the proper display settings for the additional display devices. When you are creating the additional display devices, you can enable the “Match desktop resolution at runtime” feature. E-Prime will then take the resolution being used when the experiment is launched and set the designated display device to that resolution.
Watch Changing the display resolution for more information.
Confirming the available Refresh Rates
TIMING: Stimulus Presentation Challenges  describes the need to present stimuli for integer multiples of the refresh cycle of the monitor. In order to set your display duration to a multiple of the refresh rate, you need to know the refresh rates that are supported by your system.
E-Prime can and will get the refresh rate that you specify in the DisplayDevice properties. This value may or may not match what is configured through Windows control panel. E-Prime logs the refresh rate in the data file for each experiment under the variable name Display.RefreshRate. (If running with two monitors, the second refresh rate value is logged as Display2.RefreshRate.) After specifying the refresh rate in E-Studio (explained in the next section), you should always run a test experiment, examine the resulting data file in E-DataAid and confirm the value logged in the E-Prime data file. Figure 2 shows a typical result from a 60 Hz refresh rate.
Notice that the example shows a logged value of 60.011 rather than the integer value of 60 that was specified in E-Studio. While refresh rates are often reported as whole numbers by the vendor, they are rarely the exact value reported. For example, a monitor running at 60 Hz may actually be running at 59.98 or 60.02 Hz. These small variations are within the fault tolerances of the manufacturer, and do not pose any problems for accurate display presentations provided that you understand that and make your durations divisible by this refresh duration value. The upcoming sections on specifying the display duration and using RefreshAlignment explain how E-Prime works successfully with non-integer refresh rates.
Set the Refresh Rate
The Refresh Rate is specified on the Display Device properties tab. The default value is “unspecified”. If you click on the “Refresh Rate Requested” field, a list of common refresh rates appear. As the name of this field suggests, E-Prime treats this rate as a request. E-Prime attempts to set the video system to this rate. If it cannot set it to either this rate or a value between the “Minimum Acceptable Refresh Rate” and the “Maximum Acceptable Refresh Rate”, and if the “Throw error if invalid refresh rate” is set to “Yes”, E-Prime will generate a runtime error. Unless you are developing and/or running your experiment in virtualization mode, which is not recommended for data collection and which is also explained below, you should keep the default value for “Throw Error”.
The “unspecified” value is appropriate to use when you are in the early stages of experiment development in E-Studio. However, as soon as you confirm what the refresh rate is on your laboratory experiments, you should set this rate here, as well as design the display durations around the specific refresh rate in your data collection lab (e.g. display durations should be divisible by the refresh rate).
A Note about Virtualization Mode
When E-Prime 3.0 is running on a system where video hardware is emulated (such as Standard Display Adapter in Vista) or under virtualization software, which is typically used to mimic an operating system, E-Prime cannot reliably detect the refresh rate. The Display Device Property “Throw error if invalid refresh rate” controls E-Prime's behavior in this situation. When set to the default value of “yes”, E-Run generates a fatal error and does not allow the experiment to run.
NOTE: E-Prime cannot maintain accurate timing when run under virtualization software.
However, in some circumstances it may be convenient to develop and test an experiment with a computer that is running virtualization software while the actual data collection will occur on machines that are running under native Windows mode. Alternatively the experiment may not use reaction time as the dependent measure. In these circumstances, the error can be turned off by switching the property to “no”.
Set the Display Durations to be multiples of the Refresh Rate
NOTE: The display durations that you can use for your experiment as a function of your refresh rate.
We’ve already examined examples where a 60Hz refresh rate equates to displays that are multiples of 16.6666 ms. Other than monitors with a refresh rate of 100Hz, which equates to display times in multiples of 10 ms, the refresh rate will not be a whole number. Since E-Prime requires that durations be defined as integer values, then you will end up with some display durations that are an extra refresh duration. The RefreshAlignment feature was designed expressly for this purpose, to enable E-Prime to start looking a bit earlier than indicated by the display duration for the refresh event.
Synchronize to the Vertical Blank Event
All E-Prime stimulus presentation objects allow synchronization with the refresh cycle via the object’s properties. The Sync tab located in the stimulus presentation object’s (e.g., TextDisplay, ImageDisplay, SlideDisplay, SoundOut, etc.) Property pages allow the user to specify whether the onset time for the next stimulus should be delayed until the next vertical blanking event. When the Onset Sync property is set to vertical blank, the object will delay until the next vertical blanking before presenting the stimulus. Note, the second stimulus is not starting at an integer multiple of milliseconds but rather as soon as the vertical blanking event occurs.
When the synching signal (i.e., vertical blanking) is detected, the next event considers this signal as the actual onset time of the stimulus, and processes the duration from this start time rather than from the end time of the previous stimulus. This is necessary in order to stay synchronized with the vertical blanking events. If timing does not re-synchronize with the actual vertical blanking, the display timing and display updating will drift and cause display tearing where part of the previous screen stays on the screen while only a portion of the new screen occurs. When using Display.FlippingEnabled, the Sync tab is required to be set at vertical blank.
Using Refresh Alignment
As we’ve just described, display duration times should be specified as multiples of the refresh rate, particularly for display durations that are less than 100 ms. However, it is often not possible to enter a display duration that is divisible by the refresh rate, for two reasons. First, a 60 Hz monitor refreshes the screen every 16.6666667 ms, but E-Prime requires you to specify display durations as non-decimal values. Therefore, in the case of a 60Hz monitor, the display duration would have to be specified as either 16 or 17 ms. Similarly, the refresh rate itself is rarely a whole number. For example, a monitor that we commonly refer to as running at 60Hz isn’t running at exactly 60Hz; instead it is likely running around 59.98 Hz or 60.02 Hz. These differences are considered to fall within the acceptable hardware tolerances of the hardware manufacturer.
Eventually, you will encounter a scenario where the next scheduled display time occurs just after a refresh occurs, and therefore the system will have to wait another full refresh of the screen before the next display can be written to the screen. Let’s consider a specific example with a Refresh rate of 60 Hz. The experimental sequence involves two displays, Display1 and Display 2, each with a duration of 1000 ms. Assume that Display1 draws at time 1234; Display is then scheduled to appear at time 2234. Assume further that the next refresh is scheduled to occur at time 2233. Without the use of the RefreshAlignment feature, Display2 will not display until time 2249 (2233 + 16), which makes Display1 on the screen effectively for 1015 ms as shown in Figure 3.
RefreshAlignment instructs E-Prime to start looking for the refresh event earlier than what is indicated by the current display object’s duration. It is set on the Display Device properties page in E-Studio. RefreshAlignment is specified as a percentage of the refresh rate, and the default value is 25%. Therefore, on a 60 Hz monitor with 16.6667 ms per refresh, RefreshAlignment will being looking for the refresh event up 4.1555 ms early. In the case of the current example, E-Run will start looking at time 2229, and therefore detect and respond to the refresh event which occurs at time 2233.
This makes the effective duration of Display1 = 999, and Display2 starts within one ms of its target value. If RefreshAlignment were not be utilized, then Display1 would have an effective duration of 1016, because it would be displayed for an additional refresh after E-Prime missed the early refresh, and Display2 would be displayed 16 ms after its target value.
This example assumes that RefreshAlignment is being used in conjunction with Event mode. With RefreshAlignment and event mode, the next TargetOnsetTime is adjusted after an early refresh is detected. Conversely, when using RefreshAlignment in Cumulative mode, the next target onset time is not adjusted. As a result, Display1 is displayed for a shorter amount of time (999 ms, the same as in event mode), but Display 2 is lengthened.
In Figure 3, the black solid line at time 998 shows when a Refresh will occur. The gray line at time 1000 shows the next target onset time. The black/gray line shows when the next refresh after 998 would occur, assuming that you are running at 60 Hz. With RefreshAlignment on (see top panel), the object that is targeted to start at 1000 begins 2 ms sooner to catch the refresh at time 998. However, since we are in cumulative mode, the next target onset time is not changed, and as a result Display2 then runs for 2 ms more. The effective error on two objects is -2 ms and +2 ms.
If the same experiment were run in cumulative mode but with RefreshAlignment off, then the object targeted for 1000 ms has to wait until 1014, since the early Refresh at 998 was missed. Therefore, Display 1 appears for one extra refresh. Since we are in cumulative mode, the duration of Display2 is reduced by one refresh. The effective error in this example is +14 ms for the first display and -14 ms for the 2nd display. Notice that with the user of Refresh Alignment, negative OnsetDelays will occur and they are acceptable – a negative OnsetDelay does not indicate a problem in the trial sequence unless you get them for a large number of trials which might indicate that the Duration is not divisible by refresh rate.
Summary, Display Durations, Refresh Rate and Synchronization
The combination of specifying a reduced display duration and synchronizing with the vertical blanking allows the experiment displays to be accurate even with minor timing variations in the refresh rate. It is important to note that even using the same model display card on two identical computers may result in slightly different refresh rates. Hence, a 50 ms duration on one monitor might result in a period of 49.9 to 50.1 ms across cards.
If Event timing mode is in use, the actual duration for which the participants sees a stimulus is equal to the Duration specified for the stimulus object plus the OnsetDelay of the next object that alters the visual location of the first stimulus. For example, if the duration for the first stimulus was set to 90 ms, and the next stimulus had an onset delay of 10 ms, the true duration of the first stimulus would be 100 ms.
E-Prime offers the ability to use Display flipping to perform any drawing operations. The use of flipping is recommended especially for larger displays to reduce the possibility of display tearing (when part of the new/old screen appears at the same time). Use of flipping requires a PreRelease value of approximately one refresh duration for the object that precedes the drawing object to ensure proper scheduling. Without ample PreRelease, the object will schedule for the following refresh period. This would be reflected in the OnsetTime and OnsetDelay properties.
NOTE: When flipping is enabled, all E-Basic Canvas calls targeting the on-screen canvas will internally wait for the vertical blank refresh period. The use of Display.WaitForVerticalBlank will thus not be necessary and if used would cause the Canvas operation to draw a refresh later. Whether using flipping or not, it is recommend when performing any drawing commands to do so on an off-screen canvas and then use one Canvas.Copy operation to update the screen. Sending output to multiple monitors Researchers are sometimes interested in sending output to more than one display. The best execution for this depends on the motivation for the multiple outputs in the first place.
When running off of the laptop, especially those built prior to 2010, users often want to send output not to the built-in LCD display but instead to an external VGA CRT display. Given the decrease in the display latencies for LCD monitors, this has become less of a concern and there is less need to do so. Further, as VGA connectors become less common, this becomes a less available option. However, there are no adverse timing implications when running E-Prime on a laptop while sending the display signal exclusively to a CRT monitor (built in LCD disabled).
Conversely, there are adverse timing implications when using the duplicate, mirroring, or cloning modes to send output to multiple monitors. When duplicating, mirroring, or cloning the display, the equipment will make attempts to synchronize displays, but this may result in settings that you are not aware of. To be safe, if you must run in such a scenario, you need to confirm the settings/performance of each display device with a third-party tester such as the Black Box Toolkit.
Users who are performing MRI and fMRI experiments with E-Prime often need to send the same display information to two monitors, one located in the MRI room and the other in the technician’s observation room. The best solution in such cases is to utilize Psychology Software Tools projection system Hyperion. With this solution, the output port on Hyperion is used to direct output to the control room display. Therefore, both the MRI and the control room monitors are able to view the same screen, but without using the duplicate/mirror feature.
Caution also needs to be exercised when sending output to a television, including plasma, LCD LED, and OLED-based systems. Television-based systems have more “tricks” to squeeze more performance out of the system, including how they interpret interlaced signals to eliminate any appearance of interlacing. In general, though, you should select the television options that are recommended for gaming mode, since gaming users are often pushing the envelope of display performance.
Sound Latency Solutions
E-Prime provides several tools to address the sound latency problem.
- The Sound Tester application helps you to identify the optimal configuration for your computing environment. The Sound Tester is described in E-STUDIO: Sound Devices 
- The CodecConfig utility helps to identify the optimal codecs to use for particular sound files. CodecConfig is described in GETTING STARTED: Codec Config .
- PST periodically tests different sound cards and reports our latest results.
1E-Prime has the ability to specify more than one monitor for each display device; this can be useful, for example, when running an experiment from a laptop and directing the output to a CRT monitor that is connected to the laptop. With such a scenario, you still do not want to match the desktop resolution.