httomolibgpu 5.5__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.
Files changed (36) hide show
  1. {httomolibgpu-5.5/httomolibgpu.egg-info → httomolibgpu-5.6}/PKG-INFO +1 -1
  2. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/misc/rescale.py +0 -1
  3. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/prep/normalize.py +71 -11
  4. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/prep/phase.py +2 -1
  5. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/prep/stripe.py +2 -1
  6. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/recon/algorithm.py +2 -2
  7. {httomolibgpu-5.5 → httomolibgpu-5.6/httomolibgpu.egg-info}/PKG-INFO +1 -1
  8. {httomolibgpu-5.5 → httomolibgpu-5.6}/LICENSE +0 -0
  9. {httomolibgpu-5.5 → httomolibgpu-5.6}/MANIFEST.in +0 -0
  10. {httomolibgpu-5.5 → httomolibgpu-5.6}/README.rst +0 -0
  11. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/__init__.py +0 -0
  12. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/__init__.py +0 -0
  13. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/calc_metrics.cu +0 -0
  14. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/center_360_shifts.cu +0 -0
  15. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/generate_mask.cu +0 -0
  16. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/median_kernel.cu +0 -0
  17. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/raven_filter.cu +0 -0
  18. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/remove_nan_inf.cu +0 -0
  19. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/cuda_kernels/remove_stripe_fw.cu +0 -0
  20. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/cupywrapper.py +0 -0
  21. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/misc/__init__.py +0 -0
  22. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/misc/corr.py +0 -0
  23. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/misc/denoise.py +0 -0
  24. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/misc/morph.py +0 -0
  25. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/misc/utils.py +0 -0
  26. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/prep/__init__.py +0 -0
  27. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/prep/alignment.py +0 -0
  28. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/recon/__init__.py +0 -0
  29. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/recon/_phase_cross_correlation.py +0 -0
  30. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu/recon/rotation.py +0 -0
  31. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu.egg-info/SOURCES.txt +0 -0
  32. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu.egg-info/dependency_links.txt +0 -0
  33. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu.egg-info/requires.txt +0 -0
  34. {httomolibgpu-5.5 → httomolibgpu-5.6}/httomolibgpu.egg-info/top_level.txt +0 -0
  35. {httomolibgpu-5.5 → httomolibgpu-5.6}/pyproject.toml +0 -0
  36. {httomolibgpu-5.5 → httomolibgpu-5.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: httomolibgpu
3
- Version: 5.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
@@ -33,7 +33,6 @@ __all__ = [
33
33
 
34
34
  from httomolibgpu.misc.utils import (
35
35
  __check_variable_type,
36
- __check_if_data_3D_array,
37
36
  __check_if_data_correct_type,
38
37
  )
39
38
 
@@ -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
- cutoff: Union[float, int] = 10.0,
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
- cutoff : float,int
70
- Permitted maximum value for the normalised data.
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(cutoff, [int, float], "cutoff", [], methods_name)
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 > cutoff) v = cutoff;\n"
118
- kernel += "if (v < -cutoff) v = cutoff;\n"
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 cutoff",
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
- normalisation_kernel(data, flat0, dark0, float32(cutoff), out)
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
 
@@ -22,7 +22,6 @@
22
22
 
23
23
  import numpy as np
24
24
  from httomolibgpu import cupywrapper
25
- from tomobar.supp.memory_estimator_helpers import DeviceMemStack
26
25
 
27
26
  cp = cupywrapper.cp
28
27
  cupy_run = cupywrapper.cupy_run
@@ -30,6 +29,8 @@ next_fast_len = cupywrapper.next_fast_len
30
29
 
31
30
  from unittest.mock import Mock
32
31
 
32
+ from tomobar.supp.memory_estimator_helpers import DeviceMemStack
33
+
33
34
  if cupy_run:
34
35
  from cupyx.scipy.fft import fft2, ifft2, fftshift
35
36
  from cupyx.scipy.fftpack import get_fft_plan
@@ -29,8 +29,9 @@ cupy_run = cupywrapper.cupy_run
29
29
 
30
30
  from unittest.mock import Mock
31
31
 
32
+ from tomobar.supp.memory_estimator_helpers import DeviceMemStack
33
+
32
34
  if cupy_run:
33
- from tomobar.supp.memory_estimator_helpers import DeviceMemStack
34
35
  from cupyx.scipy.ndimage import median_filter, binary_dilation, uniform_filter1d
35
36
  from cupyx.scipy.fft import fft2, ifft2, fftshift
36
37
  from cupyx.scipy.fftpack import get_fft_plan
@@ -27,9 +27,9 @@ cp = cupywrapper.cp
27
27
  cupy_run = cupywrapper.cupy_run
28
28
 
29
29
  from unittest.mock import Mock
30
+ from tomobar.supp.memory_estimator_helpers import DeviceMemStack
30
31
 
31
32
  if cupy_run:
32
- from tomobar.supp.memory_estimator_helpers import DeviceMemStack
33
33
  from tomobar.methodsDIR import RecToolsDIR
34
34
  from tomobar.methodsDIR_CuPy import RecToolsDIRCuPy
35
35
  from tomobar.methodsIR_CuPy import RecToolsIRCuPy
@@ -654,7 +654,7 @@ def ADMM3d_tomobar(
654
654
  """
655
655
  An Alternating Direction Method of Multipliers method with various types of regularisation or
656
656
  denoising operations :cite:`kazantsev2019ccpi` (currently accepts ROF_TV and PD_TV regularisations only).
657
- For more information see :ref:`_method_ADMM3d_tomobar`.
657
+ For more information see :ref:`method_ADMM3d_tomobar`.
658
658
 
659
659
  Parameters
660
660
  ----------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: httomolibgpu
3
- Version: 5.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