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

Bases: SimilarityMetric

Similarity metric implementing the normalized cross-correlation, or Pearson Correlation Coefficient [Gonzalez and Woods, 2017].

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.




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().