Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron channeling pattern functionality #477

Open
2 tasks
hakonanes opened this issue Nov 30, 2021 · 8 comments
Open
2 tasks

Electron channeling pattern functionality #477

hakonanes opened this issue Nov 30, 2021 · 8 comments
Labels
enhancement New feature or request help wanted Would be nice if someone could help

Comments

@hakonanes
Copy link
Member

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

  • ECPDetector: similar to EBSDDetector, but should return an ECP pattern with the correct scale (real space)?
  • ECP class storing one or more ECP patterns?

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.

@hakonanes hakonanes added the enhancement New feature or request label Nov 30, 2021
@hakonanes hakonanes added the help wanted Would be nice if someone could help label Jan 17, 2022
@IMBalENce
Copy link
Contributor

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
Copy link
Member Author

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
Copy link
Contributor

IMBalENce commented Jul 14, 2022

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
Copy link
Member Author

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
Copy link
Contributor

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 #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
Copy link
Member Author

hakonanes commented Aug 3, 2022

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:

mp_upper, mp_lower = self._get_master_pattern_arrays_from_energy(energy)
# Remove data outside equator and combine into a 1D array
keep = mp_upper != 0
data = np.ravel(np.stack((mp_upper[keep], mp_lower[keep])))
# Get vectors for upper and lower hemispheres into a 1D array
size = mp_upper.shape[0]
x, y = np.meshgrid(np.linspace(-1, 1, size), np.linspace(-1, 1, size))
x = x[keep]
y = y[keep]
stereo2sphere = InverseStereographicProjection()
v1 = stereo2sphere.xy2vector(x.ravel(), y.ravel())
stereo2sphere.pole = 1
v2 = stereo2sphere.xy2vector(x.ravel(), y.ravel())
v3 = Vector3d.stack((v1, v2)).flatten()
grid = pv.StructuredGrid(v3.x, v3.y, v3.z)
grid.point_data["Intensity"] = data

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
Copy link
Contributor

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
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Would be nice if someone could help
Projects
None yet
Development

No branches or pull requests

2 participants