Skip to content

Commit 3ba8579

Browse files
committed
removing paganin savu related tests
1 parent a3ada6d commit 3ba8579

File tree

3 files changed

+5
-110
lines changed

3 files changed

+5
-110
lines changed

httomolibgpu/prep/phase.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"paganin_filter_tomopy",
4646
]
4747

48+
4849
##-------------------------------------------------------------##
4950
# Adaptation of retrieve_phase (Paganin filter) from TomoPy
5051
def paganin_filter_tomopy(
@@ -247,4 +248,4 @@ def _reciprocal_coord(pixel_size: float, num_grid: int) -> cp.ndarray:
247248
n = num_grid - 1
248249
rc = cp.arange(-n, num_grid, 2, dtype=cp.float32)
249250
rc *= 2 * math.pi / (n * pixel_size)
250-
return rc
251+
return rc

httomolibgpu/recon/algorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def FBP3d_tomobar(
152152
"""
153153
Perform Filtered Backprojection (FBP) reconstruction using ASTRA toolbox :cite:`van2016fast` and
154154
ToMoBAR :cite:`kazantsev2020tomographic` wrappers.
155-
This is a 3D recon from the CuPy array directly and using a custom built SINC filter for filtration in Fourier space,
155+
This is a 3D recon from the CuPy array directly and using a custom built SINC filter for filtration in Fourier space,
156156
see more in :ref:`method_FBP3d_tomobar`.
157157
158158
Parameters
@@ -166,7 +166,7 @@ def FBP3d_tomobar(
166166
detector_pad : int
167167
Detector width padding with edge values to remove circle/arc type artifacts in the reconstruction.
168168
filter_freq_cutoff : float
169-
Cutoff frequency parameter for the SINC filter, the lower values may produce better contrast but noisy reconstruction. The filter change will also affect the dynamic range of the reconstructed image.
169+
Cutoff frequency parameter for the SINC filter, the lower values may produce better contrast but noisy reconstruction. The filter change will also affect the dynamic range of the reconstructed image.
170170
recon_size : int, optional
171171
The [recon_size, recon_size] shape of the reconstructed slice in pixels.
172172
By default (None), the reconstructed size will be the dimension of the horizontal detector.

tests/test_prep/test_phase.py

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4,118 +4,12 @@
44
import numpy as np
55
import pytest
66
from cupy.cuda import nvtx
7-
from httomolibgpu.prep.phase import paganin_filter_savu, paganin_filter_tomopy
7+
from httomolibgpu.prep.phase import paganin_filter_tomopy
88
from numpy.testing import assert_allclose
99

1010
eps = 1e-6
1111

1212

13-
def test_paganin_savu_filter(data):
14-
# --- testing the Paganin filter on tomo_standard ---#
15-
filtered_data = paganin_filter_savu(data).get()
16-
17-
assert filtered_data.ndim == 3
18-
assert_allclose(np.mean(filtered_data), -770.5339, rtol=eps)
19-
assert_allclose(np.max(filtered_data), -679.80945, rtol=eps)
20-
21-
#: make sure the output is float32
22-
assert filtered_data.dtype == np.float32
23-
assert filtered_data.flags.c_contiguous
24-
25-
26-
def test_paganin_filter_savu_energy100(data):
27-
filtered_data = paganin_filter_savu(data, energy=100.0).get()
28-
29-
assert_allclose(np.mean(filtered_data), -778.61926, rtol=1e-05)
30-
assert_allclose(np.min(filtered_data), -808.9013, rtol=eps)
31-
32-
assert filtered_data.ndim == 3
33-
assert filtered_data.dtype == np.float32
34-
35-
36-
def test_paganin_filter_savu_padmean(data):
37-
filtered_data = paganin_filter_savu(data, pad_method="mean").get()
38-
39-
assert_allclose(np.mean(filtered_data), -765.3401, rtol=eps)
40-
assert_allclose(np.min(filtered_data), -793.68787, rtol=eps)
41-
# test a few other slices to ensure shifting etc is right
42-
assert_allclose(
43-
filtered_data[0, 50, 1:5],
44-
[-785.60736, -786.20215, -786.7521, -787.25494],
45-
rtol=eps,
46-
)
47-
assert_allclose(
48-
filtered_data[0, 50, 40:42], [-776.6436, -775.1906], rtol=eps, atol=1e-5
49-
)
50-
assert_allclose(
51-
filtered_data[0, 60:63, 90],
52-
[-737.75104, -736.6097, -735.49884],
53-
rtol=eps,
54-
atol=1e-5,
55-
)
56-
57-
58-
@pytest.mark.perf
59-
def test_paganin_filter_savu_performance(ensure_clean_memory):
60-
# Note: low/high and size values taken from sample2_medium.yaml real run
61-
62-
# this test needs ~20GB of memory with 1801 - we'll divide depending on GPU memory
63-
dev = cp.cuda.Device()
64-
mem_80percent = 0.8 * dev.mem_info[0]
65-
size = 1801
66-
required_mem = 20 * 1024 * 1024 * 1024
67-
if mem_80percent < required_mem:
68-
size = int(np.ceil(size / required_mem * mem_80percent))
69-
print(f"Using smaller size of ({size}, 5, 2560) due to memory restrictions")
70-
71-
data_host = np.random.random_sample(size=(size, 5, 2560)).astype(np.float32) * 2.0
72-
data = cp.asarray(data_host, dtype=np.float32)
73-
74-
# run code and time it
75-
# cold run first
76-
paganin_filter_savu(
77-
data,
78-
ratio=250.0,
79-
energy=53.0,
80-
distance=1.0,
81-
resolution=1.28,
82-
pad_y=100,
83-
pad_x=100,
84-
pad_method="edge",
85-
increment=0.0,
86-
)
87-
dev = cp.cuda.Device()
88-
dev.synchronize()
89-
90-
start = time.perf_counter_ns()
91-
nvtx.RangePush("Core")
92-
for _ in range(10):
93-
paganin_filter_savu(
94-
data,
95-
ratio=250.0,
96-
energy=53.0,
97-
distance=1.0,
98-
resolution=1.28,
99-
pad_y=100,
100-
pad_x=100,
101-
pad_method="edge",
102-
increment=0.0,
103-
)
104-
nvtx.RangePop()
105-
dev.synchronize()
106-
duration_ms = float(time.perf_counter_ns() - start) * 1e-6 / 10
107-
108-
assert "performance in ms" == duration_ms
109-
110-
111-
def test_paganin_filter_savu_1D_raises(ensure_clean_memory):
112-
_data = cp.ones(10)
113-
with pytest.raises(ValueError):
114-
paganin_filter_savu(_data)
115-
116-
_data = None #: free up GPU memory
117-
118-
11913
# paganin filter tomopy
12014
def test_paganin_filter_tomopy_1D_raises(ensure_clean_memory):
12115
_data = cp.ones(10)

0 commit comments

Comments
 (0)