avg2ddt sets the data type of outputfile, and conceptually changes the units of the data contained in the file, as follows:
if the input file is "average" (i.e., created with the avg(1) program), the output file is set to "ddt" and the output data values are first derivative of electric potential, in uV/s;
if the input file is "ddt" the output file is set to "ddt2" and the output data values are second derivative of electric potential, in uV/s/s;
if the input file is "csd" (i.e., created with the avg2csd(1) program), the output file is set to "csd-ddt" and the output data values are first derivative of current source density, in uA/m2/s (microamps per square meter per second);
if the input file is "csd-ddt", the output file is set to "csd-ddt2" and the output data values are second derivative of current source density, in uA/m2/s/s.
The data in outputfile can be plotted with ploterps(1) but almost certainly they will need smoothing or filtering to be viewable. Smoothing or filtering can be done as the data are being displayed using the -smooth or -filter options to ploterps(1) , or a separate file containing filtered data can be created from outputfile using the filter(1) program. See the EXAMPLES section for typical examples of filtering. Also, due to the increased scale of the output data, ploterps(1) will need the -cal and -scale options set appropriately when viewing the data. Typical values would be -cal 50 and -scale 100 for first derivative data and -cal 500 and -scale 1000 for second derivative data (note that ploterps(1) should set these parameters automatically when using the default configuration files, e.g. chan5, 26chan).
Data overflow must be considered when running avg2ddt. The derivative calculation increases the size of the data values, which can result in data overflow (i.e. values too large to fit their storage type). All overflow is detected and somewhat corrected by replacing the overflow value with the maximum valid value for the storage type (note this correction is merely the lesser of two evils - the maximum valid value is better than an invalid, potentially sign-changed, overflow value but it is still an incorrect value). Each overflow results in a warning message that indicates the bin number, channel number, and sample number associated with the overflow, as well as the magnitude of the overflow. A count of the number of overflows for each bin is also recorded in the bin headers of outputfile, so alternately the user can detect overflow by running headinfo(1) on outputfile. The user should inspect these messages (possibly plotting the associated data areas) to determine if the overflow is a problem. Some overflow may be acceptable, for example the overflow related to the steep edges of calibration pulses. Usually it is best to reduce or eliminate overflow errors by decreasing the resolution of the output data (see the -d option).
The data values are multiplied by the resolution (specifically, 1/10th of the pp10units value) to convert them to the values stored in outputfile, so a decrease in resolution results in a decrease in the size of the values being stored, which effectively reduces the chance of overflow.
If problematic overflow is occurring, check the resolution of the input file (using the headinfo(1) program for instance) and rerun avg2ddt with the -d option, specifying a resolution less than that of the input file. To avoid an unnecessary loss of information it is best to reduce the resolution only as much as needed; for example, if the input file has a resolution of 1000 points per 10 units, try specifying -d 900 and see how much the overflow is reduced; if it isn’t enough, try -d 800, etc.
The default is to set the output file to the same resolution as the input file.
avg2ddt /usr/local/erp/lib/testwaves.avg testwaves.ddt ploterps xwin 26chan -files /usr/local/erp/lib/testwaves.avg -bins 3 ploterps xwin 26chan -files testwaves.ddt -bins 3
To create a derivative of a grand average, and compare bin 7 of the average to its derivative:
avg2ddt conaud.gnd conaud.ddt ploterps xwin 26chan -files conaud.gnd -bins 7 ploterps xwin 26chan -files conaud.ddt -bins 7 -filter lp 5
To create a separate filtered file of the derivative, and view bin 7 of the derivative using the -nobaseline option to ploterps to maintain the intrinsic positivity and negativity:
filter lp conaud.ddt conaud.ddt.lp5 5 ploterps xwin 26chan -files conaud.ddt.lp5 -bins 7 -nobaseline
To create and view the first and second derivatives of bin 5 of a grand average, decreasing the resolution to reduce overflow errors:
avg2ddt clex.gnd clex.ddt -d 500 filter lp clex.ddt clex.ddt.lp5 5 avg2ddt clex.ddt.lp5 clex.ddt.lp5.ddt -d 100 ploterps xwin 26chan -files clex.gnd -bins 5 ploterps xwin 26chan -files clex.ddt.lp5 -bins 5 ploterps xwin 26chan -files clex.ddt.lp5.ddt -bins 5
To create and view the derivative of a current source density average:
avg2csd clex.gnd clex.csd filter lp clex.csd clex.csd.lp10 10 avg2ddt clex.csd.lp10 clex.csd.lp10.ddt -d 200 filter lp clex.csd.lp10.ddt clex.csd.lp10.ddt.lp5 5 ploterps xwin 26chan -files clex.gnd -bins 5 ploterps xwin 26chan -files clex.csd.lp10 -bins 5 ploterps xwin 26chan -files clex.csd.lp10.ddt.lp5 -bins 5
http://www.cut-the-knot.org/Curriculum/Calculus/CubicSpline.shtml for an interactive graph that helps in visualizing a waveform and its derivative.
Table of Contents