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

Static pattern matching framework, orientation similarity map and crystal map merging #234

Merged
merged 90 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
1fc5bd8
feat(SimilarityMetric): ZNCC, NDP and user defined metrics
onatlandsmyr Oct 12, 2020
2e8adc9
fix(SimilarityMetric): squeeze dimensions of similarity matrix
onatlandsmyr Oct 12, 2020
9d42d70
Merge branch 'similarity-metrics'
onatlandsmyr Oct 12, 2020
ce40f63
fix(SimiliarityMetric): rechunk dask arrays after type conversion
onatlandsmyr Oct 13, 2020
8d1b68b
Merge branch 'similarity-metrics'
onatlandsmyr Oct 13, 2020
089e0d1
refactor(SimilarityMetric)
onatlandsmyr Oct 13, 2020
83e87c7
test(SimilarityMetric): Many to many ZNCC
onatlandsmyr Oct 13, 2020
0754523
refactor: removed metricscopes including ANY
onatlandsmyr Oct 13, 2020
c1d70db
wip: tests cover most cases
onatlandsmyr Oct 13, 2020
096540e
test: remove print statement
onatlandsmyr Oct 13, 2020
0d5bbb4
Merge branch 'similarity-metrics' into template-matching
onatlandsmyr Oct 13, 2020
21c8c63
refactor: indexation -> indexing
onatlandsmyr Oct 13, 2020
405a587
Reformat docstrings, add Ole to credits, add indexing module to doc
hakonanes Oct 13, 2020
23d93d8
refactor: renamed variables and made functions private
onatlandsmyr Oct 13, 2020
aaa0f12
Merge remote-tracking branch 'origin/similarity-metrics' into similar…
onatlandsmyr Oct 13, 2020
e3f3815
Merge branch 'similarity-metrics' into template-matching
onatlandsmyr Oct 13, 2020
9eb4310
refactor: underscore prefix
onatlandsmyr Oct 13, 2020
6aa285e
Merge branch 'similarity-metrics' into template-matching
onatlandsmyr Oct 13, 2020
c992d0b
refactor: underscore prefix
onatlandsmyr Oct 13, 2020
fbe77be
Merge branch 'similarity-metrics' into template-matching
onatlandsmyr Oct 13, 2020
eed1303
Update docstring table, and more
hakonanes Oct 13, 2020
9ed54a2
Merge branch 'similarity-metrics' of github.com:onatlandsmyr/kikuchip…
hakonanes Oct 13, 2020
b6f729f
Add indexing module to kikuchipy/__init__.py
hakonanes Oct 13, 2020
f6388c5
Add static dictionary indexing note in changelog
hakonanes Oct 13, 2020
be02b8d
fix: change standard shape of similarity matrix
onatlandsmyr Oct 16, 2020
635e24d
test: update tests to new output standard
onatlandsmyr Oct 16, 2020
97ea036
Merge remote-tracking branch 'origin/similarity-metrics' into similar…
onatlandsmyr Oct 16, 2020
c8035c3
Merge branch 'similarity-metrics' into template-matching
onatlandsmyr Oct 16, 2020
a9573d8
fix: _is_compatible to be working for all scopes
onatlandsmyr Oct 16, 2020
2555edf
Clarify parameters in docstrings, some minor syntax changes, repr
hakonanes Oct 16, 2020
85aa302
Merge branch 'similarity-metrics' of github.com:onatlandsmyr/kikuchip…
hakonanes Oct 16, 2020
376e3dc
Merge branch 'similarity-metrics' into template-matching
onatlandsmyr Oct 16, 2020
746893c
Docstring explanation of _is_compatible()
hakonanes Oct 16, 2020
ac5cc3b
Merge branch 'similarity-metrics' into template-matching
onatlandsmyr Oct 16, 2020
dff8456
Return numpy where only numpy arrays are passed, test repr
hakonanes Oct 16, 2020
ed6104a
Improve return numpy/dask test
hakonanes Oct 16, 2020
182f3a0
Merge branch 'similarity-metrics' into template-matching
onatlandsmyr Oct 16, 2020
a0725e9
feat(template_match): Keep n largest metric results and template indices
onatlandsmyr Oct 16, 2020
6402e33
tests: simple tests covering all lines
onatlandsmyr Oct 16, 2020
3f3e7eb
refactor: move code to give user more specific error
onatlandsmyr Oct 16, 2020
869746d
Merge remote-tracking branch 'pyxem/master' into similarity-metrics
onatlandsmyr Oct 16, 2020
1ad6d65
Merge branch 'similarity-metrics' into template-matching
onatlandsmyr Oct 16, 2020
fa0e981
refactor: removed comment
onatlandsmyr Oct 16, 2020
0b712e1
feat: StaticDictionaryIndexing, OSM and xmap merging
onatlandsmyr Oct 17, 2020
2b0d7e2
wip: empty test files
onatlandsmyr Oct 17, 2020
4a6feeb
docs: template_match and slicing of templates
onatlandsmyr Oct 17, 2020
8071674
fix: accept all scopes in template_match
onatlandsmyr Oct 17, 2020
3d1fed6
refactor: renamed variables and removed unnecessary code
onatlandsmyr Oct 17, 2020
083e390
refactor: moved code to read metric str earlier
onatlandsmyr Oct 18, 2020
192fbb0
docs: template slices and punctuation marks.
onatlandsmyr Oct 18, 2020
5a7167b
fix: raise NotImplementedError
onatlandsmyr Oct 18, 2020
89ef36f
fix: allow user-defined footprint in OSM
onatlandsmyr Oct 18, 2020
0367312
refactor+test: _merge -> merge_crystalmaps
onatlandsmyr Oct 18, 2020
ec1cefb
test: StaticDictionaryIndexing and OSM
onatlandsmyr Oct 18, 2020
bb8d3fa
Merge branch 'template-matching' into static-dictionary
onatlandsmyr Oct 18, 2020
2b6078a
docs: StaticDictionaryIndexing
onatlandsmyr Oct 18, 2020
aa6d320
fix: OSM bug
onatlandsmyr Oct 18, 2020
bb0ad78
refactor: template_match -> pattern_match
onatlandsmyr Oct 19, 2020
08d31be
refactor(SimilarityMetric): patterns->experimental, templates->simulated
onatlandsmyr Oct 20, 2020
ad46855
docs: data -> patterns
onatlandsmyr Oct 20, 2020
d2a0782
Merge branch 'template-matching' into static-dictionary
onatlandsmyr Oct 20, 2020
6179e32
feat: EBSD.index method using StaticDictionaryIndexing
onatlandsmyr Oct 20, 2020
e004054
fix: cyclic import and some documentation
onatlandsmyr Oct 20, 2020
be3c57b
Merge branch 'master' of github.com:pyxem/kikuchipy into static-dicti…
hakonanes Oct 26, 2020
b6179ba
Remove setting of n_slices to None in static dictionary comp.
hakonanes Oct 27, 2020
311df71
No longer raises ValueWarning instead of Error on merge equal phases
onatlandsmyr Oct 28, 2020
ec96dcd
Warns instead of raising error on merge equal phases
onatlandsmyr Oct 28, 2020
c56a972
Merge remote-tracking branch 'origin/static-dictionary' into static-d…
onatlandsmyr Oct 28, 2020
7bff4c2
refactor: templates -> simulated
onatlandsmyr Oct 28, 2020
4c691c2
refactor+test(EBSD): .index(...) -> .dictionary_indexing(...)
onatlandsmyr Oct 28, 2020
b1f304e
test: fix to pass
onatlandsmyr Oct 28, 2020
545d3fc
Merge branch 'master' of github.com:pyxem/kikuchipy into static-dicti…
hakonanes Oct 30, 2020
d431175
Merge branch 'master' into static-dictionary
hakonanes Oct 30, 2020
bdf53f7
Intermediate commit before merging master into this branch
hakonanes Nov 4, 2020
34a0ae9
Merge branch 'master' into static-dictionary
hakonanes Nov 4, 2020
51d1a03
Docstring changes, alternative merge_crystal_map [skip ci]
hakonanes Nov 4, 2020
37c257b
Enable single scores per point, return comb. scores/indices
hakonanes Nov 5, 2020
78c53cd
Cont. testing crystal map merging, ensuring all tests pass
hakonanes Nov 5, 2020
d3b69fe
100% coverage for xmap merging, some tests left
hakonanes Nov 6, 2020
c78db42
Finish crystal map merge tests
hakonanes Nov 6, 2020
6286481
Touch up merge_crystal_maps docstring
hakonanes Nov 9, 2020
5041904
Changes to static dictionary indexing and OSM [skip ci]
hakonanes Nov 10, 2020
35fe4a8
MetricScope SOME_TO_MANY/ONE, 100% coverage
hakonanes Nov 11, 2020
ca832e0
Rename ZNCC->NCC, make ncc and ndp available from module
hakonanes Nov 11, 2020
1e80f8d
Update changelog
hakonanes Nov 11, 2020
2716c8d
Add equation from Marquardt et al. (2017) to OSM docstring
hakonanes Nov 11, 2020
bf8b3fb
Print phase name and memory use % in indexing progressbar
hakonanes Nov 12, 2020
16d76ec
Clarify difference of keep_n variable in _pattern_matching funcs
hakonanes Nov 12, 2020
35eb2ce
Merge branch 'master' into static-dictionary
hakonanes Nov 13, 2020
fe9ca1c
Dictionary indexing (DI) -> pattern matching, but keep DI references
hakonanes Nov 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 7 additions & 11 deletions doc/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,14 @@ indexing
.. currentmodule:: kikuchipy.indexing

.. autosummary::
pattern_matching
merge_crystal_maps
orientation_similarity_map
StaticDictionaryIndexing
similarity_metrics

pattern_matching
----------------

.. currentmodule:: kikuchipy.indexing.pattern_matching

.. autosummary::
pattern_match

.. automodule:: kikuchipy.indexing.pattern_matching
.. autofunction:: merge_crystal_maps
.. autofunction:: orientation_similarity_map
.. autoclass:: StaticDictionaryIndexing
:members:
:undoc-members:
:show-inheritance:
Expand All @@ -257,7 +253,7 @@ similarity_metrics
....

io
==
===

.. automodule:: kikuchipy.io

Expand Down
63 changes: 60 additions & 3 deletions kikuchipy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
import gc
import os
import tempfile
from typing import Tuple

from diffpy.structure import Atom, Lattice, Structure
from diffsims.crystallography import ReciprocalLatticePoint
import numpy as np
from orix.crystal_map import Phase
from orix.crystal_map import CrystalMap, Phase, PhaseList
from orix.quaternion.rotation import Rotation
from orix.vector import Vector3d, neo_euler
import pytest
Expand All @@ -40,8 +41,8 @@

@pytest.fixture
def dummy_signal():
"""Dummy signal of shape <3, 3|3, 3>. If this is changed, all tests
using this signal will fail since they compare the output from
"""Dummy signal of shape <(3, 3)|(3, 3)>. If this is changed, all
tests using this signal will fail since they compare the output from
methods using this signal (as input) to hard-coded outputs.
"""
# fmt: off
Expand Down Expand Up @@ -292,3 +293,59 @@ def nickel_zone_axes(nickel_kikuchi_band, nickel_rotations, pc1):
in_pattern=uvw_in_pattern,
gnomonic_radius=detector.r_max,
)


@pytest.fixture
def rotations():
return Rotation([(2, 4, 6, 8), (-1, -3, -5, -7)])


@pytest.fixture
def get_single_phase_xmap(rotations):
def _get_single_phase_xmap(
nav_shape,
rotations_per_point=5,
prop_names=["scores", "simulation_indices"],
name="a",
phase_id=0,
):
d, map_size = _get_spatial_array_dicts(nav_shape)
rot_idx = np.random.choice(
np.arange(rotations.size), map_size * rotations_per_point
)
data_shape = (map_size,)
if rotations_per_point > 1:
data_shape += (rotations_per_point,)
d["rotations"] = rotations[rot_idx].reshape(*data_shape)
d["phase_id"] = np.ones(map_size) * phase_id
d["phase_list"] = PhaseList(Phase(name=name))
# Scores and simulation indices
d["prop"] = {
prop_names[0]: np.ones(data_shape, dtype=np.float32),
prop_names[1]: np.arange(np.prod(data_shape)).reshape(data_shape),
}
return CrystalMap(**d)

return _get_single_phase_xmap


def _get_spatial_array_dicts(
nav_shape: Tuple[int, int], step_sizes: Tuple[int, int] = (1.5, 1)
) -> Tuple[dict, int]:
ny, nx = nav_shape
dy, dx = step_sizes
d = {"x": None, "y": None, "z": None}
map_size = 1
if nx > 1:
if ny > 1:
d["x"] = np.tile(np.arange(nx) * dx, ny)
else:
d["x"] = np.arange(nx) * dx
map_size *= nx
if ny > 1:
if nx > 1:
d["y"] = np.sort(np.tile(np.arange(ny) * dy, nx))
else:
d["y"] = np.arange(ny) * dy
map_size *= ny
return d, map_size
14 changes: 11 additions & 3 deletions kikuchipy/indexing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,24 @@
# You should have received a copy of the GNU General Public License
# along with kikuchipy. If not, see <http://www.gnu.org/licenses/>.

"""Indexing of EBSD patterns."""
"""Indexing of EBSD patterns and useful related tools."""

from kikuchipy.indexing._merge_crystal_maps import merge_crystal_maps
from kikuchipy.indexing.orientation_similarity_map import (
orientation_similarity_map,
)
from kikuchipy.indexing.similarity_metrics import (
make_similarity_metric,
MetricScope,
)
from kikuchipy.indexing.pattern_matching import pattern_match
from kikuchipy.indexing._static_dictionary_indexing import (
StaticDictionaryIndexing,
)

__all__ = [
"merge_crystal_maps",
"orientation_similarity_map",
"make_similarity_metric",
"MetricScope",
"pattern_match",
"StaticDictionaryIndexing",
]