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

Refactor orientation mapping3 #1

Merged
merged 76 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
9bccc5e
Update: Update versions
CSSFrancis May 9, 2024
05b21b4
Merge pull request #1075 from CSSFrancis/post-release
CSSFrancis May 24, 2024
5cbcc22
Fixed indexing error
sivborg May 27, 2024
35c2d32
Updated changelog
sivborg May 28, 2024
a0e857c
Testing: Add Test for mask+center_of_mass
CSSFrancis May 29, 2024
8c1fcb1
Merge pull request #1080 from sivborg/direct_beam_com_fix
CSSFrancis May 29, 2024
c9ccddd
BugFix: Fix "Broken" link
CSSFrancis May 29, 2024
25b6f68
Merge pull request #1083 from CSSFrancis/fix_link_check
CSSFrancis May 29, 2024
011e4d2
New Feature: Add Template Matching with dilated windowed template
CSSFrancis Mar 29, 2024
3dad15d
Documentation: Add example and docstrings
CSSFrancis Mar 29, 2024
5240c54
BugFix: Update how volume is computed.
CSSFrancis Apr 10, 2024
f0e3259
BugFix: Update how volume is computed.
CSSFrancis Apr 10, 2024
d39ae2a
BugFix: Fix normalization bug
CSSFrancis Apr 19, 2024
0ec6839
BugFix: Float 64 dtype
CSSFrancis Apr 20, 2024
4495a3f
Refactor: Move match_template_dilate
CSSFrancis May 28, 2024
d4d1518
BugFix: Fix labeled vectors to markers.
CSSFrancis May 28, 2024
6667df6
BugFix: Fix Template Matching with circular window.
CSSFrancis May 29, 2024
6e357a5
Documentation: Add to CHANGELOG.rst
CSSFrancis May 29, 2024
b67045e
Addition: Add Extra files for tutorials.
CSSFrancis May 26, 2024
03cb678
New Feature: Add new datasets to data repo from zenodo.
CSSFrancis May 28, 2024
8172575
Documentation: Add to CHANGELOG.rst
CSSFrancis May 28, 2024
9f01033
Testing: Add testing for circular Background
CSSFrancis May 31, 2024
1a25638
Refactor: Changes per @hakonanes
CSSFrancis May 31, 2024
cc864bb
Merge pull request #1084 from CSSFrancis/adjust_template_matching
CSSFrancis Jun 1, 2024
f81f487
Merge pull request #1081 from CSSFrancis/updated_data
CSSFrancis Jun 4, 2024
c826c02
Documentation: Add additional information about averaging neighboring…
CSSFrancis May 29, 2024
8124180
Documentation: Add Hough Transform example.
CSSFrancis May 29, 2024
7576cc8
Documentation: Add CHANGELOG.rst
CSSFrancis May 29, 2024
f5d7bca
Refactor: Clean up Examples
CSSFrancis May 29, 2024
62ab7c9
Refactor: Remove Long Running Examples
CSSFrancis May 29, 2024
dd05e44
Documentation: Fix Formatting
CSSFrancis May 29, 2024
388afb0
Merge pull request #1082 from CSSFrancis/Update-documentation
CSSFrancis Jun 6, 2024
a7cedeb
Refactor: Moved orientation mapping to polar_diffraction2d.py
CSSFrancis Feb 8, 2024
dc77b79
New Feature: Added OrientationMap class
CSSFrancis Feb 14, 2024
ad9eb9b
Refactor: Clean up `OrientationMap` class
CSSFrancis Feb 14, 2024
d6dc3a0
Bugfix: Fix `OrientationMap` error
CSSFrancis Feb 14, 2024
7f4afc9
Bugfix: transpose polar image to match
CSSFrancis Feb 14, 2024
9ad2e38
Testing: Add tests for orientation mapping
CSSFrancis Feb 17, 2024
bf23e68
Refactor: Avoid testing for signal size
CSSFrancis Feb 26, 2024
15260f8
BugFix: Fix regression with rebase
CSSFrancis May 7, 2024
22d7fb3
BugFix: Remove test
CSSFrancis May 7, 2024
178a815
New Feature: Added OrientationMap class
CSSFrancis Feb 14, 2024
44b0faa
Implement `to_markers`
viljarjf Apr 20, 2024
adb33a1
Type hints and colors
viljarjf Apr 20, 2024
7e538f7
Implement to_navigator and to_single_phase_orientations
viljarjf Apr 20, 2024
b2031ca
Change units of in-plane angle to degrees
viljarjf Apr 20, 2024
5e21eb2
Refactor to_marker
viljarjf Apr 20, 2024
3690c09
BugFix: Fix regression from rebase
CSSFrancis May 7, 2024
2edfc3a
Documentation: Add example
CSSFrancis May 7, 2024
dc7772b
Documentation: Clean up Example for on_zone_orientation.py
CSSFrancis May 8, 2024
00d4633
Documentation: Add examples for simulating multiple phases.
CSSFrancis May 8, 2024
d7483f6
Update: Update diffsims version
CSSFrancis May 9, 2024
691ed5b
Update: Update tests for grain orientation.
CSSFrancis May 9, 2024
5a82d19
Add low-index simulations
viljarjf May 10, 2024
cb4aba4
Translate angle index to degrees
viljarjf May 10, 2024
438c2ed
Update test to use `si_phase_simple`
viljarjf May 10, 2024
9f8e686
Testing: Remove unused tests
CSSFrancis May 13, 2024
0c735a0
Plotting: Add plotting for diffracting intensity
CSSFrancis May 14, 2024
82c0e01
Plotting: Add plotting of ipf
CSSFrancis May 14, 2024
7349133
Refactor:Add kwargs
CSSFrancis May 24, 2024
fabe79f
New Feature: Add to `CrystalMap`
CSSFrancis May 27, 2024
de23d14
New Feature: Add to `CrystalMap`
CSSFrancis May 27, 2024
3a245d1
Refactor: Refactor indexation_results.py
CSSFrancis May 27, 2024
994eba8
Testing: Test `to_crystal_map` function
CSSFrancis May 27, 2024
9e6afda
Testing: Test `to_crystal_map` function for multiple phases
CSSFrancis May 27, 2024
2d03b93
Try to ensure correct conventions is followed
viljarjf May 27, 2024
20bbfe5
Rebase: Follow up for Rebase
CSSFrancis May 29, 2024
eb86caa
Refactor: Fix Tests
CSSFrancis May 29, 2024
5642625
BugFix: Fix Examples
CSSFrancis May 29, 2024
050c332
Version: diffsims == 0.6.rc1
CSSFrancis May 29, 2024
2d67890
Visualization: Add marker for IPF visualization
CSSFrancis May 31, 2024
772dafa
Testing: Added new tests to cover new class and fixed up documentation.
CSSFrancis May 31, 2024
c479e07
Testing: Update Oldest
CSSFrancis May 31, 2024
80f5428
Refactor: rename simulated_fe.py
CSSFrancis May 31, 2024
2cf1c95
Testing: ++ min matplotlib version
CSSFrancis May 31, 2024
2d93837
Refactor: References
CSSFrancis May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- os: ubuntu-latest
python-version: 3.8

DEPENDENCIES: diffsims==0.5.0 hyperspy~=2.0.rc0 lmfit==0.9.12 matplotlib==3.6 orix==0.9.0 scikit-image==0.19.0 scikit-learn==1.0.0
DEPENDENCIES: diffsims==0.6.rc1 hyperspy~=2.0.rc0 lmfit==0.9.12 matplotlib==3.7.5 orix==0.12.1 scikit-image==0.19.0 scikit-learn==1.0.0
LABEL: -oldest
steps:
- uses: actions/checkout@v3
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.

Unreleased
==========
Fixed
-----
- Fixed indexing error in :meth:`~pyxem.signals.Diffraction2D.get_direct_beam_position` (#1080)

Added
-----
- Added Examples for doing a Circular Hough Transform and Increased Documentation for Filtering Data (#1082)
Added
-----
- Added `circular_background` to :meth:`~pyxem.signals.Diffraction2D.template_match_disk` to account for
an amorphous circular background when template matching (#1084)

- Added new datasets of in situ crystalization, Ag SPED,
Organic Semiconductor Orientation mapping, Orientation Mapping, and DPC (#1081)


2024-05-08 - version 0.18.0
==========
Expand Down
6 changes: 5 additions & 1 deletion doc/_static/switcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
},
{
"name": "stable",
"version": "0.17.0",
"version": "0.18.0",
"url": "https://pyxem.readthedocs.io/en/stable/"
},
{
"version": "0.17.0",
"url": "https://pyxem.readthedocs.io/en/v0.17.0/"
},
{
"version": "0.16.0",
"url": "https://pyxem.readthedocs.io/en/v0.16.0/"
Expand Down
11 changes: 10 additions & 1 deletion doc/bibliography.bib
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ @article{Pekin:17
keywords = { Strain measurement,Nanobeam electron diffraction},
pages = {170--176},
title = {{Optimizing disk registration algorithms for nanobeam electron diffraction strain mapping}},
url = {https://www.sciencedirect.com/science/article/pii/S0304399116304065},
url = {https://doi.org/10.1016/j.ultramic.2016.12.021},
volume = {176},
year = {2017}
}
Expand Down Expand Up @@ -90,4 +90,13 @@ @article{Viladot:13
volume = {252},
journal = {Journal of microscopy},
doi = {10.1111/jmi.12065}
}
@article{pyxemorientationmapping2022,
title={Free, flexible and fast: Orientation mapping using the multi-core and GPU-accelerated template matching capabilities in the python-based open source 4D-STEM analysis toolbox Pyxem},
author={Cautaerts, Niels and Crout, Phillip and {\AA}nes, H{\aa}kon Wiik and Prestat, Eric and Jeong, Jiwon and Dehm, Gerhard and Liebscher, Christian H},
journal={Ultramicroscopy},
pages={113517},
year={2022},
publisher={Elsevier},
doi={10.1016/j.ultramic.2022.113517}
}
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"http://dx.doi.org/10.1088/0965-0393/23/8/083501", # 403 Client Error: Forbidden for url
"https://doi.org/10.1111/jmi.12065", # 403 Client Error: Forbidden for url
"https://doi.org/10.1111/j.0022-2720.2004.01293.x", # 403 Client Error: Forbidden for url
"https://doi.org/10.1016/j.ultramic.2016.12.021",
]


Expand Down
3 changes: 3 additions & 0 deletions examples/orientation_mapping/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Orientation Mapping
===================
Below is a gallery of examples on how to do orientation mapping in pyxem.
65 changes: 65 additions & 0 deletions examples/orientation_mapping/mulit_phase_orientation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""
Multi Phase Orientation Mapping
===============================
You can also calculate the orientation of the grains for multiple phases using the
:meth:`pyxem.signals.PolarSignal2D.get_orientation` method. This requires that you
simulate the entire S2 space for the phase and then compare to the simulated diffraction.

For more information on the orientation mapping process see :cite:`pyxemorientationmapping2022`
"""

import pyxem as pxm
from pyxem.data import fe_multi_phase_grains, fe_bcc_phase, fe_fcc_phase
from diffsims.generators.simulation_generator import SimulationGenerator
from orix.quaternion import Rotation
from orix.sampling import get_sample_reduced_fundamental

mulit_phase = fe_multi_phase_grains()

# %%
# First we center the diffraction patterns and get a polar signal
# Increasing the number of npt_azim with give better polar sampling
# but will take longer to compute the orientation map
# The mean=True argument will return the mean pixel value in each bin rather than the sum
# this makes the high k values more visible

mulit_phase.calibration.center = None
polar_multi = mulit_phase.get_azimuthal_integral2d(
npt=100, npt_azim=360, inplace=False, mean=True
)
polar_multi.plot()

# %%
# Now we can get make a simulation. In this case we want to set a minimum_intensity which removes the low intensity reflections.
# we also sample the S2 space using the :func`orix.sampling.get_sample_reduced_fundamental`
# We have two phases here so we can make a simulation object with both of the phases.

bcc = fe_bcc_phase()
fcc = fe_fcc_phase()
bcc.name = "BCC Phase"
fcc.name = "FCC Phase"
fcc.color = "red"
bcc.color = "blue"

generator = SimulationGenerator(200, minimum_intensity=0.05)
rotations_bcc = get_sample_reduced_fundamental(
resolution=1, point_group=bcc.point_group
)
rotations_fcc = get_sample_reduced_fundamental(
resolution=1, point_group=fcc.point_group
)

sim = generator.calculate_diffraction2d(
[bcc, fcc],
rotation=[rotations_bcc, rotations_fcc],
max_excitation_error=0.1,
reciprocal_radius=2,
with_direct_beam=False,
)
orientation_map = polar_multi.get_orientation(sim)


cmap = orientation_map.to_crystal_map()
cmap.plot()
# %%
# sphinx_gallery_thumbnail_number = 3
62 changes: 62 additions & 0 deletions examples/orientation_mapping/on_zone_orientation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
On Zone Orientation
===================
Sometimes you have a tilt boundary and you might want to know the orientation of the
grains on each side of the boundary. This can be done using the
:meth:`pyxem.signals.PolarSignal2D.get_orientation` method.

For more information on the orientation mapping process see :cite:`pyxemorientationmapping2022`
"""

from pyxem.data import si_tilt, si_phase
from diffsims.generators.simulation_generator import SimulationGenerator
from orix.quaternion import Rotation
from orix.vector import Vector3d

simulated_si_tilt = si_tilt()

# %%
# Pre-Processing
# --------------
# First we center the diffraction patterns and get a polar signal
# Increasing the number of npt_azim with give better polar sampling
# but will take longer to compute the orientation map
# The mean=True argument will return the mean pixel value in each bin rather than the sum
# this makes the high k values more visible

simulated_si_tilt.calibration.center = None
polar_si_tilt = simulated_si_tilt.get_azimuthal_integral2d(
npt=100, npt_azim=360, inplace=False, mean=True
)
polar_si_tilt.plot()

# %%

# Building a Simulation
# ---------------------
# Now we can get make the orientation map. In this case we have aligned the tilt axis with the z-axis
# so we can use the :func:`orix.vector.Vector3d.from_euler` method to get the rotation axis.
# As always ``with_direct_beam=False`` is important to make sure that the center
# beam does not affect the orientation mapping.


phase = si_phase()
generator = SimulationGenerator(200)
sim = generator.calculate_diffraction2d(
phase,
rotation=Rotation.from_euler(
[[0, 0, 0], [0, 0, 0]],
degrees=True,
),
max_excitation_error=0.1,
reciprocal_radius=1.5,
with_direct_beam=False,
)
# Getting the Orientation
# -----------------------
# This should be fairly good at finding the orientation of the grains on each side of the tilt boundary.
# The rotation is stored in the rotation column of the orientation map or .isg[2,0] if you want to use the
# rotation as a navigator or plot it directly.

orientation_map = polar_si_tilt.get_orientation(sim)
orientation_map.plot_over_signal(simulated_si_tilt)
63 changes: 63 additions & 0 deletions examples/orientation_mapping/single_phase_orientation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""
Single Phase Orientation Mapping
================================
You can also calculate the orientation of the grains in a single phase sample using the
:meth:`pyxem.signals.PolarSignal2D.get_orientation` method. This requires that you
simulate the entire S2 space for the phase and then compare to the simulated diffraction.

For more information on the orientation mapping process see :cite:`pyxemorientationmapping2022`
"""

from pyxem.data import si_phase, si_grains
from diffsims.generators.simulation_generator import SimulationGenerator
from orix.sampling import get_sample_reduced_fundamental

simulated_si = si_grains()

# %%
# Pre-Processing
# --------------
# First we center the diffraction patterns and get a polar signal
# Increasing the number of npt_azim with give better polar sampling
# but will take longer to compute the orientation map
# The mean=True argument will return the mean pixel value in each bin rather than the sum
# this makes the high k values more visible

simulated_si.calibration.center = None
polar_si = simulated_si.get_azimuthal_integral2d(
npt=100, npt_azim=360, inplace=False, mean=True
)
polar_si.plot()

# %%
# Building a Simulation
# ---------------------
# Now we can get make a simulation. In this case we want to set a minimum_intensity which removes the low intensity reflections.
# we also sample the S2 space using the :func`orix.sampling.get_sample_reduced_fundamental`. Make sure that you set
# ``with_direct_beam=False`` or the orientation mapping will be unduely affected by the center beam.
phase = si_phase()
generator = SimulationGenerator(200, minimum_intensity=0.05)
rotations = get_sample_reduced_fundamental(resolution=1, point_group=phase.point_group)
sim = generator.calculate_diffraction2d(
phase,
rotation=rotations,
max_excitation_error=0.1,
reciprocal_radius=2,
with_direct_beam=False,
) # Make sure that with_direct_beam ==False

# %%
# Getting the Orientation
# -----------------------
# By default the `get_orientation` function uses a gamma correction equilivent to polar_si**0.5. For noisy datasets
# it might be a good idea to reduce the noise (Maybe by averaging neighboring patterns?) or simple background subtraction,
# otherwise the gamma correction will increase the effects of noise on the data. This tries to focus on "Is the Bragg vector
# there?" rather than "Is the Bragg vector the right intensity?" patially because the intensity of the Bragg vector might have
# many different effects.


orientation_map = polar_si.get_orientation(sim)
orientation_map.plot_over_signal(simulated_si, vmax="96th")

# %%
# sphinx_gallery_thumbnail_number = 4
Loading