pyxem / pyxem-demos

Examples and tutorials of multi-dimensional diffraction microscopy workflows using pyxem.
30 stars 38 forks source link

Add example notebook for fast template matching #75

Closed din14970 closed 3 years ago

din14970 commented 3 years ago

This notebook illustrates the "fast" template matching procedure on a small dataset. I guess the notebooks should not include the output of the cells, but this way it is easier to give some feedback. Once everyone is happy, I can close this PR, clean the notebook and make a new PR.

The relevant data for running the notebook can be downloaded from here: https://owncloud.gwdg.de/index.php/s/hp6h9SSWUPDQKDQ

To to very explicit, the notebook runs on the following commit hashes:

@pc494 and @hakonanes after you get a chance to look over the example, both your inputs on the API would be great. Currently it's all just functions, and whatever the user gets back are (dictionaries of) numpy arrays. No fluff and flexible but maybe not the most user friendly. A light object framework around it with orix objects returned with quick-plot functionality would perhaps be preferable. I don't think perfection is necessary at this stage though; after the NordTEM workshop I got quite a few requests about orientation mapping with Hyperspy/Python/Pyxem, so it would be great if we can point people to a working example.

@hakonanes your input would be great regarding the plotting of stereo triangles and IPF images. Ideally the merged notebook uses a clean orix based implementation instead of the hacky solution it currently uses. What is the status of these things in orix?

@ericpre I thought I would ping you also as you might be able to use this notebook for inspiration to run the analysis on your dataset

Full notebooks and scripts to generate the images in the paper I will share separately.

hakonanes commented 3 years ago

Great stuff! I've had a look at the notebook (not tried it myself), and have a few thoughts:

  1. As mentioned before, I'm working on "zoom" in the stereographic projection. I set up a PR to orix https://github.com/pyxem/orix/pull/213 to show the progress. This should be included in orix v0.7, and then this could be used to show the stereographic triangles in your notebook.
  2. Showing figures in a grid, like your stereographic triangles, should be as easy to set up as the fundamental zone plots in the orix clustering user guide, when the stereographic triangle functionality in 1. is done.
  3. The indexing results in your notebook fits nicely into a orix.crystal_map.CrystalMap.
  4. Regarding orientation coloring for orientation maps: I agree that we should implement this, and it doesn't have to be perfect. But I would like for us to support all point groups... So far, the orix PR mentioned above is the next step towards this, in my opinion. This way we can determine the closest vector to the vector in the centre of the triangle when projecting vectors to the "fundamental triangle". We can then start to color that triangle. By "don't think perfection is necessary", do you mean only supporting coloring the m-3m point group triangle? I might be open to that as a temporary measure, if we (1) set up the API exactly how it will be when we support all other point groups as well, and (2) provide the color key, i.e. coloring of the triangle. What do you think?

For anyone else: Niels' notebook via nbviewer.

pc494 commented 3 years ago

Thanks @hakonanes for the nbviewer.

There is a fair bit of tidying up to be done: for example I think you samples S2 rather than SO(2) for this method. However as far as the API goes I'm happy. I think it's probably best to get a tidy version produced and in and then incrementally replace relevant component with orix functionality.

din14970 commented 3 years ago

@pc494 @hakonanes I added slightly more explanations and fixed the SO(2)/S2 error. I didn't change any of the functionality; ideally the visualization details would indeed be abstracted away more using orix functionality, but since it will be a while before that properly works I think it can be left as is for now? I just leave a note in there that proper visualization tools are being worked on. I think a change to the CrystalMap object should happen once the AcceleratedIndexationGenerator becomes the default way to access the indexation functionality. Do you have any other comments/suggestions regarding tidying up?

din14970 commented 3 years ago

Also, for this example to work properly https://github.com/pyxem/diffsims/pull/172 and https://github.com/pyxem/pyxem/pull/743 will first need to be merged...

pc494 commented 3 years ago

I think this is another one in the "merge and then fix" category, merging.