httomolibgpu 3.1.1__py3-none-any.whl → 4.0__py3-none-any.whl
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.
- httomolibgpu/__init__.py +1 -1
- httomolibgpu/prep/phase.py +40 -56
- httomolibgpu/recon/algorithm.py +5 -5
- {httomolibgpu-3.1.1.dist-info → httomolibgpu-4.0.dist-info}/METADATA +1 -1
- {httomolibgpu-3.1.1.dist-info → httomolibgpu-4.0.dist-info}/RECORD +8 -8
- {httomolibgpu-3.1.1.dist-info → httomolibgpu-4.0.dist-info}/WHEEL +0 -0
- {httomolibgpu-3.1.1.dist-info → httomolibgpu-4.0.dist-info}/licenses/LICENSE +0 -0
- {httomolibgpu-3.1.1.dist-info → httomolibgpu-4.0.dist-info}/top_level.txt +0 -0
httomolibgpu/__init__.py
CHANGED
|
@@ -4,7 +4,7 @@ from httomolibgpu.misc.morph import sino_360_to_180, data_resampler
|
|
|
4
4
|
from httomolibgpu.misc.rescale import rescale_to_int
|
|
5
5
|
from httomolibgpu.prep.alignment import distortion_correction_proj_discorpy
|
|
6
6
|
from httomolibgpu.prep.normalize import normalize
|
|
7
|
-
from httomolibgpu.prep.phase import
|
|
7
|
+
from httomolibgpu.prep.phase import paganin_filter
|
|
8
8
|
from httomolibgpu.prep.stripe import (
|
|
9
9
|
remove_stripe_based_sorting,
|
|
10
10
|
remove_stripe_ti,
|
httomolibgpu/prep/phase.py
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
# Created By : Tomography Team at DLS <scientificsoftware@diamond.ac.uk>
|
|
19
19
|
# Created Date: 01 November 2022
|
|
20
20
|
# ---------------------------------------------------------------------------
|
|
21
|
-
"""Modules for phase retrieval and phase-contrast enhancement"""
|
|
21
|
+
"""Modules for phase retrieval and phase-contrast enhancement. For more detailed information, see :ref:`phase_contrast_module`."""
|
|
22
22
|
|
|
23
23
|
import numpy as np
|
|
24
24
|
from httomolibgpu import cupywrapper
|
|
@@ -42,35 +42,36 @@ import math
|
|
|
42
42
|
from httomolibgpu.misc.supp_func import data_checker
|
|
43
43
|
|
|
44
44
|
__all__ = [
|
|
45
|
-
"
|
|
45
|
+
"paganin_filter",
|
|
46
46
|
]
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
#
|
|
51
|
-
|
|
49
|
+
# This implementation originated from the TomoPy version. It has been modified to conform
|
|
50
|
+
# different unit standards and also control of the filter driven by 'delta/beta' ratio
|
|
51
|
+
# as opposed to 'alpha' in the TomoPy's implementation.
|
|
52
|
+
def paganin_filter(
|
|
52
53
|
tomo: cp.ndarray,
|
|
53
|
-
pixel_size: float =
|
|
54
|
-
|
|
54
|
+
pixel_size: float = 1.28,
|
|
55
|
+
distance: float = 1.0,
|
|
55
56
|
energy: float = 53.0,
|
|
56
|
-
|
|
57
|
+
ratio_delta_beta: float = 250,
|
|
57
58
|
) -> cp.ndarray:
|
|
58
59
|
"""
|
|
59
|
-
Perform single-material phase retrieval from flats/darks corrected tomographic measurements.
|
|
60
|
-
:cite:`Paganin02` for
|
|
60
|
+
Perform single-material phase retrieval from flats/darks corrected tomographic measurements. For more detailed information, see :ref:`phase_contrast_module`.
|
|
61
|
+
Also see :cite:`Paganin02` and :cite:`paganin2020boosting` for references.
|
|
61
62
|
|
|
62
63
|
Parameters
|
|
63
64
|
----------
|
|
64
65
|
tomo : cp.ndarray
|
|
65
66
|
3D array of f/d corrected tomographic projections.
|
|
66
|
-
pixel_size : float
|
|
67
|
-
Detector pixel size in
|
|
68
|
-
|
|
69
|
-
Propagation distance of the wavefront in
|
|
70
|
-
energy : float
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
pixel_size : float
|
|
68
|
+
Detector pixel size (resolution) in micron units.
|
|
69
|
+
distance : float
|
|
70
|
+
Propagation distance of the wavefront from sample to detector in metre units.
|
|
71
|
+
energy : float
|
|
72
|
+
Beam energy in keV.
|
|
73
|
+
ratio_delta_beta : float
|
|
74
|
+
The ratio of delta/beta, where delta is the phase shift and real part of the complex material refractive index and beta is the absorption.
|
|
74
75
|
|
|
75
76
|
Returns
|
|
76
77
|
-------
|
|
@@ -84,7 +85,7 @@ def paganin_filter_tomopy(
|
|
|
84
85
|
" please provide a stack of 2D projections."
|
|
85
86
|
)
|
|
86
87
|
|
|
87
|
-
tomo = data_checker(tomo, verbosity=True, method_name="
|
|
88
|
+
tomo = data_checker(tomo, verbosity=True, method_name="paganin_filter")
|
|
88
89
|
|
|
89
90
|
dz_orig, dy_orig, dx_orig = tomo.shape
|
|
90
91
|
|
|
@@ -98,11 +99,18 @@ def paganin_filter_tomopy(
|
|
|
98
99
|
padded_tomo = cp.asarray(padded_tomo, dtype=cp.complex64)
|
|
99
100
|
fft_tomo = fft2(padded_tomo, axes=(-2, -1), overwrite_x=True)
|
|
100
101
|
|
|
101
|
-
#
|
|
102
|
-
|
|
102
|
+
# calculate alpha constant
|
|
103
|
+
alpha = _calculate_alpha(energy, distance / 1e-6, ratio_delta_beta)
|
|
104
|
+
|
|
105
|
+
# Compute the reciprocal grid
|
|
106
|
+
indx = _reciprocal_coord(pixel_size, dy)
|
|
107
|
+
indy = _reciprocal_coord(pixel_size, dx)
|
|
108
|
+
|
|
109
|
+
# Build Lorentzian-type filter
|
|
110
|
+
phase_filter = fftshift(
|
|
111
|
+
1.0 / (1.0 + alpha * (cp.add.outer(cp.square(indx), cp.square(indy))))
|
|
112
|
+
)
|
|
103
113
|
|
|
104
|
-
# Build filter in the Fourier space.
|
|
105
|
-
phase_filter = fftshift(_paganin_filter_factor2(energy, dist, alpha, w2))
|
|
106
114
|
phase_filter = phase_filter / phase_filter.max() # normalisation
|
|
107
115
|
|
|
108
116
|
# Filter projections
|
|
@@ -132,6 +140,12 @@ def paganin_filter_tomopy(
|
|
|
132
140
|
return _log_kernel(tomo)
|
|
133
141
|
|
|
134
142
|
|
|
143
|
+
def _calculate_alpha(energy, distance_micron, ratio_delta_beta):
|
|
144
|
+
return (
|
|
145
|
+
_wavelength_micron(energy) * distance_micron / (4 * math.pi)
|
|
146
|
+
) * ratio_delta_beta
|
|
147
|
+
|
|
148
|
+
|
|
135
149
|
def _shift_bit_length(x: int) -> int:
|
|
136
150
|
return 1 << (x - 1).bit_length()
|
|
137
151
|
|
|
@@ -192,42 +206,12 @@ def _pad_projections_to_second_power(
|
|
|
192
206
|
return padded_tomo, tuple(pad_list)
|
|
193
207
|
|
|
194
208
|
|
|
195
|
-
def
|
|
196
|
-
|
|
197
|
-
return 1 / (_wavelength(energy) * dist * w2 / (4 * math.pi) + alpha)
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
def _wavelength(energy: float) -> float:
|
|
201
|
-
SPEED_OF_LIGHT = 299792458e2 # [cm/s]
|
|
209
|
+
def _wavelength_micron(energy: float) -> float:
|
|
210
|
+
SPEED_OF_LIGHT = 299792458e2 * 10000.0 # [microns/s]
|
|
202
211
|
PLANCK_CONSTANT = 6.58211928e-19 # [keV*s]
|
|
203
212
|
return 2 * math.pi * PLANCK_CONSTANT * SPEED_OF_LIGHT / energy
|
|
204
213
|
|
|
205
214
|
|
|
206
|
-
def _reciprocal_grid(pixel_size: float, shape_proj: tuple) -> cp.ndarray:
|
|
207
|
-
"""
|
|
208
|
-
Calculate reciprocal grid.
|
|
209
|
-
|
|
210
|
-
Parameters
|
|
211
|
-
----------
|
|
212
|
-
pixel_size : float
|
|
213
|
-
Detector pixel size in cm.
|
|
214
|
-
shape_proj : tuple
|
|
215
|
-
Shape of the reciprocal grid along x and y axes.
|
|
216
|
-
|
|
217
|
-
Returns
|
|
218
|
-
-------
|
|
219
|
-
ndarray
|
|
220
|
-
Grid coordinates.
|
|
221
|
-
"""
|
|
222
|
-
# Sampling in reciprocal space.
|
|
223
|
-
indx = _reciprocal_coord(pixel_size, shape_proj[0])
|
|
224
|
-
indy = _reciprocal_coord(pixel_size, shape_proj[1])
|
|
225
|
-
indx_sq = cp.square(indx)
|
|
226
|
-
indy_sq = cp.square(indy)
|
|
227
|
-
|
|
228
|
-
return cp.add.outer(indx_sq, indy_sq)
|
|
229
|
-
|
|
230
|
-
|
|
231
215
|
def _reciprocal_coord(pixel_size: float, num_grid: int) -> cp.ndarray:
|
|
232
216
|
"""
|
|
233
217
|
Calculate reciprocal grid coordinates for a given pixel size
|
|
@@ -236,7 +220,7 @@ def _reciprocal_coord(pixel_size: float, num_grid: int) -> cp.ndarray:
|
|
|
236
220
|
Parameters
|
|
237
221
|
----------
|
|
238
222
|
pixel_size : float
|
|
239
|
-
Detector pixel size in
|
|
223
|
+
Detector pixel size in microns.
|
|
240
224
|
num_grid : int
|
|
241
225
|
Size of the reciprocal grid.
|
|
242
226
|
|
httomolibgpu/recon/algorithm.py
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
# Created By : Tomography Team at DLS <scientificsoftware@diamond.ac.uk>
|
|
19
19
|
# Changes relative to ToMoBAR 2024.01 version
|
|
20
20
|
# ---------------------------------------------------------------------------
|
|
21
|
-
"""Module for tomographic reconstruction. For more detailed information see :ref:`image_reconstruction_module`"""
|
|
21
|
+
"""Module for tomographic reconstruction. For more detailed information, see :ref:`image_reconstruction_module`"""
|
|
22
22
|
|
|
23
23
|
import numpy as np
|
|
24
24
|
from httomolibgpu import cupywrapper
|
|
@@ -215,9 +215,9 @@ def LPRec3d_tomobar(
|
|
|
215
215
|
recon_size: Optional[int] = None,
|
|
216
216
|
recon_mask_radius: float = 0.95,
|
|
217
217
|
power_of_2_oversampling: Optional[bool] = True,
|
|
218
|
-
power_of_2_cropping: Optional[bool] =
|
|
219
|
-
min_mem_usage_filter: Optional[bool] =
|
|
220
|
-
min_mem_usage_ifft2: Optional[bool] =
|
|
218
|
+
power_of_2_cropping: Optional[bool] = False,
|
|
219
|
+
min_mem_usage_filter: Optional[bool] = True,
|
|
220
|
+
min_mem_usage_ifft2: Optional[bool] = True,
|
|
221
221
|
neglog: bool = False,
|
|
222
222
|
) -> cp.ndarray:
|
|
223
223
|
"""
|
|
@@ -680,5 +680,5 @@ def _take_neg_log_np(data: np.ndarray) -> np.ndarray:
|
|
|
680
680
|
def __estimate_detectorHoriz_padding(detX_size) -> int:
|
|
681
681
|
det_half = detX_size // 2
|
|
682
682
|
padded_value_exact = int(np.sqrt(2 * (det_half**2))) - det_half
|
|
683
|
-
padded_add_margin =
|
|
683
|
+
padded_add_margin = padded_value_exact // 2
|
|
684
684
|
return padded_value_exact + padded_add_margin
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: httomolibgpu
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0
|
|
4
4
|
Summary: Commonly used tomography data processing methods at DLS.
|
|
5
5
|
Author-email: Daniil Kazantsev <daniil.kazantsev@diamond.ac.uk>, Yousef Moazzam <yousef.moazzam@diamond.ac.uk>, Naman Gera <naman.gera@diamond.ac.uk>
|
|
6
6
|
License: BSD-3-Clause
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
httomolibgpu/__init__.py,sha256=
|
|
1
|
+
httomolibgpu/__init__.py,sha256=j9BuoVz3kfxtUY8zDExpZOnM05eHuwNrua9zNZq1Zqw,831
|
|
2
2
|
httomolibgpu/cupywrapper.py,sha256=6ITGJ2Jw5I5kVmKEL5LlsnLRniEqqBLsHiAjvLtk0Xk,493
|
|
3
3
|
httomolibgpu/cuda_kernels/__init__.py,sha256=VQNMaGcVDwiE-C64FfLtubHpLriLG0Y3_QnjHBSHrN0,884
|
|
4
4
|
httomolibgpu/cuda_kernels/calc_metrics.cu,sha256=oV7ZPcwjWafmZjbNsUkBYPvOViJ_nX3zBoOAuPCmIrA,11335
|
|
@@ -16,13 +16,13 @@ httomolibgpu/misc/supp_func.py,sha256=yDzNmRlIlIikQ4sKd2y9trQ9yQtblECmQ2JM5vmIY5
|
|
|
16
16
|
httomolibgpu/prep/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
httomolibgpu/prep/alignment.py,sha256=BuFTfLZD5_THQAKP_ikQ3fRE8JpN-JItGllZgrHRU5s,5657
|
|
18
18
|
httomolibgpu/prep/normalize.py,sha256=ozVUAs4UY2DY7MQtJKllUgahp_4wRFKPuc_3iQl6bCE,4879
|
|
19
|
-
httomolibgpu/prep/phase.py,sha256=
|
|
19
|
+
httomolibgpu/prep/phase.py,sha256=X4RsIEux7DP9O6BXgNiOO2nEwGsphh2BtaUHiOm5onc,7200
|
|
20
20
|
httomolibgpu/prep/stripe.py,sha256=YgOVb7Z5H7NFM3d2Y1jfNNwwj7ZMDv9nMZMMCvdBnVM,15150
|
|
21
21
|
httomolibgpu/recon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
httomolibgpu/recon/algorithm.py,sha256=
|
|
22
|
+
httomolibgpu/recon/algorithm.py,sha256=6IbczYAikyXyqZbLjjBHOFE7Kir0OGHgJtnjUI8IJWk,28069
|
|
23
23
|
httomolibgpu/recon/rotation.py,sha256=k_E0lBRprJz6AGclagIkrzk_9dipADxPtL5BxrggSwM,27729
|
|
24
|
-
httomolibgpu-
|
|
25
|
-
httomolibgpu-
|
|
26
|
-
httomolibgpu-
|
|
27
|
-
httomolibgpu-
|
|
28
|
-
httomolibgpu-
|
|
24
|
+
httomolibgpu-4.0.dist-info/licenses/LICENSE,sha256=bXeLsgelPUUXw8HCIYiVC97Dpjhm2nB54m7TACdH8ng,48032
|
|
25
|
+
httomolibgpu-4.0.dist-info/METADATA,sha256=Y1elgzNtqV5cTbTs_AqFyCF9QAawUujRGaspi3bfeDY,3339
|
|
26
|
+
httomolibgpu-4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
27
|
+
httomolibgpu-4.0.dist-info/top_level.txt,sha256=nV0Ty_YvSPVd1O6MNWuIplD0w1nwk5hT76YgBZ-bzUw,13
|
|
28
|
+
httomolibgpu-4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|