last updated 04 August, 2002
VCortex: Cortex for Windows
(beta version 1.0)
User’s Manual
Laboratory of Neuropsychology, NIMH
1. Introduction *
1.2 Getting the latest version of Cortex *
1.3 Technical Support *
1.4. History (you may skip this part) *
2.2 Single-computer Cortex without graphics (\VCWin32\VCSingle.EXE) *
3.1.1 Typical Keithley/Metrabyte DASH-16 settings *
3.1.2 Typical PIO24 or CIO-DIO24 settings *
3.1.3 Typical Computerboard CIO AD-16, CIO-DAS16/F, and CIO-DAS1602/12 settings *
3.2 Graphics Board Setup *
3.3 Data Acquisition Interface Setup *
3.3.1 Spike Flip Flop Circuitry *
3.3.2 Thalamus *
3.3.3 Screw Terminal Interface Diagram for the DASH-16 type boards *
3.4 Sound Card Setup *
3.6 Cortex Software Setup and Program Execution *
3.6.1 Minimum Files Necessary to run Windows VCortex *
3.6.2 Installing VCortex on a computer without any data acquisition boards, or a computer that only has PIO24 type boards *
3.6.3 Installing VCortex on a computer with a CIO-DAS16 type board *
3.6.4 Installing the DirectX Receive Program on the receive computer (Win95/98/2000/XP) *
3.7 Uninstalling Cortex *
4.2. Item files *
4.3. Conditions files *
4.4. Timing files *
4.5. Using the ITEMS, CONDITIONS, and TIMING files in a study *
4.5.1 Deciding on your Experimental Design *
4.6. Customizing Cortex with the Cortex.cfg configuration file *
5.1.1 The File Menu *
5.1.2 The Edit Menu *
5.1.3 The Options Menu *
5.1.4 The Tools Menu *
5.1.5 The Run Menu *
5.1.6 The Clear Menu *
5.1.7 The View Menu *
5.1.8 The Window Menu *
5.1.9 The Help Menu *
5.2 The File Menu Dialog Boxes *
5.2.1 File->Load->Item File *
5.2.2 File->Load->Condition File *
5.2.4 File-> Load ->Saved File *
5.2.5 File-> Load ->LUT File *
5.2.6 File->Load->External Variables File *
5.2.7 File->Load->Blocks File *
5.2.8 File->Save->Item File *
5.2.9 File->Save->Condition File *
5.2.10 File->Save->Saved File *
5.2.11 File->Save->LUT File *
5.2.12 File->Save->External Variables File *
5.2.13 File->Save->Blocks File *
5.3 The Edit Menu Dialog Boxes *
5.3.1 Edit->Individual Item *
5.3.2 Edit->Individual Condition *
5.3.3 Edit->Timing File->Modify *
5.3.4 Edit->Timing File->Delete *
5.3.5 Edit->External Variables->Generic Externs *
5.3.6 Edit->External Variables->Named Subsets *
5.3.7 Edit->Fixspot Item *
5.3.8 Edit->Reference Item *
5.3.9 Edit->LUT *
5.3.10 Edit->Add an Item *
5.4 The Options Menu Dialog Boxes *
5.4.1 Options->Block / Repeat->Sizing *
5.4.2 Options->Block / Repeat->MasterBlock *
5.4.3 Options->Block/Repeat->Individual Blocks *
5.4.4 Options->General Parameters *
5.5 The Tools Menu Dialog Boxes *
5.5.1 Tools->LUT->Set Number of Palettes *
5.5.2 Tools->LUT->Activate *
5.6 The Run Menu Dialog Boxes *
5.6.1 Run->Start *
5.6.2 Run->Resume *
5.6.3 Run->Stop *
5.7 The Clear Menu Dialog Boxes *
5.7.1 Clear->External Variables->All *
5.7.2 Clear->Blocking->CONDstats *
5.7.3 Clear->Blocking->BLOCKstats *
5.7.4 Clear->Blocking->Reset All *
5.7.5 Clear->Histogram/Rasters *
5.8 The View Menu Dialog Boxes *
5.8.1 View->Results of most recent trial->Codes *
5.8.2 View->Results of most recent trial->EOG values *
5.8.3 View->Display an Item *
5.8.4 View->Display a Condition *
5.8.5 View->Status Bar *
5.9 Window Menu Dialog Boxes *
5.10 Quick Start Instructions *
5.10.1 Dual Computer Cortex version (VCSend) *
5.10.2 VCSingle version *
6.2. Data file format *
6.3. Interrupt structure *
7.1.1 The Cortex Image File Format *
7.1.2 Image File Formats Available with DirectX version of Cortex *
7.1.4 Transparency with DirectX receive program *
7.2 Movie File Formats *
7.2.1 Cortex Movie File Format *
7.2.2 Movie File Formats Available with DirectX version of Cortex *
7.3. Color Lookup Table *
7.3.1 What is a Color Lookup Table? *
7.3.2 How Cortex uses Color Lookup Tables *
7.3.3 Using the Cortex LUT Menu Options *
8.2. Components *
8.3. Compiling the executables *
8.4. Adding new functions and external variables to Cortex *
8.4.1 Adding new system functions to Cortex *
8.4.2 Adding library functions *
8.4.3 Adding External Variables to Cortex *
8.4.4 Rebuilding Cortex after adding new functions and variables *
10.2 Image file does not display *
10.3 Movie file does not display *
10.4 Sound does not play *
10.5 Timing file does not compile *
10.6 Spikes are not appearing in the histograms *
10.7 Colors do not look correct for BMP files *
10.8 Display of movies is slower than the refresh rate of the monitor/graphics card *
10.9 EOG data is not being stored to file *
10.10 EPP data is not being stored to file *
10.11 Adjusting the gain of the analog data *
10. 12 Can not see spike codes when viewing data *
10.13 "ERROR: CODE_ISI buffer overflowed x times (data was lost)" in the error file *
A.2 Options->Block/Repeat Menu *
A.3 Functions available for MANUAL operation *
A.4 Technical details on the internal operations of the Cortex code *
Appendix C: Sample Cortex.cfg file *
Appendix D: New Timing File Functions in the Windows version of Cortex *
Copyright notice *
Cortex is a program for running neurophysiological and behavioral experiments on a PC. Although it is still undergoing revisions, the DOS version of Cortex is a working program that we have been using to collect data for more than eight years. The integrity of the data, timing accuracy, etc. has all been validated. Cortex runs behavioral paradigms designed by the user, displays visual stimuli to the subject, collects neurophysiological and behavioral data, monitors and stores eye position data, and shows the results to the user during the experiment. Because Cortex has the capability to display and manipulate any image that has been previously created and saved on disk by the user, the variety of visual stimuli it can present is practically unlimited. The program is oriented toward experiments in vision, but it can be used in a variety of other contexts.
Data acquisition capabilities include (dependent on the available I/O hardware) up to 40 spike inputs (TTL +5v digital inputs), specialized functions for monitoring hand-bar and lever movements (TTL +5v digital inputs), eye-movement monitoring functions (A/D inputs), keyboard, and mouse inputs. Reward triggering for alert-subject experiments is accomplished through TTL +5v digital output. The user retains access to the full-array of possible uses for the I/O equipment on-board (such as D/A output, or specialized digital I/O) with easy-to-use C functions. Up to five data acquisition boards, one of each type, may be accessed by CORTEX.
A separate computer is currently responsible for the graphical display on the subject's monitor. Any VESA compliant graphics card/monitor, which is supported by Microsoft DirectX, may be used. Many of the low-level technical aspects of graphical programming are handled directly by CORTEX; thus the graphical programming environment is relatively simple to use.
CORTEX is designed to simplify combined behavioral and neurophysiological experimentation by directly handling trial randomization and simple staircasing. The user retains complete control of the trial staircasing, if desired, and can generate any staircasing paradigm needed. The user can even change the staircasing design on-line, in any way, based on behavioral responses.
Associated with Cortex are a number of utility programs. Shipped with Cortex, in the \VCWin32 directory, is the DOS program, CORTVIEW.EXE. This program can be used to view the contents of the Cortex output data file. Rather than viewing the results, this program also can be used to pipe the output to a text file. From the Cortex web site, there are links to other Cortex data analysis programs. One program that was written at the Laboratory of Neuropsychology (NIMH) is the Cortex Windows Workbench. This program provides an interactive and graphical look at Cortex data files. Cortex files can also be analyzed using PCOFF, which was developed in the Laboratory of Neurophysiology (NIMH). PCOFF is a comprehensive event code sequence search program that supports graphical display of rasters, histograms, reciprocal interval plots, using a number of different schemes to align data on specific events. The program also does analog signal processing (e.g. integration, averaging, etc.) as well as non-parametric and descriptive statistics. The Laboratory of Neurophysiology recently contributed a program called MatOFF. It is a powerful event search and data plotting program based on their earlier PCOFF program. Matoff runs under Microsoft Windows using MATLAB. Other laboratories at NIH, the University of Verona, MIT, and the Salk Institute have also contributed Matlab routines to help with the analysis and use of Cortex. These Matlab routines can be accessed from links on the Cortex web page.
This document describes the new Windows version of Cortex, VCortex. It was named "VCortex" since the interface was written with Microsoft's Visual C++ product. Rather than supplying a document describing the differences from the DOS version of Cortex, or even assuming a knowledge of the DOS version, this document was intended to stand on its own for VCortex. Of course, there is so much overlap between the two versions, much of the documentation is identical to the DOS version. In fact, the program will still be referred to as "Cortex", instead of "VCortex" in most of this document.
New users of Cortex are encouraged to read this entire manual. Experienced DOS users of Cortex should read Chapters 2, 3, and 5 for the major changes. Additionally, Appendix B contains a list of know bugs, limitations, and differences from the DOS version of Cortex.
1.2 Getting the latest version of Cortex
The latest code, executables, and documentation can be downloaded from the Cortex web site:
http:// www.cortex.salk.edu/
If you are experiencing problems with Cortex which are not covered in the Cortex documentation, please post a message to the Cortex web site's discussion group. The discussion group can be accessed from the "Discussion" page of the Cortex home page (http://www.cortex.salk.edu/discuss.htm).
1.4. History (you may skip this part)
CORTEX has been gone through so many transitions over the decades that it is daunting to list everyone who has contributed to its development. Dr. Robert Desimone, who has overseen and guided the development of CORTEX since he initially ported it from the PDP-11 platform over a decade ago, made a valiant effort to do so several years ago. This is quoted below.
Thomas M. White - the lead programmer for CORTEX from 1989-1997. Re-wrote CORTEX from scratch, implemented the in-line compiler (the CORTEX state system - CSS), real-time multi-threaded data collection system, and support for multiple touch screens, graphics boards, and data acquisition systems. He also wrote the initial procortex, Stats100, and Grast utility programs. He is now devoting his time to earning a MD degree from Cornell University.
Trina M. Norden-Krichmar - took over the role of lead programmer from Tom White in the fall of 1997. She added a Windows DirectX receive program, support for DirectX sound and movies, and support for PCI data acquisition boards. She is currently working on the implementation of a Windows version of the send program, supporting the DOS version, and updating the documentation.
Jessica Olsen - joined the Cortex Team in the summer of 2001. She took Trina's simple Visual C++ Windows version of the Cortex interface, and wrote the MFC code to transform it into the wonderful dialog boxes and menus that you see today. She also has spent a lot of time testing and contributing to the documentation of the Windows version of Cortex.
Others who have contributed substantially to CORTEX include:
Dr. Steve Macknik - wrote the TIGA and MGL graphics modules, as well as the User's manual.
Dr. Andrew Mitz - helped write the technical manual, contributed several user-accessible functions to CSS, and contributed the PCOFF and MatOFF data analysis programs.
Jamie Mazer - contributed the Set module and several user-accessible functions to CSS.
Dr. Earl Miller - overhauled the Grast program for graphical analysis of CORTEX data files, but now has contributed Matlab versions of these analysis tools.
Robert Baumann - developed the CORTEX Windows Suite - a set of tools to facilitate the analysis of CORTEX data files.
Giuseppe Bertini - helped design the Cortex web pages, especially the framed function reference, and contributed Matlab data analysis routines.
David Mechner – wrote the code to support sound in the DOS version of Cortex.
Dr. Robert Desimone wrote the following for the 1997 version of the Cortex User's Manual:
It is currently impossible to list all of the people who have helped in the development of CORTEX, through their suggestions, testing, and bug-reports. The section below acknowledges those who were most helpful in CORTEX's early years.
The remote ancestor of Cortex can be traced to an assembly language program for collecting spike data and controlling an optical bench, written for the PDP-12 by David Bender in Charlie Gross' lab at Princeton during the early 1970's. The PDP-12 was a state-of-the art laboratory computer with 8K of core memory (and a 12-bit word), a bit-mapped graphics display, a real-time programmable clock, and analog and digital interfaces built in. After Dave left Princeton for Buffalo, I assembled the necessary components for a PDP-11 system (which, shockingly!, had no lab interfaces built in) and sketched the requirements for a new spike collection program that could make use of the luxurious 64K of memory (and 2.5 MB hard disk!) that was then available. The core of this program was written in 1980 in Whitesmith's C by a moonlighting mathematician, Phil Thrift, and a high school student who had been programming in C since age 12. When I left Princeton for NIMH, the program branched in its development. One branch continued to be developed at Princeton by Tom Albright, and the other branch developed at NIMH. Jeff Moran at NIMH significantly rewrote the program, then called "Behave", and added modules for controlling the subject's behavior and controlling an external Jupiter Graphics system for presenting stimuli.
As to be expected, a memory size that once seemed luxurious eventually became ridiculously too small. After the introduction of the IBM-AT, Stan Schein and I decided to switch from the PDP-11, in part because of the great difference in price and in part because the C compilers for the AT allowed transparent access to 640K of memory, whereas it was difficult to use more than 64K on the PDP-11. A Pepper SGT graphics card from Number Nine Computer was eventually chosen to replace the Jupiter graphics system. Stan, who moved from NIH to Harvard Medical School, hired Thuan Tran, then a computer science student at MIT to port the program after I had naively (and innocently!) assured Stan that the porting would take at most six weeks, once we understood all of the new hardware. Because the old program was inflexible and filled with kludges to get around memory limitations, Thuan did not actually port it. Although he retained a few design aspects of the original PDP-11 program, he completely rewrote and greatly expanded the program over the course of the next couple of years after graduating from MIT, with direction on the design by Stan and myself and support from Stan's grant (R01-EYO6096).
In 1989, Thuan took a full time job with a computer company but continued to work part-time on the state-system interface to Cortex, on contract to NIMH. At about the same time, I hired Tom White at NIMH, and he significantly rewrote most of Cortex again, in order to make it more user friendly, to greatly upgrade its stimulus display capabilities, and to improve the maintainability of its source code. He also took over the development of GRAST, a histogram display program, and Procortex and STATS100, numerical analysis programs, greatly expanding and rewriting them over the course of the past year. Tom integrated STATS100 with SYSTAT, a commercial statistical program, and wrote a data analysis compiler that users can use to write their own analysis routines, without doing any actual programming. Tom is now at Cornell Medical School in a MD/Ph.D. program, but continues to work on Cortex occasionally, out of the goodness (truly) of his heart. I myself work on Cortex code, in my spare milliseconds, and am reasonably familiar with the workings of most of the modules. Rosalyn Merrill (NIMH), Amir Geva, and Jeff Moran also worked on small pieces of code for either Cortex or GRAST at one time during their development. Most recently, Marcello Gattass, the brother of Ricardo Gattass, has taken over the development of GRAST for the time being. Marcello promises a MS Windows version of GRAST sometime in the future. Steve Wise at NIMH has contributed towards some of the considerable development expense of Cortex. Finally, Cortex has benefited from the suggestions (and, unfortunately, bug-finding) of many of its users, particularly Mark Wessinger, Lin Li, Sidney Lehky, John Duncan, Earl Miller, Jennifer Hart, Driss Boussaoud, Josef Rauschecker, Ricardo Gattass, Leonardo Chelazzi, Andy Mitz, Richard Jeo, Carl Olson, Rebecca Hoag, and Peter DeWeerd.

A Pentium computer (at least 100 MHz) with 32 MB RAM and at least a 1 GB hard drive for data storage is recommended. These specifications are based on the assumption that the computer will have Win95/Win98 installed on it also.
For the DirectX receive program, the computer must contain a DirectX supported graphics card.
Like the send computer, the receive computer should also be a Pentium computer with at least 32 MB RAM. Since graphics are more CPU intensive, if you have two unequal computers, the faster computer with more memory should be the receive computer.
The Windows DirectX receive program must be run from Windows. It can run with Win95, Win98, Win2000, WinXP. WinNT definitely can not be used for the DirectX receive program, since it does not support DirectX 5.0 or higher.
A graphics card with at least 4 MB of onboard video memory is recommended.
Some testing on a CIO-AD16 was also performed successfully. Therefore, it is likely that all of the ISA data acquisition boards originally specified for the DOS computer version of Cortex should also work with the Windows version of Cortex. From Keithley/Metrabyte, there are: DASH-16 (for analog and digital I/O), and the PIO24 or PIO96 (for digital I/O only). From ComputerBoards, there are the clones: CIO-DAS16, CIO-AD16, CIO-DAS1602/12, CIO-DIO24 and CIO-DIO96.
The PCI versions of the data acquisition cards are not supported in this release of VCortex.
When you are buying your data acquisition board, you may also want to order a screw terminal interface. The Metrabyte "Universal Screw Terminal Accessory Board STA-U" works well with the CIO products.
For use with all data acquisition boards, the screw terminal interfaces must be altered (flip-flops must be added) or have another device that performs the latching, in order to collect spike data. The Cortex web page contains the necessary diagrams under the heading "Spike Flip-Flop Circuitry and Thalamus".
Cortex home page http://www.cortex.salk.edu/
ComputerBoards, Inc. http://www.computerboards.com
Keithley/Metrabyte http://www.keithley.com/
Microsoft DirectX http://www.microsoft.com/windows/directx/downloads/default.asp
The VCSingle.exe version is a Windows program, which does not display graphics. The serial communications functions and the analog/digital capabilites are supported. Therefore, this version can be used when graphics are not necessary, or when the graphics are displayed by some other means.
2.2.1 Computer
A Pentium computer (at least 100 MHz) with 32 MB RAM and at least a 1 GB hard drive for data storage is recommended. These specifications are based on the assumption that the computer will have Win95/Win98 installed on it also.
3.1.1 Typical Keithley/Metrabyte DASH-16 settings
4) gain = whatever is convenient
5) analog eye inputs (EOG): analog input channels 3 High and 4 High
6) evoked potentials (EPP): analog input channels 1 High and 2 High
7) bar contact input: digital input 2 and 3
9) spike inputs (2 or more separate spike channels): digital inputs 0 and 1 (for the first two inputs), which are fed by flip-flops (provided by the user’s electronics shop...see Section 3.3 entitled "Data Acquisition Interface Setup"). Typically one uses the "user 1 and 2" lugs on the Metrabyte interface connector board to access the flip-flops.
10) output to clear flip-flops: digital output 0
3.3.1 Spike Flip Flop Circuitry
3.3.3 Screw Terminal Interface Diagram for the DASH-16 type boards
(DASH-16, CIO-DAS16/F, CIO-AD16, and CIO-DAS1602/12)
The dual computer Cortex program has the ability to play sounds. Sound can be used not only as stimuli, but also as an auditory feedback mechanism to assist in training. Up to 256 different sound (.wav) files can be played during an experiment. Additionally, the volume and mix of the sound from the speakers can be changed during the experiment through function calls in the Cortex timing file (see the Timing File Reference Manual for details about the functions).
Any sound card which is supported by DirectX can be installed
in the receive computer. After the sound card is installed in the computer,
the DirectX driver must be installed. Certain problems with the sound initialization
and execution during the use of Cortex are logged to the file "dxrecv.err"
on the receive computer. Please note that the sound (.wav) files must be
present on the receive computer.
3.6 Cortex Software Setup and Program Execution
In all configurations, the first step is to download the
latest VCortex distribution file from the Cortex web site. Using WinZip
or PKUNZIP.EXE, unzip the distribution file. In the instructions below,
it is assumed that the file was unzipped into the C:\VCortex directory.
3.6.1 Minimum Files Necessary to run Windows VCortex
VCSend.exe - the Windows Send program which communicates with a receive computer via a serial connection. (Replaces \remote32\wcsend.exe in the DOS version.)
VCSingle.exe - the Windows Send program which was modified so that it does not communicate with a receive computer. The serial communications and analog/digital capabilities are supported. Therefore, this version can be used when graphics are not necessary, or when the graphics are displayed by some other means. The advantage of this version is that it can be run from your desktop computer to test out timing files, etc. (Replaces \remote32\sgl32.exe in the DOS version.)
DXRecv.exe - the Windows DirectX Receive program. This program should be run from the receive computer.
cdas16.vxd - the device driver for the CIO-DAS16 type boards. If the send computer contains a CIO-DAS16 type board, this device driver programs the board to provide the timing for the Windows Cortex program.
randsd.vxd - the device driver that uses the Windows Virtual Timer Device to provide the timing. This driver is used if the user does not have a CIO-DAS16 type board. It can be used when the user only has the PIO24 type boards, or has no boards at all (i.e., the RANDOM_SPIKE_DEVICE).
cortex.cfg - like the DOS version of Cortex, this is the usual configuration file that Cortex reads in order to determine the user's hardware specifications, graphics specifications, etc. Note that some of the parameters must be set differently than in the DOS version. Refer to Appendix C for an example cortex.cfg file.
css_inc.h, encodes.h - like the DOS version of Cortex, these are the usual files required by Cortex during execution. Note that the css_inc.h file had to be changed so that the keyboard mappings are the Windows equivalents of the DOS key codes. Therefore, this css_inc.h must be the one used, not the old DOS version of the file.
msvcrt.dll, gcl52fw.dll - two DLLs that may be
needed to run the Windows version on your computer. msvcrt.dll provides
the Microsoft user interface computers. gcl52fw.dll provides the serial
communication components.
3.6.2 Installing VCortex on a computer without any data acquisition boards, or a computer that only has PIO24 type boards
device=c:\vcortex\vcwin32\randsd.vxd
(assuming the zip file was unzipped to the c:\vcortex
directory)
SET CORTDIR=C:\VCortex\VCWin32
(assuming that the zip file was unzipped to the c:\vcortex directory)
This line will help VCortex find the css_inc.h file at all times.
device=c:\vcortex\vcwin32\randsd.vxd
device=c:\vcortex\vcwin32\cdas16.vxd
(assuming that the zip file was unzipped to the c:\vcortex directory)
CDAS16=5
(assuming that 5 is the free IRQ# in your computer)
SET CORTDIR=C:\VCortex\VCWin32
(assuming that the zip file was unzipped to the c:\vcortex directory)
This line will help VCortex find the css_inc.h file at all times.
Refer to section 3.6 above, to see the changes to system.ini and autoexec.bat that were required to run VCortex. Comment out or remove these lines from system.ini and autoexec.bat, and then reboot your computer. Cortex files will only exist in directories where you have copied the files. When installing a new version, it is best to just create a new directory. Delete the old directory when the new version works with your experiment. Remember to change the Cortex.cfg file to be appropriate for your setup, and autoexec.bat and system.ini files to reflect the proper paths.
Before Cortex begins running trials, the user must specify the different varieties of experimental conditions that are to be run in the session.
4.1. Setting up the experimental conditions.
To set up the experimental conditions, it is necessary to write at least three ASCII text files "off-line", which you then import into Cortex. These three files can be written using your favorite text editor. Word processing programs cannot be used unless they can output a standard ASCII text file, which some word processing programs have as an option. It is best to work from an already existing set of files (such as the examples and demos provided with Cortex), which you can edit and modify, rather than to try to write the files from scratch the first time.
The three files you must write are items, conditions, and timing (state system) files. For a given experimental session, you can import only a single item and condition file into Cortex, but multiple timing files.
For the items and conditions files, you will note that at the top of each file, there are headings such as ITEM, TYPE, CENTERX, etc. These headings are special keywords that you should not alter. The first and last character of each keyword define the beginning and end of the data field columns located under the keywords. That is, you enter your specifications in the columns situated under each heading word, taking care not to extend any data beyond the first or last character of the heading word. Because "tabs" can mean any number of spaces, depending on your text editor, Cortex cannot interpret tabs in the files. Thus, DO NOT USE TABS. USE ONLY SPACES between values in the items and conditions files. If you use tabs, previous versions of Cortex would read in your file in a jumbled manner and become very confused. The recent versions at least warn you that tabs are present in your file. If you get a warning about tabs, re-edit your file to remove them and then reimport the file. The state system file is free-format, so tabs are fine. The format of the files is given next.
For experiments in vision, you probably have in mind a number of visual stimuli that you want to present to a particular neuron or subject. Before specifying how and when you want the stimuli to be presented, it is first necessary to describe to Cortex the stimuli you want to present. These stimuli are referred to as ITEMS in Cortex.
You must describe each item you want to use in a given experimental session in the ITEMS ASCII file, which you import into Cortex at the start of the session. For example, you might want to compare the responses of a neuron to 20 bars of light that vary in color and orientation. In the items ASCII file, you would describe the 20 items in the format required by Cortex, including the type of visual stimulus (in this case, bars of light), their height, width, orientation, color, and position relative to some reference point on the display screen (to be described later).
An example items file is shown below:
ITEM TYPE FILLED CENTERX CENTERY BITPAN WIN_WIDE WIN_TALL HEIGHT WIDTH ANGLE INNER OUTER -R- -G- -B- C ------FILENAME------
-4 1 1 0.00 0.00 0 1.00 1.00 0.00 0 0 0 x
-3 1 1 0.00 0.00 0 0.30 0.30 0.00 255 255 255 x
-2 1 1 0.00 0.00 0 1.00 1.00 0.00 255 255 255 x
-1 1 1 0.00 0.00 0 1.00 1.00 0.00 255 255 255 x
0 1 0 0.00 0.00 0 3.00 1.00 0.00 50 50 50 x
1 1 0 0.00 0.00 1 3.00 1.00 45.00 100 100 100 x
2 8 0.00 0.00 2 1.8 1.8 230 0 230 x face.ctx
3 1 1 0.00 0.00 1 3.00 1.00 45.00 250 250 250 x
Some of the columns you must fill in within the items file are as follows:
ITEM. The ITEM refers to the item number, which you henceforth use in Cortex as the name or identifier of the stimulus you have created. Some items have negative numbers. These are "special" items that are used internally by cortex. Their meaning is usually as follows, but can be used differently:
-4 Background item
-3 Fixation spot item
-2 Reference field
-1 Reference point
0 Play item
TYPE. Cortex can handle many different kinds of items, which generally fall into two classes. The first class Cortex "knows" how to create itself. This class includes bars, circles, ellipses, annuli, and ASCII characters. Each of these types has an associated code number, which you enter in this column (see below for a list of type codes). In addition, you must enter the appropriate information about the items in the other relevant columns in the file. For example, bars need a length and width, circles need a radius, etc. The second class is bitmaps and movies, which are items that you have created outside of Cortex and saved in a disk file. These also have a "type" number, which you enter in this column. For these bitmap and movie items, you must also give the name of the disk file that holds them in the FILENAME column. For the format of these bitmapped files, see Section 7. All items, regardless of type also need an CENTERX and a CENTERY, which you enter in the appropriate column.
Item type codes:
1 bar
2 circle
3 circular annulus (outer and inner diameter should be entered in the inner and outer columns)
4-6 reserved
7 ascii character
8 bitmap (name of file must be in FILENAME column)
9 ellipse
10 annular ellipse
11 movie (name of file must be in FILENAME column)
FILLED. Objects such as bars, circles and annuli can either be filled or just an outline. If you put a '1' in this column the object will be filled, and if you put a '0' it will be an outline. If a FILLED parameter is not specified, the item will be filled by default.
CENTERX, CENTERY. Each object must have a location on the screen. This sets the x and y axis location, in degrees, from the reference point. The reference point is the location that Cortex defines to be the center of its coordinate system for placing items on the screen. The user can configure this location.
BITPAN. "Bitpannable" means that you plan to pan objects around inside a stationary window on the screen. A '0' in this field means that the object is not bitpannable, and cortex should treat it like any other object. A '1' in this field means that it is bitpannable, that cortex should utilize the window size you specify (see below), and that cortex should replicate the object 4 times, to give you more object to pan around with. A '2' in this field means the same as 1, but Cortex won't replicate it. If you use option 1, there may be sharp transitions in the image at the boundaries of the four replications, but for some purposes, this is OK. Also, you may need to set the bitpan field to 2 if you have an extremely large object. The Sgt. Pepper card will not allow you to import a bitmap larger than the display screen (640 x 480), unless you specify a window around it that is smaller than 640 x 480.
WIN_WIDE, WIN_TALL. When you give a window length and width (in degrees), and the object is bitpannable, Cortex will create a window around your item. This will allow you to pan a large object around inside a smaller window.
HEIGHT, WIDTH, ANGLE. Bars require a length, width and orientation, in degrees.
INNER. Circles and ellipses require an inner diameter.
INNER, OUTER. Annuli require an inner and outer diameter.
C (Color), -R-, -G-, -B-. For items that Cortex knows how to create, such as bars and circles, you must tell Cortex what color they should be. In the color column you may, if you wish, give a letter representing the color name you want. 'R', for example, stands for red. However, these default colors will probably not have the exact red, green, and blue values you want, so you should really list the actual rgb values you want in the file instead of just giving a color name. To give the actual rgb values, use 'X' as the color name in the color column, and then enter the appropriate values in the -R-, -G-, and -B- columns. These values range from 0 (off) to 255 (maximal brightness) for each red, green and blue gun on the CRT.
For items that are stored as bitmaps, the color you list in the items file is ignored. The colors are determined by the color lookup table, which is described in Section 7. The name of a color lookup table file can be entered in a menu within Cortex or listed in the conditions file (see below).
FILENAME. For bitmap and movie items, you must give the filename. The name can include a path, if it is not in the current directory. Note, however, that the length of the name, including the path cannot extend past the ends of the ------FILENAME------ column (i.e., 20 characters total).
The second ASCII file you must import into Cortex is the conditions file. Cortex can interleave trials from a large number of experimental conditions within a single experimental session. Each condition determines what happens on a particular type of trial. In this file, you specify which items are linked together within each condition, and which timing structure is associated with that condition.
An example of a conditions file is as follows:
COND# TEST0 TEST1 TEST2 TEST3 TEST4 TEST5 TEST6 TEST7 TEST8 TEST9 BCKGND TIMING TRIAL_TYPE FIX_ID ---COLOR-PALETTE---
1 2 2 1 2 0 -3 lookup.lut
2 3 6 7 5 4 1 1 0 -3
5
3 4 4 1 2 0 -3 lookup.lut
4 6 7 8 9 1 1 0 -3
5 10 9 3 5 1 1 0 -3
6 12 13 12 13 1 3 0 -3
7 13 12 13 12 1 3 0 -3
COND# The condition number is, as you might expect, the number of each experimental condition. Each line typically defines a condition, but if you need to list more than two items on a given test screen, you can list the additional items on the next line. In the above example, condition number 2 extends across two lines. Depending on the version of Cortex you are using, the maximum number of items per test screen is either 4, 8, or 16.
TEST0, TEST1, etc. For each test screen you list the items that you want to appear together. The item numbers refer to the items listed in the items file. On a single trial, you can have up to ten successive screens worth of images presented. The timing and sequence of the display screens is given in the state system. For example, the state file could be programmed so that in condition 2, TEST0 containing items 3, 6, and 5 will appear together first on the display screen. Then,TEST1 containing items 7 and 5 will appear together, followed by TEST2 containing item 4 alone. You can switch from one display screen to the next in one frame, i.e. 16.6 milliseconds when running at a 60 Hz refresh rate.
The order of the test screens and the order of the items within the test screens are important, if the timing file contains commands to display multiple test screens simultaneously. TEST0 will always be on top, followed by TEST1, then TEST2, etc. (That is, TEST0 will cover up everything below it.) Within the tests, the items are drawn in the order they are listed. That is, if TEST0 lists items 1,2,3,4 (in that order), they will be drawn in the same order (1,2,3,4). Item 1 will be on the bottom, and item 4 will be on the top.
BCKGND. For the background, you list an item that you would like to have as the background on each test screen. Only the color of the item, as specified in the RGB columns in the items file, will be used.
TIMING. In this column, you list which timing file (state system file), you want to run with this condition. The timing files are imported separately, and are referred to by their number.
TRIAL_TYPE. Currently not used, except as the expected_response field in the output data file header.
FIX_ID. In this column, you list which item you want for the fixation stimulus. This is typically item -3, the item number that Cortex uses internally to hold the fixation stimulus. However, you may list any item.
---COLOR-PALETTE---. The color lookup table for images and movies can either be entered from within one of Cortex's menus, or listed on a line in the conditions file. This should be the name of a disk file that holds the lookup table. Each condition can have its own lookup table. Lookup tables can also be loaded by number from the state system, for dynamic changes in color during a trial.
We have neglected the issue of timing -- when and for how long the stimuli remain on the screen. Each experimental condition is associated with a timing file. The same timing file may be used by all conditions or each condition may have its own. The timing file is discussed in the next section.
The timing file is responsible not only for informing Cortex when stimuli should go on and off, but also for any behavioral contingencies such as monitoring for a lever press, checking eye position, giving rewards, etc. The price for this flexibility is that the user must program every aspect of the flow of control, every contingency, every error state, etc.. If you know the C programming language, the state language of CORTEX will seem very familiar; the language is essentially a subset of C, with a few added features.
Each timing file is written as an ASCII file and saved with a file name. After you have written and stored your state systems as disk files, you then import one or more of the files into CORTEX, which sequentially assigns them each a number. These numbers are used as names for the timing structures. In the conditions file, you specify which timing structure is associated with each condition. For example, you may want to use two different timing structures in an experiment. Each will have its own ASCII file, with its own file name, and you will import (from within Cortex) the one timing file as timing structure #1 and the other as timing structure #2. In the conditions file, some conditions may list timing file #1 as the necessary timing structure and other conditions may list timing file #2.
For information on writing the timing file, please refer
to the separate document entitled, "Timing File Reference Manual".
4.5. Using the ITEMS, CONDITIONS, and TIMING files in a study
By modifying different ITEM, CONDITION, and TIMING files,
either alone or in combination, you can create many different experiments.
For example, once you have set up an experiment using a particular set
of ITEM, CONDITION, and TIMING files, you could change the stimuli alone
by importing a different ITEMS file into Cortex. Another way to achieve
the same end would be to import a single large ITEM file that held a large
number of stimuli to use, and then switch the items to use for a particular
experiment by importing a new CONDITIONS file. The new CONDITIONS file
will select new items from the ITEMS File. Alternatively, your primary
interest might be in different experimental paradigms rather than different
stimuli. In this case, you could keep the ITEMS and CONDITIONS files constant,
but import different timing files for different experiments.
4.5.1 Deciding on your Experimental Design
Cortex can interleave trials from a large number of experimental conditions within a single experimental session. Each condition determines what happens on a particular type of trial. For example, in one experimental condition, you may want just a red item presented, and in a different condition you may want just a green item presented. Therefore, you would set up two conditions, each with a single item on the TEST0 screen.
Why use two conditions rather than one in this example? Why not just present the red item on the TEST0 screen and the green item on the TEST1 screen of a single experimental condition? You could do this, but then the order of stimulus presentations would be the same throughout the experiment (i.e. red followed by green). If you want stimulus presentations randomly interleaved, you should assign stimuli to different experimental conditions because Cortex can only randomize the order of presentation of conditions, not the screens within a condition (actually, strictly speaking, ANYTHING can be done within the state system, including randomizing the order of presentation of screens within a condition, but this is tricky stuff). Another reason to use multiple conditions rather than a single condition with multiple screens is that there is a limit to how many screens can be presented sequentially within a single condition. You can only have 10 different screens of images (TEST0 through TEST9) within a single condition, but you can have any number of conditions.
O.K., you might ask, why do you ever need multiple image screens within a single condition? Why don't you just use one condition per screen image? One reason is that screens can be switched in 16 milliseconds (or less, depending on the refresh rate capabilities of the graphics card and monitor), whereas switching between conditions typically may require about a half a second because of various disk operations that must be performed. For some experiments, you may want to switch between certain stimuli rapidly, in which case you should put the stimuli on different screens within the same condition. Another reason is that you may want pairs or groups of stimuli always presented in the same order. Thus, on one condition you may want to have a red bar always followed by a green bar, and on a second condition you may want to have a blue bar followed by a yellow bar. Finally, if there are any behavioral contingencies linked to your conditions, at present these contingencies cannot easily span different conditions (except in some limited circumstances, described later). Consequently, if, for example, you expect a specific behavioral response to a red bar only when it has been preceded by a green bar, these two stimuli should be placed in the appropriate order within the same experimental condition. If you expect a different behavioral response to a red bar preceded by a red bar, you should place these stimuli in the appropriate order in a different condition. Items, incidentally, can be reused in many different conditions.
The concept of conditions is also related to how the data
are stored. Recall that data are stored by trial and condition, with the
data for each trial preceded by a header. Thus, one trial's worth of data
in the data file would contain the data for condition one, the next trial's
worth of data might contain the data for condition five (depending on the
order of presentation), etc.. Within each trial's worth of data, the onset
and offset of TEST0, TEST1, etc can be marked by using the encode() function
in your timing file. Suppose that a red bar item is presented only on the
TEST0 screen of condition 12. To locate the neuronal responses to the red
bar in the data file, you would find all the trial data for condition 12
(the condition number is given in the header for each trial), and then
find the time of occurrence of TEST0 in each of the trials for that condition.
The spikes that fall within TEST0 onset and TEST0 offset represent the
neuronal response to the bar on that trial.
4.6. Customizing Cortex with the Cortex.cfg configuration file
Within your current directory, you should also have a Cortex configuration file, which must be named 'Cortex.cfg'. This file contains information about the type and address of the hardware devices you are using as well as information about the size and location of graphic windows on the user's display (e.g. the histograms, rasters, eye position display, etc). The file is an ASCII file that can be edited both to conform to your current hardware configuration and to customize your display. An example configuration file should have been included with the distribution code.
The MONITOR_TYPE line of the Cortex.cfg file refers to the user's monitor. If this is not set correctly, your screen may go haywire when the program loads. For the Windows version of Cortex, the MONITOR_TYPE must be set to VC.
A second critical piece of information to check is the name and address of the analog/digital I/O board in your system. This is set on the DEVICE line of the Cortex.cfg file, but the device information also is important on the THREADS and MULTI_SPIKE lines.
A third critical piece of information includes the graphics resolution and the pixels/degree that are to be used for the subject's display. These values are set in the GRAPHICS_SPECS line of the Cortex.cfg file. Because you specify all locations to Cortex in terms of degrees of visual angle, Cortex needs to know how many pixels equal one degree. You can calculate this based on the size, resolution, and distance of your monitor from the subject. Cortex assumes that your monitor has the correct aspect ratio, so that pixels are square.
An example Cortex.cfg file can be found in Appendix C.
In this section, a brief overview of the Main Menu will
be given. In subsequent sections, each submenu will be further expanded
to include a description of each dialog box and parameter.
Figure 5.3
The Exit command is one of two ways to exit the program.
(It is the same as Run->Stop) This option will close all windows, and exit
the VCortex program. If you have made changes to any of the loaded components
(items, conditions, LUTs, etc.) via the Edit menu, these changes must be
explicitly saved with the File->Save menu. If the changes are not explicitly
saved, the changes will be lost upon File->Exit.
The timing file menu has the option to modify or delete a loaded timing file (see Figure 5.4). Modify allows you to load a different timing file in the place of an already loaded one. Delete removes a timing file that was already loaded with File->Load->TimingFile.
Figure 5.4
The External Variables option has a sub-menu consisting
of Generic Externs and Named Subsets. (See Figure 5.5) The Generic Externs
option is used to modify the char, int, float, and long external variables,
which have not been given names. The Named Subset option is used to edit
the external variables by name.
Figure 5.5
Figure 5.6
Figure 5.7
The Stop option is used to exit the program. It closes all the windows and exits. (It is the same as File->Exit.) The Resume option is used to re-start a trial in a block that was paused.
Figure 5.8
Figure 5.9
The Blocking option has a pop-up menu consisting of CONDstats, BLOCKstats, and Reset All. (See Figure 5.10) CONDstats clears all condition statistics. BLOCKstats clears all block statistics. Reset All resets all blocking variables that have been set for this trial.
The Clear->Histograms/Rasters option clears all histograms
and rasters. All spike information will be erased by selecting this option
the next time that the Run->Start option is chosen.
Figure 5.11
Figure 5.12
Figure 5.13
Figure 5.14
Figure 5.15
5.2.3 File-> Load ->Timing File
A standard file open dialog box will be presented. (See Figure 5.16) Select the timing file that you would like to load into your program. Unlike the items and conditions files, multiple timing files can be loaded into VCortex memory at the same time. As each timing file is successfully loaded, a message will appear to tell the user that the file was successfully loaded. The message will also provide the number in the Cortex State System (CSS) that it was assigned. This number is important since it is used in the TIMING column of the conditions file. It is also important since it is used to specify the timing file that is to be modified or deleted in the Edit->Timing File menu.
If the timing file was not successfully loaded, it means
that the Cortex compiler found errors in the timing file. A message box
will appear telling the user to check the cortexcc.err and VCortex.err
files for more details. These error files can be found in the directory
from which the timing file was loaded. Since these files are simple text
files, they can be displayed with Notepad, or other word processing programs.
Figure 5.16
Figure 5.17

Figure 5.19
Figure 5.20
Figure 5.21
Figure 5.22
Figure 5.23
Figure 5.24
Figure 5.26
Figure 5.27
Figure 5.28
Figure 5.29
A property sheet is displayed with tabs across the top for type, color, position and window size. The type page is complex because the value of the type combo box affects the display of that page. If you would like to change the item type, select the desired type from the drop-down list. Depending upon the item type, the other parameters on the page will change to match that item type. Note: The changes made to these items only change the copy in local memory and will not be saved to the item file unless you select File->Save->Item File.
Figure 5.30
Annulus (See Figure 5.31)
Figure 5.31
Ascii (See Figure 5.32)
Note: In the items file you may enter values for height and width. These variables are misleading because you are not able to change the size of the character. A standard font is used for all character items. These variables control the size of a square within which the character will appear.
Figure 5.32
Bitmap (See Figure 5.33)
Figure 5.33
Circle (See Figure 5.34)
Figure 5.34
Cross (See Figure 5.35)
Figure 5.35
Ellipse (See Figure 5.36)
Figure 5.36
Movie (See Figure 5.37)
Figure 5.37
Polygon (See Figure 5.38)
Figure 5.38
Rectangle (See Figure 5.39)
Figure 5.39
String (See Figure 5.40)
Figure 5.40
5.3.1.2 Item Color (See Figure 5.41)
Enter the red, green, blue (RGB) values for the item's color. (see Figure 5.41) These values must be from 0 to 255. You can also press the Choose Color button to view and set the colors.
Figure 5.41
In the color dialog box which appears when you use "Choose Color", you can click the mouse on a particular color and the RGB values of that color will be returned to the color property page. You can also choose Define Custom Color to choose colors that are not displayed in this dialog box. (See Figure 5.42)
Figure 5.42
5.3.1.3 Item Position (See Figure 5.43)
Item positions are used to determine where the center of the item will be located on the subject's display. The values are in degrees of visual angle (dva). Item positions assume that the center of the subject's display has the coordinate (0, 0).
X-Position: a positive value moves the item right, and a negative value moves the item left.
Y-Position: a positive value moves the item down, and a negative value moves the item up.
Figure 5.43
Window - As mentioned above, the Window Size can only be set if the Bitpan parameter has been set to Manual. If the Bitpan field is not set to Manual, the height and width boxes will be grayed out. When you give a window length and width (in degrees), and the object is bitpannable, Cortex will create a window around your item. This will allow you to pan a large object around inside a smaller window.
Figure 5.44

The background item number specifies the item to use in the background of the subject's display during the trial. Only the color of the item, as specified in the RGB columns in the items file, will be used
The time sequence number refers to which timing file (state system file), you want to run with this condition. The timing files are imported separately (with File->Load->Timing File), and are referred to by their number.
The fixspot item number is the number of the item that will appear as the fixation point for that condition.
If you want to use a color palette, specify a path and file name in the color palette filename entry field. You can also use the browse button to traverse the file structure for the file you want to use.
The possible choices for the trial type can be selected from the list box. This parameter is currently not used, except as the expected_response field in the output data file header.
Note: The changes you make to these conditions are only
changes to local memory and will not be saved to the condition file unless
you select File->Save->Condition File.
Figure 5.46
Figure 5.47
After the number of the timing file has been entered, a standard file open dialog box is displayed to allow you to specify the new timing file to load into that place. (See Figure 5.48)
Figure 5.48
Figure 5.49


Figure 5.50
5.3.6 Edit->External Variables->Named Subsets
Figure 5.51
If an external variables file has been loaded, a dialog box appears which displays a Name & Alias box that contains all the external variables that are loaded. (See Figure 5.52) By clicking on the down arrow of the listbox, you will be able to scroll through all the named external variables. Once you select the one to be edited, the appropriate entry box will be displayed to let you edit that external variable.
Figure 5.52
The contents of the box depend on the type of the variable. (See Figures 5.53 - 5.57)The types that you are able to edit within this box are int, char, float, long and pchar (string).
Figure 5.53
Figure 5.54
Figure 5.55
Figure 5.56
Figure 5.57
Figure 5.58
Figure 5.59
The LUT Edit dialog box which appears, allows you to change the RGB values for 256 LUT entries. (See Figure 5.60) The LUT Entry # will start at 0. The Red, Green, and Blue values correspond to that entry number. When you are finished editing that LUT entry, you can select Next>> to go to the next LUT entry. If you want to go to a particular LUT entry from this point, you can enter a specific LUT entry number in the LUT Entry # field, and press Update, to display the RGB values for that entry number. The entry number, red value, green value, and blue value must be between 0 and 255. When you are finished with all of the changes for that LUT file, press ‘Exit and Save all Changes’ to store all the new values to memory. If you do not want to save your changes press ‘Exit and Do NOT Save Changes’. Note: The changes you make to this LUT are only changes to local memory, and will not be saved to the LUT file unless you select File->Save->LUT.
Figure 5.60
After selecting ‘Exit and Save all Changes’, you will be reminded that these changes are only made to local memory. (See Figure 5.61)
Figure 5.61
5.4.1 Options->Block / Repeat->Sizing
Length of circular buffer for each block: The circular buffer contains one-character codes representing the result of each block. Since this is a circular buffer, if you do not make this buffer large enough, the contents could be overwritten. For example if you run 20 blocks and the size of this buffer is only 5, it will be overwritten 4 times. The contents of this buffer can be viewed in the status window during the trial beside the heading Bbuf.
Length of circular buffer for each condition: This buffer contains one-character codes representing the result of each trial. Since this is a circular buffer, if you do not make this buffer large enough, the contents could be overwritten. For example if you run 20 trials and the size of this buffer is only 5, it will be overwritten 4 times. The contents of this buffer can be viewed in the status window during the trial beside the heading Cbuf.
Figure 5.62
Maximum number of blocks: Specifies the maximum number of blocks that can be run.
First block number: the first individual block that will be run.
Last block number: the last individual block that will be run.
Block Order: Specifies the order in which the blocks should be run. The choices are as follows:
Random without replacement: Guarantees an even distribution of the number of blocks over the maximum blocks, but randomizes the order of presentation.
Random with replacement: The blocks will be run in completely random order.
At start: Cortex clears statistics when Run->Start is chosen, but not upon Run-> Resume.
When block changes: Cortex clears statistics when a block (correct OR error) has finished.
When repeat all blocks: Cortex clears statistics when
the repeat counter is incremented.
&nbs