Cross Correlation: Difference between revisions

From Software Product Documentation
Jump to navigation Jump to search
m (Text replacement - "www.c-motion.com/download" to "www.has-motion.com/download")
 
Line 47: Line 47:
A MAX_DELAY that is small will likely be inadequate to display the correlation of two signals. Selecting MAX_DELAY to have have the length of the two signals will cover all possible correlations.
A MAX_DELAY that is small will likely be inadequate to display the correlation of two signals. Selecting MAX_DELAY to have have the length of the two signals will cover all possible correlations.


To further review the shift between the two signals, an example script and power point can be downloaded [https://www.c-motion.com/download/examples/Cross_Correlation/2015_05_06.zip here].
To further review the shift between the two signals, an example script and power point can be downloaded [https://www.has-motion.com/download/examples/Cross_Correlation/2015_05_06.zip here].


==DATA_WRAP==
==DATA_WRAP==

Latest revision as of 11:20, 22 May 2024

Language:  English  • français • italiano • português • español 


The Cross_Correlation command can be used to determine if there is a relationship between two signals when one is shifted relative to the other.

More about calculating cross correlations can be found here and here.

Cross_Correlation

The Cross_Correlation command may be used to calculate the cross correlation between two signals.

Cross_Correlation
! /SIGNAL_OWNER1=
/SIGNAL_TYPE1=
/SIGNAL_FOLDER1=
/SIGNAL_NAME1=
! /SIGNAL_COMPONENT1=
! /SIGNAL_OWNER2=
/SIGNAL_TYPE2=
/SIGNAL_FOLDER2=
/SIGNAL_NAME2=
! /SIGNAL_COMPONENT2=
! /RESULT_OWNER=
! /RESULT_FOLDER= PROCESSED
/RESULT_NAME=
! /MAX_DELAY=10
! /DATA_WRAP=FALSE
;

Parameters

MAX_DELAY

The MAX_DELAY indicates the number of frames the signal will be shifted to determine the correlation.

The number of frames in the resulting signal = 2*MAX_DELAY +1

MAX_DELAY may also be considered as the "Window" of Frames to be compared across the signal.

A delay of 10 will result in 21 values (-10 to 10). A result at -10 will indicate that Signal ONE was shifted -10 frames relative to Signal TWO. A result at 10 will indicate that Signal ONE was shifted +10 frames relative to Signal TWO.

A MAX_DELAY that is small will likely be inadequate to display the correlation of two signals. Selecting MAX_DELAY to have have the length of the two signals will cover all possible correlations.

To further review the shift between the two signals, an example script and power point can be downloaded here.

DATA_WRAP

Data Wrapping indicates that the siganl is consider to loop.

With no Data Wrap and a MAX_DELAY of half the length of the signal, the first and last frames of the resulting signal will only be comparing half the signal.

With Data Wrap, all frames of the resulting signal will be a correlation resulting from comparing all frames of the two signals.


Example: Using the Cross Correlation Result

If you want just the frame offset with the highest correlation, you could use the sample script below:

Cross_Correlation
! /SIGNAL_OWNER1=
/SIGNAL_TYPE1=DERIVED
/SIGNAL_FOLDER1=COP_TEST
/SIGNAL_NAME1=LCOP_MAG_ORIGINAL_SIGNAL
/SIGNAL_COMPONENT1=X
! /SIGNAL_OWNER2=
/SIGNAL_TYPE2=ANALOG
/SIGNAL_FOLDER2=PROCESSED
/SIGNAL_NAME2=Force.Fz2
/SIGNAL_COMPONENT2=X
! /RESULT_OWNER=
! /RESULT_FOLDER=PROCESSED
/RESULT_NAME=CrossCorrResult
/MAX_DELAY=100
! /DATA_WRAP=FALSE
;

Evaluate_Expression
/EXPRESSION=SORT(DERIVED::PROCESSED::CrossCorrResult, -1, 2)
! /SIGNAL_TYPES=
! /SIGNAL_FOLDER=ORIGINAL
! /SIGNAL_NAMES=
 /RESULT_TYPES=DERIVED
 /RESULT_FOLDERS=PROCESSED
 /RESULT_NAME=CrossCorrResult_Sorted
! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
;

Metric_Explicit
! /RESULT_METRIC_FOLDER=PROCESSED
/RESULT_METRIC_NAME=CrossCorrResult
/METRIC_VALUE=DERIVED::PROCESSED::CrossCorrResult_Sorted[1,1]
;
Retrieved from ""