Skip to content

Commit 760512a

Browse files
authored
Merge branch 'main' into datavalidator
2 parents ee78f0c + 4d7ad21 commit 760512a

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

httomolibgpu/recon/algorithm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ def LPRec3d_tomobar(
200200
data: cp.ndarray,
201201
angles: np.ndarray,
202202
center: Optional[float] = None,
203+
filter_type: str = "shepp",
204+
filter_freq_cutoff: float = 1.0,
203205
recon_size: Optional[int] = None,
204206
recon_mask_radius: Optional[float] = 0.95,
205207
neglog: bool = False,
@@ -217,6 +219,10 @@ def LPRec3d_tomobar(
217219
An array of angles given in radians.
218220
center : float, optional
219221
The center of rotation (CoR).
222+
filter_type : str
223+
Filter type, the accepted strings are: none, ramp, shepp, cosine, cosine2, hamming, hann, parzen.
224+
filter_freq_cutoff : float
225+
Cutoff frequency parameter for a filter. The higher values increase the resolution but also amplify the noise.
220226
recon_size : int, optional
221227
The [recon_size, recon_size] shape of the reconstructed slice in pixels.
222228
By default (None), the reconstructed size will be the dimension of the horizontal detector.
@@ -242,6 +248,8 @@ def LPRec3d_tomobar(
242248
_take_neg_log(data) if neglog else data,
243249
recon_mask_radius=recon_mask_radius,
244250
data_axes_labels_order=input_data_axis_labels,
251+
filter_type=filter_type,
252+
cutoff_freq=filter_freq_cutoff,
245253
)
246254
cp._default_memory_pool.free_all_blocks()
247255
return cp.require(cp.swapaxes(reconstruction, 0, 1), requirements="C")

zenodo-tests/test_recon/test_algorithm.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import cupy as cp
23
import numpy as np
34
import pytest
@@ -71,7 +72,36 @@ def test_reconstruct_FBP3d_tomobar_i12_dataset1(i12_dataset1):
7172
assert recon_data.shape == (2560, 50, 2560)
7273

7374

74-
def test_reconstruct_LP_REC_i13_dataset1(i13_dataset1):
75+
def test_reconstruct_LPRec3d_tomobar_i12_dataset1(i12_dataset1):
76+
force_clean_gpu_memory()
77+
projdata = i12_dataset1[0]
78+
angles = i12_dataset1[1]
79+
flats = i12_dataset1[2]
80+
darks = i12_dataset1[3]
81+
del i12_dataset1
82+
83+
data_normalised = normalize(projdata, flats, darks, minus_log=True)
84+
data_normalised_cut = data_normalised[:, 5:8, :]
85+
del flats, darks, projdata, data_normalised
86+
force_clean_gpu_memory()
87+
88+
recon_data = LPRec3d_tomobar(
89+
data_normalised_cut,
90+
np.deg2rad(angles),
91+
center=1253.75,
92+
filter_type="shepp",
93+
filter_freq_cutoff=1.0,
94+
)
95+
assert recon_data.flags.c_contiguous
96+
recon_data = recon_data.get()
97+
assert isclose(np.sum(recon_data), 8973.755, abs_tol=10**-3)
98+
assert pytest.approx(np.max(recon_data), rel=1e-3) == 0.00640
99+
assert pytest.approx(np.min(recon_data), rel=1e-3) == -0.00617
100+
assert recon_data.dtype == np.float32
101+
assert recon_data.shape == (2560, 3, 2560)
102+
103+
104+
def test_reconstruct_LPRec_tomobar_i13_dataset1(i13_dataset1):
75105
force_clean_gpu_memory()
76106
projdata = i13_dataset1[0]
77107
angles = i13_dataset1[1]
@@ -102,11 +132,15 @@ def test_reconstruct_LP_REC_i13_dataset1(i13_dataset1):
102132
data=stiched_data_180degrees,
103133
angles=np.deg2rad(angles[0:3000]),
104134
center=2322.08,
135+
filter_type="shepp",
136+
filter_freq_cutoff=1.0,
105137
)
106138

107139
assert recon_data.flags.c_contiguous
108140
recon_data = recon_data.get()
109-
assert isclose(np.sum(recon_data), 620.856, abs_tol=10**-3)
141+
assert isclose(np.sum(recon_data), 1241.859, abs_tol=10**-3)
142+
assert pytest.approx(np.max(recon_data), rel=1e-3) == 0.00823
143+
assert pytest.approx(np.min(recon_data), rel=1e-3) == -0.00656
110144
assert recon_data.dtype == np.float32
111145
assert recon_data.shape == (4646, 1, 4646)
112146

@@ -166,11 +200,15 @@ def test_reconstruct_LPRec3d_tomobar_i13_dataset2(i13_dataset2):
166200
data=data_normalised,
167201
angles=np.deg2rad(angles),
168202
center=1286.25,
203+
filter_type="shepp",
204+
filter_freq_cutoff=1.0,
169205
)
170206
assert recon_data.flags.c_contiguous
171207
recon_data = recon_data.get()
172208

173-
assert isclose(np.sum(recon_data), 2044.953, abs_tol=10**-3)
209+
assert isclose(np.sum(recon_data), 4095.6257, abs_tol=10**-3)
210+
assert pytest.approx(np.max(recon_data), rel=1e-3) == 0.0105672
211+
assert pytest.approx(np.min(recon_data), rel=1e-3) == -0.00839
174212
assert recon_data.dtype == np.float32
175213
assert recon_data.shape == (2560, 10, 2560)
176214

0 commit comments

Comments
 (0)