pyxem / kikuchipy

Toolbox for analysis of electron backscatter diffraction (EBSD) patterns
https://kikuchipy.org
GNU General Public License v3.0
79 stars 30 forks source link

Add EBSD Hough indexing with a thin wrapper around PyEBSDIndex #590

Closed hakonanes closed 1 year ago

hakonanes commented 1 year ago

Description of the change

This PR adds convenience methods for Hough indexing by a very thin wrapper around PyEBSDIndex. The methods are added to simplify use of kikuchipy with PyEBSDIndex.

Caveats:

A CrystalMap is returned from the new method EBSD.hough_indexing(), which removes most of the inconvenience of getting a map from the array PyEBSDIndex' returns from its EBSDIndexer.index_pats() and similar functions. A function kikuchipy.indexing.xmap_from_hough_indexing_data() requring the array and an orix PhaseList can be used to convert the array to a crystal map when using PyEBSDIndex directly (not via hough_indexing()).

EBSD.hough_indexing() requires an pyebsdindex.ebsd_index.EBSDIndexer, which can be conveniently created using a new method EBSDDetector.get_indexer(phase_list), where phase_list is a PhaseList. This ensures that all detector parameters (sample tilt, camera elevation, pattern shape) and the phase list (either FCC, BCC or both, at the moment) are handled correctly.

Lastly, a EBSD.hough_indexing_optimize_pc() method is added to optimize projection centers (PCs). This wraps pyebsdindex.pcopt.optimize() or pyebsdindex.pcopt.optimize_pso(), depending on whether Nelder-Mead or particle swarm is chosen as optimization function. A EBSDDetector with optimized PCs is returned.

All tutorial notebooks using Hough indexing have been updated. They demonstrate nicely how to use the new functionality.

PyEBSDIndex is an optional dependency. It should be installed manually or via pip install kikuchipy[all]. all is a new dependency list installing all dependencies and optional dependencies (PyEBSDIndex, NLopt, PyVista). The viz dependency list (PyVista) is deprecated and will be removed in 0.9.


@Erlendos12, @htrellin and @olavlet: These changes might interest you for your https://github.com/htrellin/EBSD-GUI.


@drowenhorst-nrl: Hough indexing in kikuchipy is a very thin wrapper around PyEBSDIndex. This PR contains no duplication of functionality. I hope the new functionality in kikuchipy will increase the use of PyEBSDIndex and help identify any bugs going forward.

Progress of the PR

Minimal example of the bug fix or new feature

The indexing tutorials in the docs built from this PR demonstrates the new functionality nicely: https://kikuchipy--590.org.readthedocs.build/en/590/tutorials/index.html#indexing

For reviewers