Reading nData into MATLAB

To read a binary nData (.nd) file into MATLAB, use the following .m file:

nd_read.m

Example usage:

    nd = nd_read('zz.nd');

This will create a MATLAB struct with the following organization:

  nd.class          - (string) Description of file class
  nd.nconst         - (int) Number of constant parameters
  nd.nvar           - (int) Number of variable parameters
  nd.ntable         - (int) Number of event code tables [not yet implemented]
  nd.ntrial         - (int) Number of trials

  nd.const(i).name  - (string) Name of ith constant parameter, i=1..nd.nconst
  nd.const(i).val   - (string) Value of ith constant parameter
  nd.const(i).type  - (char) Type of ith constant parameter, e.g., i, f, c for
                      int, float, char, respectively.

  nd.var(i).name    - (string) Name of ith variable parameter, i=1..nd.nvar
  nd.var(i).type    - (char) Type of ith variable parameter, e.g., i, f, c for
                      int, float, char, respectively.

  nd.tr(i).tcode    - (int) Trial code for ith trial i=1..nd.ntrial
  nd.tr(i).tref     - (int) Time reference for ith trial
  nd.tr(i).nparam   - (int) Number of variable parameter values for ith trial
  nd.tr(i).nrec     - (int) Number of records (i.e., channels) for ith trial

  nd.tr(i).par(j).name - (string) Name of jth param, j=1..nd.tr(i).nparam
  nd.tr(i).par(j).val  - (string) Value of jth param.
                         NOTE:  These are the values for the variable params
                         whose names and types are stored in nd.var()... above.

  nd.tr(i).r(j).rtype    - (int) Record type, 0-spikes, 1-float, 2-point value
  nd.tr(i).r(j).name     - (string) Record name, e.g., 'lgn_0_0_0', etc...
  nd.tr(i).r(j).rcode    - (int) Record code
  nd.tr(i).r(j).sampling - (float) Sampling rate, e.g., 1000.0 = msec
  nd.tr(i).r(j).t0       - (int) Time origin for recorded spikes, e.g., 0
  nd.tr(i).r(j).tn       - (int) Time duration for recording, e.g., 2048
  nd.tr(i).r(j).n        - (int) Number of spikes
  nd.tr(i).r(j).p(1..n)  - (int) spike times (for spike data)
  nd.tr(i).r(j).x(1..tn) - (int) float values (for continuous data)