- class kikuchipy.indexing.SimilarityMetric(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)#
Abstract class implementing a similarity metric to match experimental and simulated EBSD patterns in a dictionary.
For use in
dictionary_indexing()or directly on pattern arrays if a
__call__()method is implemented. Note that dictionary_indexing() will always reshape the dictionary pattern array to 2D (1 navigation dimension, 1 signal dimension) before calling
Take a look at the implementation of
NormalizedCrossCorrelationMetricfor how to write a concrete custom metric.
When writing a custom similarity metric class, the methods listed as abstract below must be implemented. Any number of custom parameters can be passed. Also listed are the attributes available to the methods if set properly during initialization or after.
Number of experimental patterns. If not given, this is set to None and must be set later. Must be at least 1.
Number of dictionary patterns. If not given, this is set to None and must be set later. Must be at least 1.
A boolean mask equal to the experimental patterns’ detector shape
(n rows, n columns), where only pixels equal to
Falseare matched. If not given, all pixels are used.
Which data type to cast the patterns to before matching to.
Whether to allow rechunking of arrays before matching. Default is
Return the list of allowed array data types used during matching.
Return or set which data type to cast the patterns to before matching.
Return or set the number of dictionary patterns to match.
Return or set the number of experimental patterns to match.
Return or set whether to allow rechunking of arrays before matching.
Return the sign signifying whether a greater match is better, either +1 (greater is better) or -1 (lower is better).
Return or set the boolean mask equal to the experimental patterns' detector shape
(n rows, n columns).
Match all experimental patterns to all dictionary patterns and return their similarities.
Prepare dictionary patterns before matching to experimental patterns in
Prepare experimental patterns before matching to dictionary patterns in