# NormalizedCrossCorrelationMetric#

class kikuchipy.indexing.NormalizedCrossCorrelationMetric(n_experimental_patterns: = None, n_dictionary_patterns: = None, signal_mask: = None, dtype: = 'float32', rechunk: bool = False)[source]#

Similarity metric implementing the normalized cross-correlation, or Pearson Correlation Coefficient .

The metric is defined as

$r = \frac {\sum^n_{i=1}(x_i - \bar{x})(y_i - \bar{y})} { \sqrt{\sum ^n _{i=1}(x_i - \bar{x})^2} \sqrt{\sum ^n _{i=1}(y_i - \bar{y})^2} },$

where experimental patterns $$x$$ and simulated patterns $$y$$ are centered by subtracting out the mean of each pattern, and the sum of cross-products of the centered patterns is accumulated. The denominator adjusts the scales of the patterns to have equal units.

Equivalent results are obtained with dask.array.tensordot() with axes=([2, 3], [1, 2])) for 4D and 3D experimental and simulated data sets, respectively.

See SimilarityMetric for the description of the initialization parameters and the list of attributes.

Attributes

Methods

 Match all experimental patterns to all dictionary patterns and return their similarities. Prepare dictionary patterns before matching to experimental patterns in match(). Prepare experimental patterns before matching to dictionary patterns in match().