Cross correlation

objref correl
correl = new CrossCorrelation(yref, tref, ytest, ttest)

A GUI for viewing cross correlation between a reference and test vector function.

Two curves, ref(t) and test(t) are displayed on top graph.
Bottom graph shows
integral from tbegin to tend of
ref(t)*test(t+shift)*dt
where shift ranges from -maxshift to +maxshift.

This wraps the Vector.correl function
http://www.neuron.yale.edu/neuron/docs/help/neuron/general/classes/vector/vect2.html#correl
Since Vector.correl is implemented using the fast fourier transform
this tool interpolates the vectors in the domain tbegin to tend onto
a grid with number of points equal to a power of 2. To do this an
"actual dt" is selected which is near the "nominal dt" grid spacing and
satisfies (tend-tbegin)/"actual dt" = 2^n where n is an integer. The noninterpolated
ref and test functions are plotted as black lines and the interpolated versions
are plotted as red lines.

tend and tbegin may be selected by dragging the two blue vertical lines when
the "Select Boundaries" radiobutton is selected or one may enter
new values directly into the respective field editors.

The reference and test function vectors may be changed by first putting the
vector function into the vector clipboard and then selecting the respective
"* from Clipboard" buttons.

Since the fft implicitly assumes a periodic approximation to the functions, it is
helpful to verify that the apparent cross correlation is not
significantly  affected by the boundary conditions. "Periodic boundary
conditions mean that the functions should be thought of as a string
of sausages. "Zero Boundary Conditions" means that the sausages are doubled
in length and the extra size is padded by 0's.

The integral can be dominated by the product of the function mean values
and so a checkbox is provided to subtract the mean from each function
prior to calculating the cross correlation.

Two examples are created by the mosinit.hoc file.

CrossCorrelation[1] shows the autocorrelation of a pulse function
of amplitude 2 and width 1. Thus with a shift of 0, the integral is 4
(when "Use mean = 0" is off). As the test function is shifted to the
right or left, the correlation linearly decreases. When the functions
no longer overlap (shift > 1 or < -1) the correlation is 0.

CrossCorrelation[0] shows the cross correlation between a spike train test
function with high amplituded spikes and an identical frequency spike train
reference function with smaller double spikes. Notice that the cross
correlation is maximum when the test function is shifted right by about
,5 ms so that the test spikes overlap the second of the double spike pairs.
There is another cross correlation peak at -4.3 ms indicating that the
test spikes shifted left overlap the first of the double spike pairs.

Questions about this tool should be directed to
michael.hines@yale.edu 
