Correlation Library  1.0
CScaledCorrelationBB Class Reference

A class that computes the scaled correlation for two vectors of time stamps (Binary - Binary). More...

#include <ScaledCorrelation-BB.h>

List of all members.

Public Member Functions

 CScaledCorrelationBB (int piScaleWindow, int piCorrelationWindow, int piTrialLength, int &piIsError)
 Constructor.
 ~CScaledCorrelationBB ()
 Destructor.
void ComputeScaledCorrelation (int *piaTimeStampsA, int piNrTimeStampsInA, int *piaTimeStampsB, int piNrTimeStampsInB, int pbUseFisherZTransform)
 Compute the scaled correlation of two vectors of time stamps.
void ComputeWindowedScaledCorrelationPerTrial (int *piaTimeStampsA, int piNrTimeStampsInA, int *piaTimeStampsB, int piNrTimeStampsInB, int piFromOffsetInTrial, int piToOffsetInTrial, int pbUseFisherZTransform)
 Compute the scaled correlation of two vectors of time stamps, on a partial window of the trial.
float * GetScaledCrossCorrelogram ()
 Returns the buffer with the computed scaled correlogram; returns NULL if there was an error; please check the buffer for NULL before using it!!
float * GetFiCoefficientSums ()
 Returns the sum of valid Fi coefficients of correlation for each bin of the correlogram.
int * GetFiCoefficientCounts ()
 Returns how many Fi coefficients of correlation have been averaged for each bin of the scaled cross correlogram.
int * GetDistributionOfCorrelationCoefficients (int &piNumberOfBins, float &pfBinSize)
 Returns the distribution of coefficients of correlation.
int ModifyScaleWindow (int piNewScale)
 Changes the scale segment size for the scaled correlation.
int ModifyCorrelationWindow (int piNewCorrelationWindow)
 Set the size of the correlation window; the parameter specifies the of the correlation window; for example for a window of -100..+100 pass 100 as a parameter.
int ModifyTrialLength (int piNewTrialLength)
 Set the length of the trial in original sampling units.
int ModifyAllParameters (int piNewScale, int piNewCorrelationWindow, int piNewTrialLength)
 Sets all parameters at once.
int GetScaleWindow ()
 Get the size of the current scale segment.
int GetCorrelationWindow ()
 Get the size of the correlation window.
int GetTrialLength ()
 Get the trial length in original sampling units.
int GetDistributionOfCorrelationCoefficientsBinNr ()
 Get the number of bins of the distribution of coefficients of correlation.
float GetDistributionOfCorrelationCoefficientsBinSize ()
 Get the size of a bin of the distribution of coefficients of correlation.

Detailed Description

A class that computes the scaled correlation for two vectors of time stamps (Binary - Binary).

For details on the Scaled Correlation algorithm see paper on "Scaled Correlation Analysis" by Danko Nikolic, Raul C. Muresan, Weijia Feng, and Wolf Singer.


Constructor & Destructor Documentation

CScaledCorrelationBB::CScaledCorrelationBB ( int  piScaleWindow,
int  piCorrelationWindow,
int  piTrialLength,
int &  piIsError 
)

Constructor.

Parameters:
piScaleWindow- The scale on which you compute the scaled correlation; use the same units as the sampling unit of your time stamps
piCorrelationWindow- The size of the cross correlation window (eg. 80 for a cross correlation with lags of -80..+80); use again the same units as the sampling of your time stamps
piTrialLength- The size of the trial in units of your time stamps
piIsError- A return parameter, set to 0 on success. It is set to -1 by the constructor if there is a mismatch of window sizes and the GetScaledCorrelogram() function will return NULL;

Member Function Documentation

void CScaledCorrelationBB::ComputeScaledCorrelation ( int *  piaTimeStampsA,
int  piNrTimeStampsInA,
int *  piaTimeStampsB,
int  piNrTimeStampsInB,
int  pbUseFisherZTransform 
)

Compute the scaled correlation of two vectors of time stamps.

Parameters:
piaTimeStampsA- The vector holding the time stamps of the first neuron
piNrTimeStampsInA- Number of time stamps in the first vector
piaTimeStampsB- The vector holding the time stamps of the second neuron
piNrTimeStampsInB- Number of time stamps in the second vector
pbUseFisherZTransform- Set to 1 to use the Fisher Z transform to average the coefficients of correlation; set to 0 for normal computation;
void CScaledCorrelationBB::ComputeWindowedScaledCorrelationPerTrial ( int *  piaTimeStampsA,
int  piNrTimeStampsInA,
int *  piaTimeStampsB,
int  piNrTimeStampsInB,
int  piFromOffsetInTrial,
int  piToOffsetInTrial,
int  pbUseFisherZTransform 
)

Compute the scaled correlation of two vectors of time stamps, on a partial window of the trial.

Compute the scaled correlation of two vectors of time stamps, on a partial window of the trial;

Warning:
ONLY ACCEPTS ONE TRIAL!!! so do not pass signals longer than the size of a single trial! Subsequent trials will be discarded.
Parameters:
piaTimeStampsA- The vector holding the time stamps of the first neuron
piNrTimeStampsInA- Number of time stamps in the first vector
piaTimeStampsB- The vector holding the time stamps of the second neuron
piNrTimeStampsInB- Number of time stamps in the second vector
piFromOffsetInTrial- The start offset in the trial where the desired window starts (time stamp)
piToOffsetInTrial- The end offset in the trial where the desired window stops (time stamp)
pbUseFisherZTransform- Set to 1 to use the Fisher Z transform to average the coefficients of correlation; set to 0 for normal computation;

Get the size of the correlation window.

Returns:
Returns the size of the correlation window
int * CScaledCorrelationBB::GetDistributionOfCorrelationCoefficients ( int &  piNumberOfBins,
float &  pfBinSize 
)

Returns the distribution of coefficients of correlation.

Returns:
A pointer to the internal buffer that holds the distribution of correlation coefficients
The number of bins in the distribution (piNumberOfBins); this is equal to the size of the buffer
The size of one bin of the distribution (pfBinSize); the size of the bin is in sampling units of the original signals

Get the number of bins of the distribution of coefficients of correlation.

Returns:
Returns the number of bins used to compute the distribution of correlation coefficients; the value equals the size of the internal buffer that stores the distribution of correlation coefficients (see also function: GetDistributionOfCorrelationCoefficients)

Get the size of a bin of the distribution of coefficients of correlation.

Returns:
Returns the size of the bins used to compute the distribution of correlation coefficients (see also function: GetDistributionOfCorrelationCoefficients)

Returns how many Fi coefficients of correlation have been averaged for each bin of the scaled cross correlogram.

Returns:
A pointer to the internal buffer containing the counts of "Fi" correlation coefficients averaged for each bin. The size of the buffer is (2*iCorrelationWindow+1), and the count of valid Fi coefficients, that were averaged to compute the scaled cross correlogram at lag 0, is at position iCorrelationWindow

Returns the sum of valid Fi coefficients of correlation for each bin of the correlogram.

The size of the buffer is (2*iCorrelationWindow+1), and the sum of coefficients for lag 0 is at position iCorrelationWindow. Use this function to get the sum of all valid coefficients that were used to compute the average correlation coefficient for each bin of the ScaledCrossCorrelogram: ScaledCrossCorrelogram[i] = FiCoefficientSums[i] / FiCoefficientCounts[i].

Returns:
A pointer to a buffer holding the sum of correlation coefficients for each bin (without dividing them to the counts; the scaled correlogram = the sum of coefficients / the count of coefficients).
Warning:
If no valid coefficient was found for a given bin, the buffer containes a value of NAN at that position. Please check for this in the code!

Returns the buffer with the computed scaled correlogram; returns NULL if there was an error; please check the buffer for NULL before using it!!

The size of the scaled correlogram buffer is (2*iCorrelationWindow+1), and element with lag 0 is at position iCorrelationWindow;

Returns:
Returns a pointer to the internal scaled correlation buffer. Do not write into the buffer!
The buffer has a NotANumber (NAN = -100000000.0) value for bins where correlation could not be defined because of lack of variance in the input vectors

Get the size of the current scale segment.

Returns:
Returns the size of the scale segment window

Get the trial length in original sampling units.

Returns:
Returns the length of the trial in original sampling units
int CScaledCorrelationBB::ModifyAllParameters ( int  piNewScale,
int  piNewCorrelationWindow,
int  piNewTrialLength 
)

Sets all parameters at once.

Parameters:
piNewScale- The new size of the scale segment
piNewCorrelationWindow- The new size of the correlation window
piNewTrialLength- The new length of the trial
Returns:
Returns 0 on success, -1 if the new scale window is too small; -2 if the new correlation window is too small; -3 if the new scale window is larger than the trial size; -4 if the trial length is smaller than the correlation window
int CScaledCorrelationBB::ModifyCorrelationWindow ( int  piNewCorrelationWindow)

Set the size of the correlation window; the parameter specifies the of the correlation window; for example for a window of -100..+100 pass 100 as a parameter.

Parameters:
piNewCorrelationWindow- The new size of the correlation window
Returns:
Returns 0 on success, -1 if the window is too small; -2 if the window is larger than the length of the trial
int CScaledCorrelationBB::ModifyScaleWindow ( int  piNewScale)

Changes the scale segment size for the scaled correlation.

Parameters:
piNewScale- The new size of the scale segment
Returns:
Returns 0 on success, -1 if the scale window is too small; -2 if the new scale window is larger than the trial size
int CScaledCorrelationBB::ModifyTrialLength ( int  piNewTrialLength)

Set the length of the trial in original sampling units.

Parameters:
piNewTrialLength- The new length of the trial
Returns:
Returns 0 on success and -1 if the trial length is smaller than the scale window; -2 if the trial length is smaller than the correlation window

The documentation for this class was generated from the following files: