Converting your data to ndata

It is usually simple to convert spike-time data to the ndata format. There are two text file formats, T1 and T2, that can be directly converted to ndata. Below are examples of converting single-unit and multiple single-unit data to ndata. If you have a more complicated data format that you would like to convert to ndata, please contact Wyeth Bair.

T1 text file format

Single-unit data that is written in the simple text format known as T1 (shown below) can be converted to ndata with the following command:
  ndutil t12nd [input_T1_file] [output_ndata_file]
after replacing values in [ ]'s with appropriate file names. In the ndata file that is created, the channel name will be unit0.

Example T1 data file:

Name cell_018
Start 0
Duration 2000
Sampling 1000.0
Params contrast orientation speed
Trials 5
T 1 1.00 45 fast
R 12 10 24 88 99 225 348 1052 1067 1221 1288 1304 1515
T 2 0.50 180 medium
R 9 62 69 74 101 193 404 516 1002 1861
T 3 0.00 90 slow
R 0
T 4 1.00 180 medium
R 6 17 102 252 279 1535 1923
T 5 0.50 270 fast
R 11 24 32 65 139 320 598 601 1431 1636 1777 1923

The file begins with a list of identifiers (in green) and values (in red). The identifier, Name specifies a character string that identifies the data file. The identifiers Start and Duration define the time period during which data was recorded. The unit of time is defined by Sampling, which specifies the number of samples per second. Thus, a sampling value of 1000.0 indicates milliseconds. The identifier, Params is followed by a list of parameter names whose values vary and thus are specified for each trial. The identifier, Trials is followed by the number of trials of data in the file.

The rest of the file consists of data organized in trials. Each trial begins with T followed by the trial number, which can run in order from 1 up to the total number of trials in the file. The next items on the line (in white) specify the values for each parameter named above by Params. Values must be separated by spaces or tabs, and a newline (i.e., an end-of-line character) must terminate the line. The next line in the trial begins with R (for record) and specifies the number of data points in the record (in red) and the times of action potentials (in yellow) in units specified by Sampling. If no spikes were recorded on a given trial, the record line is simply "R 0", as in trial 3 above. There should be no action potential values that fall outside of the time period specified by Start and Duration. In this example, the integers from 0 to 1999, inclusive, are the only acceptable values for spike times. Spike time values should be separated by spaces (or tabs) and the last spike time (on each trial) must be followed by a newline.

Converting multiple single-unit data to ndata

To convert multiple single-unit data to ndata, simply use the T1 format shown above and repeat the record lines (those beginning with R) for the appropriate number of single units (see below for dual single units). In the ndata file that is created, the channel names will be unit0, unit1, etc. It is necessary that every trial has the same number of record lines, even if there are zero spikes for some records.

Use the following command to convert the T1 file to ndata:

  nda_util t12nd [input_T1_file] [output_ndata_file]
after replacing values in [ ]'s with appropriate file names.


  . . .

T 1 1.00 45 fast
R 12 10 24 88 99 225 348 1052 1067 1221 1288 1304 1515
R 5 234 352 784 1000 1410
T 2 0.50 180 medium
R 9 62 69 74 101 193 404 516 1002 1861
R 2 573 781
T 3
  . . .



T2: Converting data with event codes to ndata

If the neural data includes a set of event codes, these can be encoded using the T2 format (shown below) and converted to ndata using the command:
  ndutil t22nd [input_T2_file] [output_ndata_file]

Name cell_018
Start 0
Duration 2000
Sampling 1000.0
BeginConst
  sf 1.0
  tf 20
  ...
EndConst
BeginTable
  1 FixationOnset
  2 StimulusOnset
  30 FixationBreak
  40 ResponseCorrect
  41 ResponseIncorrect
  100 Reward
  ...
EndTable
Params contrast orientation speed
Trials 5
T 1 0 1.00 45 fast
R0 12 10 24 88 99 225 348 1052 1067 1221 1288 1304 1515
R3 3 1 134 2 257 30 1040
T 2 2583 0.50 180 medium
R0 9 62 69 74 101 193 404 516 1002 1861
R3 4 1 154 2 271 40 1508 100 1808
T 3 5308 0.00 90 slow
  ...
In this format, the event codes are listed as pairs of numbers and descriptive strings within BeginTable and EndTable labels. These codes can then be referenced in records indicated by R3 (record type 3). To differentiate the record types, spike time records must be indicated using R0.

Other features of the T2 format include the following. A time reference is given by the integers (in blue) following the trial index number (in green) and before the variable parameter values (in white). This time reference indicates when each recording began relative to the start of the first trial, which can be set to zero. A set of constant paramters that describe featuers of the data file that do not vary across trials can also be included in the header. In the example above, two parameter names and values are shown. Parameters do not need to be on separate lines.