stemdiff 5.2.10__tar.gz → 5.2.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stemdiff-5.2.10/src/stemdiff.egg-info → stemdiff-5.2.12}/PKG-INFO +37 -34
- stemdiff-5.2.12/README.md +76 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/setup.py +12 -2
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/STEMDIFF/__init__.py +1 -1
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/STEMDIFF/dbase.py +3 -3
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/STEMDIFF/io.py +109 -0
- stemdiff-5.2.12/src/STEMDIFF/sum.py +399 -0
- stemdiff-5.2.12/src/STEMDIFF/summ.py +190 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12/src/stemdiff.egg-info}/PKG-INFO +37 -34
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/stemdiff.egg-info/requires.txt +6 -1
- stemdiff-5.2.10/README.md +0 -79
- stemdiff-5.2.10/src/STEMDIFF/sum.py +0 -359
- stemdiff-5.2.10/src/STEMDIFF/summ.py +0 -193
- {stemdiff-5.2.10 → stemdiff-5.2.12}/CITATION +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/LICENCE +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/MANIFEST.in +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/pyproject.toml +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/setup.cfg +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/STEMDIFF/__main__.py +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/STEMDIFF/detectors.py +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/STEMDIFF/gvars.py +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/stemdiff.egg-info/SOURCES.txt +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/stemdiff.egg-info/dependency_links.txt +0 -0
- {stemdiff-5.2.10 → stemdiff-5.2.12}/src/stemdiff.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: stemdiff
|
|
3
|
-
Version: 5.2.
|
|
3
|
+
Version: 5.2.12
|
|
4
4
|
Summary: Convert 4D-STEM data to 2D-powder diffraction pattern.
|
|
5
5
|
Home-page: https://github.com/mirekslouf/stemdiff/
|
|
6
6
|
Author: Mirek Slouf
|
|
@@ -14,10 +14,15 @@ Requires-Python: >=3.6
|
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENCE
|
|
16
16
|
Requires-Dist: numpy
|
|
17
|
-
Requires-Dist: matplotlib
|
|
18
17
|
Requires-Dist: scipy
|
|
19
18
|
Requires-Dist: pandas
|
|
19
|
+
Requires-Dist: matplotlib
|
|
20
20
|
Requires-Dist: scikit-image
|
|
21
|
+
Requires-Dist: pillow
|
|
22
|
+
Requires-Dist: opencv-python
|
|
23
|
+
Requires-Dist: tqdm
|
|
24
|
+
Requires-Dist: ediff
|
|
25
|
+
Requires-Dist: idiff
|
|
21
26
|
Dynamic: author
|
|
22
27
|
Dynamic: author-email
|
|
23
28
|
Dynamic: classifier
|
|
@@ -25,6 +30,7 @@ Dynamic: description
|
|
|
25
30
|
Dynamic: description-content-type
|
|
26
31
|
Dynamic: home-page
|
|
27
32
|
Dynamic: license
|
|
33
|
+
Dynamic: license-file
|
|
28
34
|
Dynamic: project-url
|
|
29
35
|
Dynamic: requires-dist
|
|
30
36
|
Dynamic: requires-python
|
|
@@ -35,37 +41,36 @@ STEMDIFF :: 4D-STEM dataset to 2D-diffractogram
|
|
|
35
41
|
|
|
36
42
|
* The **STEMDIFF package** converts... <br>
|
|
37
43
|
... a 4D-STEM dataset from a SEM microscope (huge and complex) <br>
|
|
38
|
-
... to a 2D-powder diffraction pattern (simple and easy to
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
[https://doi.org/10.3390/nano11040962](https://doi.org/10.3390/nano11040962)
|
|
43
|
-
2. *Materials* 14 (2021) 7550.
|
|
44
|
-
[https://doi.org/10.3390/ma14247550](https://doi.org/10.3390/ma14247550)
|
|
45
|
-
* If you use STEMDIFF package, **please cite** the 2nd publication (or both :-)
|
|
44
|
+
... to a 2D-powder diffraction pattern (simple and easy to process).
|
|
45
|
+
* If you use EDIFF in your research, **please cite** our recent paper:
|
|
46
|
+
- *Microscopy and Microanalysis* 31, 2025, ozaf045. <br>
|
|
47
|
+
[https://doi.org/10.1093/mam/ozaf045](https://doi.org/10.1093/mam/ozaf045)
|
|
46
48
|
|
|
47
49
|
Principle
|
|
48
50
|
---------
|
|
49
51
|
|
|
50
52
|
<img src="https://mirekslouf.github.io/stemdiff/docs/assets/principle.pptx.png" alt="STEMDIFF principle" width="500"/>
|
|
51
53
|
|
|
54
|
+
|
|
52
55
|
Installation
|
|
53
56
|
------------
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
* Installation of stemdiff:
|
|
58
|
+
- `pip install stemdiff`
|
|
59
|
+
* Additional packages (auto-installed with stemdiff if not present):
|
|
60
|
+
- Standard sci-libraries: `numpy`, `matplotlib`, `scipy`, `pandas`
|
|
61
|
+
- Additional libs for images: `scikit-image`, `pillow`, `opencv-python`
|
|
62
|
+
- Additional libs for calculations: `tqdm`, `ediff`, `idiff`
|
|
59
63
|
|
|
60
64
|
Quick start
|
|
61
65
|
-----------
|
|
62
66
|
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
[
|
|
68
|
-
and
|
|
67
|
+
* [Worked example](https://drive.google.com/file/d/1K3jWqiO1CpX-d4avcoYK0S8JfbAkZU78/view?usp=sharing)
|
|
68
|
+
shows the STEMDIFF package in action.
|
|
69
|
+
* [Help on GitHub](https://mirekslouf.github.io/stemdiff/docs/)
|
|
70
|
+
with complete
|
|
71
|
+
[package documentation](https://mirekslouf.github.io/stemdiff/docs/pdoc.html/stemdiff.html)
|
|
72
|
+
and
|
|
73
|
+
[additional examples](https://drive.google.com/drive/folders/1X4TOdnMHVGSskzQJZ12edLt6MVl3HLvm?usp=sharing).
|
|
69
74
|
|
|
70
75
|
Documentation, help and examples
|
|
71
76
|
--------------------------------
|
|
@@ -74,11 +79,12 @@ Documentation, help and examples
|
|
|
74
79
|
the stable version to install.
|
|
75
80
|
* [GitHub](https://github.com/mirekslouf/stemdiff) repository -
|
|
76
81
|
the current version under development.
|
|
77
|
-
* [GitHub Pages](https://mirekslouf.github.io/stemdiff)
|
|
78
|
-
|
|
79
|
-
and [complete package documentation](https://mirekslouf.github.io/stemdiff/docs/pdoc.html/stemdiff.html).
|
|
82
|
+
* [GitHub Pages](https://mirekslouf.github.io/stemdiff/) -
|
|
83
|
+
the more user-friendly version of GitHub website.
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
|
|
86
|
+
Versions of STEMDIFF
|
|
87
|
+
--------------------
|
|
82
88
|
|
|
83
89
|
* Version 1.0 = Matlab: just a simple summation of 4D-dataset
|
|
84
90
|
* Version 2.0 = like v.1.0 + post-processing in Jupyter
|
|
@@ -92,20 +98,17 @@ Documentation, help and examples
|
|
|
92
98
|
* sum just the central region with the strongest diffractions
|
|
93
99
|
⇒ higher speed
|
|
94
100
|
* 3 centering types: (0) geometry, (1) center of 1st, (2) individual centers
|
|
95
|
-
*
|
|
96
|
-
* better documentation strings + demo data + improved *master script*
|
|
101
|
+
* improved definition of summation and better documentation
|
|
97
102
|
* Version 5.0 = complete rewrite of v.4.2
|
|
98
|
-
* all key features of v.4.2 (summation, filtering, deconvolution)
|
|
99
103
|
* conversion *2D-diffractogram → 1D-profile* moved to package EDIFF
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
- better filtering (including estimated number of diffractions)
|
|
103
|
-
- more types of deconvolution (experimental; to be finished in v.6.0)
|
|
104
|
+
* better filtering (including estimated number of diffractions)
|
|
105
|
+
* more detectors + more types of deconvolution (beta; to finish in v.6.0)
|
|
104
106
|
* Version 5.1 = (beta) support for parallel processing
|
|
105
107
|
* Version 5.2 = (beta) improvement of diff.patterns in sister package idiff
|
|
106
108
|
|
|
109
|
+
|
|
107
110
|
Acknowledgement
|
|
108
111
|
---------------
|
|
109
112
|
|
|
110
113
|
The development was co-funded by TACR, program NCK,
|
|
111
|
-
project [TN02000020](https://
|
|
114
|
+
project [TN02000020](https://starfos.tacr.cz/en/projekty/TN02000020).
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
STEMDIFF :: 4D-STEM dataset to 2D-diffractogram
|
|
2
|
+
-----------------------------------------------
|
|
3
|
+
|
|
4
|
+
* The **STEMDIFF package** converts... <br>
|
|
5
|
+
... a 4D-STEM dataset from a SEM microscope (huge and complex) <br>
|
|
6
|
+
... to a 2D-powder diffraction pattern (simple and easy to process).
|
|
7
|
+
* If you use EDIFF in your research, **please cite** our recent paper:
|
|
8
|
+
- *Microscopy and Microanalysis* 31, 2025, ozaf045. <br>
|
|
9
|
+
[https://doi.org/10.1093/mam/ozaf045](https://doi.org/10.1093/mam/ozaf045)
|
|
10
|
+
|
|
11
|
+
Principle
|
|
12
|
+
---------
|
|
13
|
+
|
|
14
|
+
<img src="https://mirekslouf.github.io/stemdiff/docs/assets/principle.pptx.png" alt="STEMDIFF principle" width="500"/>
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
Installation
|
|
18
|
+
------------
|
|
19
|
+
* Installation of stemdiff:
|
|
20
|
+
- `pip install stemdiff`
|
|
21
|
+
* Additional packages (auto-installed with stemdiff if not present):
|
|
22
|
+
- Standard sci-libraries: `numpy`, `matplotlib`, `scipy`, `pandas`
|
|
23
|
+
- Additional libs for images: `scikit-image`, `pillow`, `opencv-python`
|
|
24
|
+
- Additional libs for calculations: `tqdm`, `ediff`, `idiff`
|
|
25
|
+
|
|
26
|
+
Quick start
|
|
27
|
+
-----------
|
|
28
|
+
|
|
29
|
+
* [Worked example](https://drive.google.com/file/d/1K3jWqiO1CpX-d4avcoYK0S8JfbAkZU78/view?usp=sharing)
|
|
30
|
+
shows the STEMDIFF package in action.
|
|
31
|
+
* [Help on GitHub](https://mirekslouf.github.io/stemdiff/docs/)
|
|
32
|
+
with complete
|
|
33
|
+
[package documentation](https://mirekslouf.github.io/stemdiff/docs/pdoc.html/stemdiff.html)
|
|
34
|
+
and
|
|
35
|
+
[additional examples](https://drive.google.com/drive/folders/1X4TOdnMHVGSskzQJZ12edLt6MVl3HLvm?usp=sharing).
|
|
36
|
+
|
|
37
|
+
Documentation, help and examples
|
|
38
|
+
--------------------------------
|
|
39
|
+
|
|
40
|
+
* [PyPI](https://pypi.org/project/stemdiff) repository -
|
|
41
|
+
the stable version to install.
|
|
42
|
+
* [GitHub](https://github.com/mirekslouf/stemdiff) repository -
|
|
43
|
+
the current version under development.
|
|
44
|
+
* [GitHub Pages](https://mirekslouf.github.io/stemdiff/) -
|
|
45
|
+
the more user-friendly version of GitHub website.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
Versions of STEMDIFF
|
|
49
|
+
--------------------
|
|
50
|
+
|
|
51
|
+
* Version 1.0 = Matlab: just a simple summation of 4D-dataset
|
|
52
|
+
* Version 2.0 = like v.1.0 + post-processing in Jupyter
|
|
53
|
+
* Version 3.0 = Python scripts: summation + S-filtering
|
|
54
|
+
* Version 4.0 = Python package: summation + S-filtering + deconvolution
|
|
55
|
+
* summation = summation of all 2D-diffractograms
|
|
56
|
+
* S-filtering = sum only diffractograms with strong diffractions = high S
|
|
57
|
+
* deconvolution = reduce the primary beam spread effect
|
|
58
|
+
⇒ better resolution
|
|
59
|
+
* Version 4.2 = like v.4.0 + a few important improvements, such as:
|
|
60
|
+
* sum just the central region with the strongest diffractions
|
|
61
|
+
⇒ higher speed
|
|
62
|
+
* 3 centering types: (0) geometry, (1) center of 1st, (2) individual centers
|
|
63
|
+
* improved definition of summation and better documentation
|
|
64
|
+
* Version 5.0 = complete rewrite of v.4.2
|
|
65
|
+
* conversion *2D-diffractogram → 1D-profile* moved to package EDIFF
|
|
66
|
+
* better filtering (including estimated number of diffractions)
|
|
67
|
+
* more detectors + more types of deconvolution (beta; to finish in v.6.0)
|
|
68
|
+
* Version 5.1 = (beta) support for parallel processing
|
|
69
|
+
* Version 5.2 = (beta) improvement of diff.patterns in sister package idiff
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Acknowledgement
|
|
73
|
+
---------------
|
|
74
|
+
|
|
75
|
+
The development was co-funded by TACR, program NCK,
|
|
76
|
+
project [TN02000020](https://starfos.tacr.cz/en/projekty/TN02000020).
|
|
@@ -32,6 +32,16 @@ setuptools.setup(
|
|
|
32
32
|
package_dir={"":"src"},
|
|
33
33
|
packages=setuptools.find_packages(where="src"),
|
|
34
34
|
python_requires=">=3.6",
|
|
35
|
-
install_requires=
|
|
36
|
-
|
|
35
|
+
install_requires=[
|
|
36
|
+
"numpy",
|
|
37
|
+
"scipy", # io.py
|
|
38
|
+
"pandas", # dbase.py
|
|
39
|
+
"matplotlib", # io.py, and provides mpl_toolkits
|
|
40
|
+
"scikit-image", # dbase.py, io.py, sum.py
|
|
41
|
+
"pillow", # detectors.py, io.py
|
|
42
|
+
"opencv-python", # io.py: cv2.resize
|
|
43
|
+
"tqdm", # sum.py, summ.py
|
|
44
|
+
"ediff", # sum.py
|
|
45
|
+
"idiff", # sum.py, summ.py
|
|
46
|
+
],
|
|
37
47
|
include_package_data=True)
|
|
@@ -56,11 +56,11 @@ def calc_database(SDATA, DIFFIMAGES):
|
|
|
56
56
|
# (the center must be determined for rescaled/upscaled array
|
|
57
57
|
if DIFFIMAGES.ctype == 2:
|
|
58
58
|
xc,yc = stemdiff.io.Arrays.find_center(
|
|
59
|
-
stemdiff.io.Arrays.
|
|
59
|
+
stemdiff.io.Arrays.rescale_fast(arr, R, inter=2), # rescaled array
|
|
60
60
|
DIFFIMAGES.csquare*R, DIFFIMAGES.cintensity) # central region
|
|
61
61
|
elif (DIFFIMAGES.ctype == 1) and (xc == None):
|
|
62
|
-
xc,yc = stemdiff.io.
|
|
63
|
-
stemdiff.io.Arrays.
|
|
62
|
+
xc,yc = stemdiff.io.Arrays.find_center(
|
|
63
|
+
stemdiff.io.Arrays.rescale_fast(arr, R, inter=2), # rescaled array
|
|
64
64
|
DIFFIMAGES.csquare*R, DIFFIMAGES.cintensity) # central region
|
|
65
65
|
elif (DIFFIMAGES.ctype == 0) and (xc == None):
|
|
66
66
|
geometric_center = round(SDATA.detector.detector_size*R/2)
|
|
@@ -50,6 +50,8 @@ import matplotlib.pyplot as plt
|
|
|
50
50
|
from mpl_toolkits import axes_grid1 # to add nice colorbars
|
|
51
51
|
from PIL import Image
|
|
52
52
|
from skimage import transform, measure, morphology
|
|
53
|
+
from scipy.ndimage import shift
|
|
54
|
+
import cv2
|
|
53
55
|
|
|
54
56
|
|
|
55
57
|
def set_plot_parameters(size=(12,9), dpi=75, fontsize=10, my_rcParams=None):
|
|
@@ -636,7 +638,114 @@ class Arrays:
|
|
|
636
638
|
arr = arr/np.max(arr) * arr_max
|
|
637
639
|
# Return the rescaled array.
|
|
638
640
|
return(arr)
|
|
641
|
+
|
|
642
|
+
def rescale_fast(arr, R, inter=1):
|
|
643
|
+
'''
|
|
644
|
+
Rescale 2D numpy array (which represents an image).
|
|
645
|
+
Uses resize function from cv2, which is fater than skimage rescale.
|
|
646
|
+
|
|
647
|
+
Parameters
|
|
648
|
+
----------
|
|
649
|
+
arr : 2D numpy array
|
|
650
|
+
Numpy array representing DAT-file/image.
|
|
651
|
+
R : integer
|
|
652
|
+
Rescale parameter: new_size_of the array = original_size * R
|
|
653
|
+
inter : integer
|
|
654
|
+
Interpolation mode:
|
|
655
|
+
* 0 = nearest
|
|
656
|
+
* 1 = linear
|
|
657
|
+
* 2 = cubic
|
|
658
|
+
|
|
659
|
+
Returns
|
|
660
|
+
-------
|
|
661
|
+
arr : 2D numpy array
|
|
662
|
+
The array has `new_size = original_size * R`.
|
|
663
|
+
'''
|
|
664
|
+
# Map inter to cv enum
|
|
665
|
+
inters = [
|
|
666
|
+
cv2.INTER_NEAREST,
|
|
667
|
+
cv2.INTER_LINEAR,
|
|
668
|
+
cv2.INTER_CUBIC
|
|
669
|
+
]
|
|
670
|
+
# Keep original value of array maximum.
|
|
671
|
+
arr_max = np.max(arr)
|
|
672
|
+
# Rescale the array.
|
|
673
|
+
# dsize is required, (0, 0) means use fx and fy
|
|
674
|
+
arr = cv2.resize(arr, (0, 0), fx=R, fy=R, interpolation=inters[inter])
|
|
675
|
+
# Restore the original value of array maximum.
|
|
676
|
+
arr = arr/np.max(arr) * arr_max
|
|
677
|
+
# Avoid negative values
|
|
678
|
+
arr = np.clip(arr, 0, None)
|
|
679
|
+
# Return the rescaled array.
|
|
680
|
+
return arr
|
|
681
|
+
|
|
682
|
+
def zero_spatial_edges(arr, border_width=10):
|
|
683
|
+
'''
|
|
684
|
+
Zeros the edges of an array with shape (..., H, W).
|
|
685
|
+
This allows processing N images at once - shape (N, H, W).
|
|
686
|
+
Also works for a single image with shape (H, W).
|
|
687
|
+
|
|
688
|
+
Important - this operation happens inplace (the zeros are written
|
|
689
|
+
to the input array).
|
|
639
690
|
|
|
691
|
+
Parameters
|
|
692
|
+
----------
|
|
693
|
+
arr : numpy array
|
|
694
|
+
Numpy array representing DAT-file/image.
|
|
695
|
+
border_width : int, optional, default is 10
|
|
696
|
+
Width of the
|
|
697
|
+
|
|
698
|
+
Returns
|
|
699
|
+
-------
|
|
700
|
+
numpy array
|
|
701
|
+
Array with zeroed edges.
|
|
702
|
+
'''
|
|
703
|
+
w = border_width
|
|
704
|
+
|
|
705
|
+
# Zero Top and Bottom
|
|
706
|
+
arr[..., :w, :] = 0 # first 'w' rows
|
|
707
|
+
arr[..., -w:, :] = 0 # last 'w' rows
|
|
708
|
+
|
|
709
|
+
# Zero Left and Right
|
|
710
|
+
arr[..., :, :w] = 0 # first 'w' columns
|
|
711
|
+
arr[..., :, -w:] = 0 # last 'w' columns
|
|
712
|
+
|
|
713
|
+
return arr
|
|
714
|
+
|
|
715
|
+
def recenter(arr, center_x, center_y):
|
|
716
|
+
'''
|
|
717
|
+
Recenters the image by shifting (center_x, center_y) to the array
|
|
718
|
+
center.
|
|
719
|
+
Empty edges are filled with zeros.
|
|
720
|
+
|
|
721
|
+
Parameters
|
|
722
|
+
----------
|
|
723
|
+
arr : 2D numpy array
|
|
724
|
+
Numpy array representing DAT-file/image.
|
|
725
|
+
center_x : int
|
|
726
|
+
X coordinate of the center.
|
|
727
|
+
center_y : int
|
|
728
|
+
Y coordinate of the center.
|
|
729
|
+
|
|
730
|
+
Returns
|
|
731
|
+
-------
|
|
732
|
+
2D numpy array
|
|
733
|
+
Centered array.
|
|
734
|
+
'''
|
|
735
|
+
h, w = arr.shape
|
|
736
|
+
|
|
737
|
+
# Calculate the required displacement
|
|
738
|
+
# shift_y = target_y - current_y
|
|
739
|
+
shift_y = (h // 2) - center_y
|
|
740
|
+
shift_x = (w // 2) - center_x
|
|
741
|
+
|
|
742
|
+
# mode='constant' fills the boundary with cval (default is 0.0)
|
|
743
|
+
# order=0 uses nearest-neighbor (keeps pixel values exact)
|
|
744
|
+
# order=1 uses bilinear interpolation (smoother, better for sub-pixel)
|
|
745
|
+
shifted_img = shift(arr, shift=[shift_x, shift_y], mode='constant',
|
|
746
|
+
cval=0, order=0)
|
|
747
|
+
|
|
748
|
+
return shifted_img
|
|
640
749
|
|
|
641
750
|
def remove_edges(arr,rsize,xc,yc):
|
|
642
751
|
'''
|