fastshft

deliver stimuli for steady-state visual attention experiments

usage: fastshft

fastshft is an MSDOS program that delivers a configurable sequence of visual stimuli at the left and right margins of the upper hemifield of a video display. It sends an event code at the beginning of each stimulus, at each horizontal shift of the joystick (or other game port input device), and at the beginning and the end of each block of stimuli. (A previous version of fastshft was implemented in Microsoft QuickC, sent event codes via the parallel port only, and handled processor interrupts. This document discusses only the current version, which is implemented in 80286 assembly language can be configured at compile time to send codes via a serial port or a parallel port, and ignores interrupts.)

STIMULI
fastshft uses graphics mode 13h (320 x 200) to plot square stimuli 50 pixels wide and 43 pixels high, vertically centred and horizontally placed at the left and right horizontal margins of the display. (The unequal pixelwise horizontal and vertical dimensions compensate for the display aspect ratio.) These vertically centred squares are superior to a fixation cross, which is plotted in white against a black background, with its central point at the horizontal centre of the display and vertically offset from the top of the display by a distance equal to the stimulus height plus three fourths of the display height. The number of pixels in each of the four arms of the fixation cross, not counting the pixel at the centre of the cross, is one eighth of the horizontal extent of the stimuli -- i.e. 6 pixels.

The program begins by reading unsigned byte (range 0 through 255) stimulus codes from the file STIMULI.DAT in the current directory. No bounds-checking is performed as the contents of the data file are stored; thus it is possible for a large data file to overwrite fastshft's executable code. If this happens, unpredictable behaviour will ensue and you'll need to reboot the system. The absolute limit on the number of entries in the data file is 65280 (hex FF00) minus the size of the executable file FASTSHFT.COM. This quantity generally will not exceed 63800.

Configurable aspects of stimulus display are associated with stimulus codes read from the configuration file STIMULI.DAT, and events to be logged by the data recorder are associated with event codes sent through the serial port. Some occurrences, such as target stimuli and trial control, have both stimulus codes and event codes:

EVENTSTIMULUS
CODE
EVENT
CODE
left background stimulus 1  
left target stimulus 2 2
right background stimulus 3  
right target stimulus 4 4
begin trial attending left 5 5
begin trial attending right6 6
end trial 7 7
left response   126
right response   127
start recorder   132
stop recorder   136

The target and background codes cause the respective stimuli to appear at the left or right edge of the screen. Drawing and blanking of these stimuli are synchronised to the video hardware's vertical sync pulse in order to avoid flicker and to ensure constant, reliable display timing. Each display cycle consists of four sync periods. At the usual vertical sync timing of 72s-1, a single sync period is 13.89ms and thus a display cycle is 55.56ms. If stimuli are alternated between the two different sides of the display, as is the usual procedure in the two-location steady-state paradigm, the resulting stimulus period is 111.11ms and thus the stimulus rate is 9s-1 with a 50% duty cycle, with the two locations exactly out of phase.

EVENTS

During its initialisation, fastshft examines BIOS memory (segment 0040h) to determine the host machine's I/O configuration and port addresses. It is assumed that the machine contains at least one parallel port and at least one serial port. If the machine contains more than one serial port, the first expansion serial port (COM2) is used; otherwise the program defaults to COM1. The serial port is set for eight data bits, no parity, and one stop bit (8N1) at a baud rate of 19200.

Target codes (code 2 and code 4), in addition to causing a target stimulus to be displayed, are copied onto the serial output line so that target events can be logged by a recorder. Responses are also logged: fastshft polls the game port input at the beginning of every refresh cycle, and places an event code on the serial output if the game port's status has changed since the last poll.

TRIAL CONTROL

The two `begin trial' codes cause the software to display a white square in the stimulus location on the designated attended side, and then to wait for a key to be pressed. If that key is a control-C, the program aborts. Otherwise, the program waits until the state of the input device matches the designated side. The program then sounds a tone to signal that the scan should begin, and monitors the parallel port's BUSY input for a negative-going sync pulse from the scanner (see the `hardware' section of this document for information on coupling the scanner pulse into the parallel port). When a sync pulse is received, or when an override has been received from the keybord, the recorder start code (132) is then output via the serial port, and the white square is removed. (132 is the start code accepted by the ISCAN data recording system when serial triggering is enabled; see the ISCAN documentation for details.) After waiting for a period of at least one and no more than two vertical sync cycles (at least 13.89ms and no more than 27.78ms) so as to give the data recorder time to start, fastshft sends a strobe pulse (negative-going, ~5µs duration) on the parallel port to trigger the MRI scanner, and then presents stimuli until an `end trial' code (code 7) is reached.

On encountering an `end trial' code, fastshft sends the `end trial' code via the serial port, waits for a period of one to two vertical sync cycles, and then sends the recorder stop code (136).

EYE MOVEMENT CALIBRATION
fastshft is designed for use with the ISCAN infrared eye tracking system. This system requires that the eye tracker be calibrated to directions of gaze at the centre and the cour corners of the display. When fastshft starts, it displays small yellow targets at these five locations, in the order expected by the ISCAN calibration procedure (centre, top left, top right, bottom left, bottom right). A control-C during display of a calibration target restarts the calibration display, returning to the centre target. Any other key causes the display to proceed to the next calibration location.

TERMINATION
On termination, the graphics mode and interrupt mask are restored to those that were current when fastshft was invoked. The serial port configuration is not restored.

HARDWARE
fastshft is engineered to work with an optical input transduced by a high-resistance photocell connected between +5V (game port pin 1) and the X axis input (game port pin 3). (The photocell used during development was a CdSe cell, type 7H, Mouser Electronics stock number 621-CL707H, full on-resistance ~ 0.6MΩ, off-resistance ~ 335MΩ, peak sensitivity at 620nm, illuminated via two DB-1000 1mm plastic optical fibres from a high-output light emitting diode, Radio Shack 276-086A, 5cd at 660nm peak. The LED is in series with a diode and a capacitor to limit and to smooth out any currents induced on the power supply line by the scanner gradients.) This photocell in parallel with a 100kΩ resistor, and in series with the standard 0.01µF capacitor and current-limiting resistance internal to the PC game port interface yields a rise time on the order of 380µs when dark and 335µs when illuminated. (In our setup, the end of the fibre is covered when the subject's finger is moved right, and uncovered when the finger is moved left.) A calibration routine at the beginning of the program establishes a threshold rise time for distinguishing the two states. For purposes of hardware debugging, rise times measured in arbitrary units can also be read by the command-line program joystk. These arbitary units can be calibrated against the video refresh period by the program joycal.

circuit diagram for response box

The General Electric Signa scanner can be configured to provide a negative-going TTL sync pulse at the start of scan or at the start of each excitation. We use a 7404 inverter to buffer this signal into a transistor which pulls the parallel port's BUSY input down to ground during the sync pulse. Power for the inverter is drawn from the data line D0. On older parallel ports, this data line may not be able to provide more than 3V and may not be able to source much current; hence, for maximum compatibility, our design uses the 74HCT04 CMOS version of the chip:

circuit diagram for scanner interface

Author: Matthew Belmonte.