Check out the Hyperspy Workshop May 13-17, 2024 Online

get_unique_vectors#

DiffractionVectors2D.get_unique_vectors(distance_threshold=0.01, method='distance_comparison', min_samples=1, return_clusters=False, columns=(-2, -1))[source]#

Returns diffraction vectors considered unique by: strict comparison, distance comparison with a specified threshold, or by clustering using DBSCAN [1].

Parameters:
  • distance_threshold (float) – The minimum distance between diffraction vectors for them to be considered unique diffraction vectors. If distance_threshold==0, the unique vectors will be determined by strict comparison.

  • method (str) – The method to use to determine unique vectors. Valid methods are ‘strict’, ‘distance_comparison’ and ‘DBSCAN’. ‘strict’ returns all vectors that are strictly unique and corresponds to distance_threshold=0. ‘distance_comparison’ checks the distance between vectors to determine if some should belong to the same unique vector, and if so, the unique vector is iteratively updated to the average value. ‘DBSCAN’ relies on the DBSCAN [1] clustering algorithm, and uses the Eucledian distance metric.

  • min_samples (int, optional) – The minimum number of not strictly identical vectors within one cluster for the cluster to be considered a core sample, i.e. to not be considered noise. Only used for method=’DBSCAN’.

  • return_clusters (bool, optional) – If True (False is default), the DBSCAN clustering result is returned. Only used for method=’DBSCAN’.

References

[1] “https://scikit-learn.org/stable/modules/generated/sklearn.cluster.DBSCAN.html

Returns:

  • unique_peaks (DiffractionVectors) – The unique diffraction vectors.

  • clusters (DBSCAN) – The results from the clustering, given as class DBSCAN. Only returned if method=’DBSCAN’ and return_clusters=True.