httomolibgpu 5.5.1__tar.gz → 5.6__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.
- {httomolibgpu-5.5.1/httomolibgpu.egg-info → httomolibgpu-5.6}/PKG-INFO +1 -1
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/misc/rescale.py +0 -1
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/prep/normalize.py +71 -11
- {httomolibgpu-5.5.1 → httomolibgpu-5.6/httomolibgpu.egg-info}/PKG-INFO +1 -1
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/LICENSE +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/MANIFEST.in +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/README.rst +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/__init__.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/__init__.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/calc_metrics.cu +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/center_360_shifts.cu +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/generate_mask.cu +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/median_kernel.cu +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/raven_filter.cu +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/remove_nan_inf.cu +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/remove_stripe_fw.cu +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/cupywrapper.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/misc/__init__.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/misc/corr.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/misc/denoise.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/misc/morph.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/misc/utils.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/prep/__init__.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/prep/alignment.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/prep/phase.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/prep/stripe.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/recon/__init__.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/recon/_phase_cross_correlation.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/recon/algorithm.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu/recon/rotation.py +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu.egg-info/SOURCES.txt +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu.egg-info/dependency_links.txt +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu.egg-info/requires.txt +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/httomolibgpu.egg-info/top_level.txt +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/pyproject.toml +0 -0
- {httomolibgpu-5.5.1 → httomolibgpu-5.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: httomolibgpu
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.6
|
|
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
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"""Modules for raw projection data normalization"""
|
|
22
22
|
|
|
23
23
|
from httomolibgpu import cupywrapper
|
|
24
|
+
import numpy as np
|
|
24
25
|
|
|
25
26
|
cp = cupywrapper.cp
|
|
26
27
|
cupy_run = cupywrapper.cupy_run
|
|
@@ -32,8 +33,8 @@ if cupy_run:
|
|
|
32
33
|
else:
|
|
33
34
|
mean = Mock()
|
|
34
35
|
|
|
35
|
-
from typing import Union
|
|
36
|
-
from numpy import float32
|
|
36
|
+
from typing import Union, Optional
|
|
37
|
+
from numpy import float32, int64
|
|
37
38
|
from httomolibgpu.misc.utils import (
|
|
38
39
|
__check_variable_type,
|
|
39
40
|
__check_if_data_3D_array,
|
|
@@ -49,7 +50,8 @@ def dark_flat_field_correction(
|
|
|
49
50
|
darks: cp.ndarray,
|
|
50
51
|
flats_multiplier: Union[float, int] = 1.0,
|
|
51
52
|
darks_multiplier: Union[float, int] = 1.0,
|
|
52
|
-
|
|
53
|
+
upper_bound: Optional[Union[float, int]] = None,
|
|
54
|
+
lower_bound: Optional[Union[float, int]] = None,
|
|
53
55
|
) -> cp.ndarray:
|
|
54
56
|
"""
|
|
55
57
|
Perform dark/flat field correction of raw projection data.
|
|
@@ -66,8 +68,10 @@ def dark_flat_field_correction(
|
|
|
66
68
|
A multiplier to apply to flats, can work as an intensity compensation constant.
|
|
67
69
|
darks_multiplier: float,int
|
|
68
70
|
A multiplier to apply to darks, can work as an intensity compensation constant.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
upper_bound : Optional[float, int]
|
|
72
|
+
All values above the upper bound are set to the provided value. Default None.
|
|
73
|
+
lower_bound : Optional[float, int]
|
|
74
|
+
All values bellow the lower bound are set to the provided value. Default None.
|
|
71
75
|
|
|
72
76
|
Returns
|
|
73
77
|
-------
|
|
@@ -92,10 +96,21 @@ def dark_flat_field_correction(
|
|
|
92
96
|
__check_variable_type(
|
|
93
97
|
darks_multiplier, [int, float], "darks_multiplier", [], methods_name
|
|
94
98
|
)
|
|
95
|
-
__check_variable_type(
|
|
96
|
-
|
|
99
|
+
__check_variable_type(
|
|
100
|
+
upper_bound, [int, float, type(None)], "upper_bound", [], methods_name
|
|
101
|
+
)
|
|
102
|
+
__check_variable_type(
|
|
103
|
+
lower_bound, [int, float, type(None)], "lower_bound", [], methods_name
|
|
104
|
+
)
|
|
97
105
|
|
|
98
106
|
_check_valid_input_flats_darks(flats, darks)
|
|
107
|
+
###################################
|
|
108
|
+
|
|
109
|
+
data_elements_num = int(np.prod(data.shape))
|
|
110
|
+
if upper_bound is None:
|
|
111
|
+
upper_bound = 1e12
|
|
112
|
+
if lower_bound is None:
|
|
113
|
+
lower_bound = -1e12
|
|
99
114
|
|
|
100
115
|
dark0 = cp.empty(darks.shape[1:], dtype=float32)
|
|
101
116
|
flat0 = cp.empty(flats.shape[1:], dtype=float32)
|
|
@@ -114,12 +129,12 @@ def dark_flat_field_correction(
|
|
|
114
129
|
}
|
|
115
130
|
float v = (float(data) - float(darks))/denom;
|
|
116
131
|
"""
|
|
117
|
-
kernel += "if (v >
|
|
118
|
-
kernel += "if (v
|
|
132
|
+
kernel += "if (v > upper_bound) v = upper_bound;\n"
|
|
133
|
+
kernel += "if (v <= lower_bound) v = lower_bound;\n"
|
|
119
134
|
kernel += "out = v;\n"
|
|
120
135
|
|
|
121
136
|
normalisation_kernel = cp.ElementwiseKernel(
|
|
122
|
-
"T data, U flats, U darks, raw float32
|
|
137
|
+
"T data, U flats, U darks, raw float32 upper_bound, raw float32 lower_bound",
|
|
123
138
|
"float32 out",
|
|
124
139
|
kernel,
|
|
125
140
|
kernel_name,
|
|
@@ -128,7 +143,52 @@ def dark_flat_field_correction(
|
|
|
128
143
|
no_return=True,
|
|
129
144
|
)
|
|
130
145
|
|
|
131
|
-
|
|
146
|
+
count_greater_kernel = cp.ReductionKernel(
|
|
147
|
+
in_params="T data, raw float32 upper_bound",
|
|
148
|
+
out_params="int32 out",
|
|
149
|
+
map_expr="data >= upper_bound ? 1 : 0", # map each element → 1 or 0
|
|
150
|
+
reduce_expr="a + b", # sum them
|
|
151
|
+
post_map_expr="out = a", # final result
|
|
152
|
+
identity="0",
|
|
153
|
+
name="count_greater",
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
count_smaller_kernel = cp.ReductionKernel(
|
|
157
|
+
in_params="T data, raw float32 lower_bound",
|
|
158
|
+
out_params="int32 out",
|
|
159
|
+
map_expr="data <= lower_bound ? 1 : 0", # map each element → 1 or 0
|
|
160
|
+
reduce_expr="a + b", # sum them
|
|
161
|
+
post_map_expr="out = a", # final result
|
|
162
|
+
identity="0",
|
|
163
|
+
name="count_smaller",
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
normalisation_kernel(data, flat0, dark0, upper_bound, lower_bound, out)
|
|
167
|
+
|
|
168
|
+
# Count the amount of clipping and raise warnings if required
|
|
169
|
+
clipped_percentage_warning = (
|
|
170
|
+
50.0 # warning if more clipped values than given percentage
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
clipped_total_up = int(count_greater_kernel(out, float32(upper_bound)))
|
|
174
|
+
clipped_up_percent = clipped_total_up / data_elements_num * 100
|
|
175
|
+
|
|
176
|
+
if clipped_up_percent >= clipped_percentage_warning:
|
|
177
|
+
print(
|
|
178
|
+
"Warning! The output data of 'dark_flat_field_correction' method contains \033[31m{}\033[0m percent of 'upper_bound' clipped data.".format(
|
|
179
|
+
int(clipped_up_percent)
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
clipped_total_lower = int(count_smaller_kernel(out, float32(lower_bound)))
|
|
184
|
+
clipped_down_percent = clipped_total_lower / data_elements_num * 100
|
|
185
|
+
|
|
186
|
+
if clipped_down_percent >= clipped_percentage_warning:
|
|
187
|
+
print(
|
|
188
|
+
"Warning! The output data of 'dark_flat_field_correction' method contains \033[31m{}\033[0m percent of 'lower_bound' clipped data.".format(
|
|
189
|
+
int(clipped_down_percent)
|
|
190
|
+
)
|
|
191
|
+
)
|
|
132
192
|
|
|
133
193
|
return out
|
|
134
194
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: httomolibgpu
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.6
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|