pyxem / kikuchipy

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

Electron channeling pattern functionality #477

Open hakonanes opened 2 years ago

hakonanes commented 2 years ago

What functionality should we support in the new ECPMasterPattern class to be introduced in #476? What new tools do we need?

I haven't targeted these points for the v0.6 release, as I think it is important to get the TKD and ECP readers out so that people can start to use them. We can then include any functionality here in a v0.7 release.

IMBalENce commented 2 years ago

Sorry for taking so long to get back to you regarding the ECP tests. I have fetched your 'hakonanes/generalize-master-pattern-class' branch tested ECP master pattern loading and plotting.

In general, I can successfully load ECP masterpattern generated from EMsoft. I have also tried the temporary solution by setting mp.set_signal_type("EBSDMasterPattern"). This seems also reset the EBSDMasterPattern.phase, EBSDMasterPattern.projection, EBSDMasterPattern.hemisphere to None, and trigger the error from _is_suitable_for_projection check. After manually assigning the proper values, EBSDMasterPattern.get_patterns can work perfectly.

I will try to write up a draft for the ecp_detector from the existing ebsd_detector.

hakonanes commented 2 years ago

No problem, thank you for looking at this!

set_signal_type() is a HyperSpy BaseSignal method. In general, I think only data, axes_manager, metadata and original_metadata carry over with set_signal_type(), and none of our custom properties phase, projection and hemisphere. I've overwritten set_signal_type() for the master pattern classes so that these are carried over when converting from one master pattern class to another. If you pull the latest commits from my branch, you should not have to set the properties anymore. There's always a danger in overwriting methods, since we might have to update kikuchipy whenever a method we overwrite changes in HyperSpy. However, I think set_signal_type() is a well defined method which hopefully won't change much in the future.

IMBalENce commented 2 years ago

After some tinkering, I guess I'm starting to have some better understandings on kikuchipy now :)

Based on your existing ebsd code, I've added (more or less like copy and paste) ecp_detector, ecp class, and get_patterns function in the ecp_master_pattern class in my branch ecp-dev so far. Initial test on displaying simulated patterns seem to work ok. Of course, I still need to modify and add more docstrings; and purge the functions that are not applicable to ECP.

One thing I'm still trying to figure out is how ECP pattern is acquired in SEM and how to properly display them (Perhaps something equivalent to Lambert projection, but slightly different reference frame). Therefore, I guess the existing gnomonic projection model would not be suitable for displaying ECP pattern (probably close enough for displaying a small angular range). I was wondering if signals._kikuchi_master_pattern.KikuchiMasterPattern._get_master_pattern_arrays_from_energy is the main place I should look into?

Hopefully, our new microscope with ECP function will be up and running soon. We could test and validate the simulations very soon.

By the way, thank you for the latest 0.6.1 release. I really like the the new kinematic simulation. It works great on some of my latest works.

Edited: Just confirmed in Singh S, De Graef M. Dictionary Indexing of Electron Channeling Patterns. Microsc Microanal. 2017;23(1):1-10. doi:10.1017/S1431927616012769 ECP is display using azimuthal equal-area Lambert projection.

hakonanes commented 2 years ago

I'm glad you've looked more into this, since I don't do any ECP experiments myself and don't have time to work in this.

I still need to modify and add more docstrings; and purge the functions that are not applicable to ECP.

I think basing the ECPMasterPattern class on a parent private KikuchiMasterPattern class like will be introduced in #476 (relevant file) is the best approach. The methods and properties that make sense for both EBSD/TKD and ECP master patterns are implemented in this parent private class, while methods and properties that only make sense for EBSD/TKD or ECP are implemented in the child classes EBSDMasterPattern and ECPMasterPattern.

ECPMasterPattern.get_patterns() should be different to EBSDMasterPattern.get_patterns(), since the "ECP detector" is the BSE detector, most times an annular detector, which we can define with an inner and an outer radius, a working distance and a sample tilt. This is how it is done in EMsoft:

Hopefully, our new microscope with ECP function will be up and running soon. We could test and validate the simulations very soon.

I think the best way forward is for you to acquire some ECPs for us to then find the most intuitive way to project patterns onto a ECPDetector from a ECPMasterPattern. Good luck with the ECP experiments!

By the way, thank you for the latest 0.6.1 release. I really like the the new kinematic simulation. It works great on some of my latest works.

I'm glad you find them useful. If possible, could you elaborate on what you use them for?

IMBalENce commented 2 years ago

Yes, the current modification were all based on your branch generalize-master-pattern-class. The parent private KikuchiMasterPattern class has made all the changes so much easier.

I think basing the ECPMasterPattern class on a parent private KikuchiMasterPattern class like will be introduced in https://github.com/pyxem/kikuchipy/pull/476 (relevant file) is the best approach.

Thank you for pointing out the EMsoft solutions. Sure, I'll look into it and try to add those methods in to Kikuchipy for simulating ECP patterns.

This is how it is done in EMsoft:

I was using the simulation for visualizing the crystal planes for some researchers who are not familiar with pole figure but would like to find out the orientation relationship between crystals. I also find it very intriguing for simulation of a Kikuchi ball in 3D space. I made this Kikuchi ball augmented reality APP sometime ago, but never really get the pattern correctly displayed. Currently, it is only a simple albedo wrapped on a hemisphere with a lot of distortion. Perhaps, I'll try to something you did in the latest release.

I'm glad you find them useful. If possible, could you elaborate on what you use them for?

hakonanes commented 2 years ago

The parent private KikuchiMasterPattern class has made all the changes so much easier.

That's great. Your interest pushes me to finish this within early next week... Will let you know!

I was using the simulation for visualizing the crystal planes for some researchers who are not familiar with pole figure but would like to find out the orientation relationship between crystals.

Cool! I've recently separated the user guide into tutorials and examples: https://kikuchipy.org/en/latest/. I hope this makes it easier to add small snippets to the docs. Your demonstration sounds like something that isn't shown in the docs yet, do you think it might fit in the "Examples" section? The goal is for this section to show small recipies of common tasks... like visualizing crystal planes!

Currently, it is only a simple albedo wrapped on a hemisphere with a lot of distortion. Perhaps, I'll try to something you did in the latest release.

Very cool! The 3D master pattern plot is done by getting the unit vector (x, y, z) for each point (X, Y) in the stereographic projection, and then creating a pyvista.StructuredGrid:

https://github.com/pyxem/kikuchipy/blob/1ffaef9a5f485e1f1da2fda2a022b1f80d1f9e0e/kikuchipy/signals/ebsd_master_pattern.py#L436-L454

We now have a EBSDMasterPattern.as_lambert() method, perhaps we can add a EBSDMasterPattern.as_spherical() method, returning the StructuredGrid? You can then easily access the coordinates and associated intensities in your augmented reality app?

IMBalENce commented 2 years ago

Great! Thank you for the information. I'll try to refine the app again to correct the pattern display.

Very cool! The 3D master pattern plot is done by getting the unit vector (x, y, z) for each point (X, Y) in the stereographic projection, and then creating a pyvista.StructuredGrid:

I'm not 100% sure how it works yet. It was made in the Vuforia package which looks a bit more like a CAD software. I may need to find out how to parse the proper pattern geometry into the software

We now have a EBSDMasterPattern.as_lambert() method, perhaps we can add a EBSDMasterPattern.as_spherical() method, returning the StructuredGrid? You can then easily access the coordinates and associated intensities in your augmented reality app?

No problem. I'll try to add some of my notebooks. Perhaps you can confirm if it fits there or not.

Cool! I've recently separated the user guide into tutorials and examples: https://kikuchipy.org/en/latest/. I hope this makes it easier to add small snippets to the docs. Your demonstration sounds like something that isn't shown in the docs yet, do you think it might fit in the "Examples" section? The goal is for this section to show small recipies of common tasks... like visualizing crystal planes!

hakonanes commented 2 years ago

I may need to find out how to parse the proper pattern geometry into the software

OK, let me know if you think the StructuredGrid with coordinates and intensities can be useful.

I'll try to add some of my notebooks.

That would be great! It might be that snippets fit better as examples, so just adding the notebooks to GitHub in a repo (not kikuchipy) to show them might be the best option to start discussing the content.