mgplx2ctx is a MATLAB program that converts Plexon .plx files to Cortex file format. This program is most useful when Cortex is used to control an experiment and passes event codes from a PIO port to the Plexon MAP. The .plx file is created by the on-line spike sorter client and can be read and written by Offline Sorter and by NEX. Files created by mgplx2ctx have the standard Cortex file format. This program is similar to plx2ctx, a stand-alone conversion program that uses the same configuration ("mapping") file. mgplx2ctx is distributed with the MatOFF data analysis package. Unlike MatOFF, mgplx2ctx will not work with older versions of MATLAB; it requires MATLAB R13 (v6.5) or later.
Differences between the .plx file structure and Cortex file structure dictate the use of a mapping file when running mgplx2ctx. Plexon files contain a continuous data stream with specialized data headers for each type of data encountered. The mgplx2ctx map file provides instruction for breaking this continuous stream in to Cortex files and trials, and supplies a correspondence between Plexon spike and analog channels with Cortex data channels.
An example mgplx2ctx mapping file is provided with this distribution. It is called mgplx2ctx.map.
A line beginning with a semicolon ";" is a comment in the mapping file.
Cortex files that are related to each other have the same file name and sequential file extension numbers (e.g., FILE.1, FILE.2, FILE.3, etc.). Within any one of these Cortex files, the data are divided into trials. Plexon files are continuous files that may include many trials and experimental conditions. Thus, a single Plexon file could be mapped to multiple Cortex files, and each of these Cortex files will generally have many trials. mgplx2ctx uses event codes to signal the start and end of Cortex files and Cortex trials. This scheme requires that experimenter has included these event codes in the data stream stored in the Plexon as file as "strobbed events".
To break a Plexon file into multiple Cortex files, specify PLEXONSTART and PLEXONSTOP values in the map file. PLEXONSTART specifies the event used to indicate the beginning of a new Cortex file. PLEXONSTOP specifies the event used to indicate the end of a Cortex file. Any data between a PLEXONSTOP event code and the following PLEXONSTART event code will be ignored. Either PLEXONSTART or PLEXONSTOP can be set to zero. If both are set to zero, mgplx2ctx will simply create a single Cortex file.
Example:
PLEXONSTART: 990
PLEXONSTOP: 991
In this example, any data before event code 990 will be ignored. Following the first 990, data will be placed into a Cortex file until event code 991 is encountered. After that, a new event code 990 will make mgplx2ctx open a new Cortex file (adding +1 to the file extension number) and repeat the process.
Cortex files must be broken into trials using the CORTEXSTART and CORTEXSTOP event codes. mgplx2ctx will start a new trial in the Cortex file whenever it encounters the CORTEXSTART event code. The trial is ended when a CORTEXSTOP event is reached. If you set CORTEXSTOP to zero, CORTEXSTART will both end the previous trial and start a new one.
Example:
CORTEXSTART: 19
CORTEXSTOP: 20
This mapping file entry tells mgplx2ctx to start a new Cortex trial each time event code 19 occurs and end the trial at event 20. Events between codes 19 and 20 will not be stored.
Plexon spike channels are hard-coded in terms of the electrode number (1 to 16, etc.) and the template number. Cortex treats each spike as an event code. The mgplx2ctx map file assigns an event code to each electrode and template:
; event code mapping for electrode #1
S 1,0: 0
S 1,1: 111
S 1,2: 112
S 1,3: 113
; event code mapping for electrode #2
S 2,0: 0
S 2,1: 114
S 2,2: 115
S 2,3: 116
In this example, the following assignments take place:
electrode #1
template 0 (unsorted spikes) is not mapped because it is assigned
an event code value of zero
templates 1 to 3 are mapped to event codes 111 to 113
electrode #2
template 0 (unsorted spikes) is not mapped because it is
assigned an event code value of zero
templates 1 to 3 are mapped to event codes 114 to 116
Plexon "slow analog" channels are mapped in a way similar to spike channels. Plexon channel numbering starts at channel 0. Only two Cortex channels are supported, channel #1 is the X eye data and channel #2 is the Y eye data.
A 0: 1
A 1: 2
In this example the Plexon channels 0 and 1 are mapped to Cortex X and Y eye data, respectively.

The window above is launched when you type mgplx2ctx on the MATLAB command line. You must specify an input file name and a mapping file name. To create an output file, enter the path to a directory for the output file path, and enter a root name (with not extension) for the Cortex file name. The extension of the Cortex file(s) created start with the number listed under "File" in the window. The default is .1.
Analog data can be included, excluded and decimated. Decimated means reducing the effective analog sampling rate by skipping every nth sample. Thus, a decimation value of 4 will convert a 2000 Hz data set in the Plexon file to a 500 Hz data set in the Cortex file. This is valuable because Cortex can only hold a maximum of 32,782 X-Y pairs in each trial. At 2000 Hz the analog buffer will overflow about 16.5 seconds into a trial. mgplx2ctx will safely truncate the analog data, but you will loose any information after the overflow. Some data analysis program will also complain if the amount of data in the buffer does not match the expected amount. Decimating data is one way to manage the conversion a data sampled at high rates.
The converter can do two processes, convert (using the Start button) and evaluate (using the Evaluate button). The evaluate button does somewhat less processing of the data file and does not produce an output. It is useful to see, for example, if an analog buffer overflow might occur. Informative messages are given in the MATLAB command window. After the process is complete, some of the same information is displayed in the lower window of the GUI. The Trial window shows which trials are being evaluated during the early phase of processing. Later in processing is shows the total number of trials found in the file.
The mgplx2ctx is a GUI that uses mplx2ctx for all the processing. It is possible to use mplx2ctx from the MATLAB command line or in another program with this calling format:
mplx2ctx(data_filename,mapping_filename,cortex_filename,options);
The only option for command line operation is options{1}='NOANALOG' or options{1}='ANALOG'. Example:
options{1}='ANALOG';
mplx2ctx('r021a.plx','rusty.map','R021A',options);
This example uses the mapping file rusty.map to convert Plexon file r021a.plx
to Cortex files R021A.1, R021A.2, etc.
Copyright 2006, NIMH Laboratory of Systems
Neuroscience
Last updated 30 March 2006