Skip to content

Commit 370c50f

Browse files
authored
Merge branch 'main' into iterative_reg
2 parents febe9cf + 6c84615 commit 370c50f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

httomolibgpu/prep/stripe.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def remove_stripe_ti(
143143

144144
_, _, dx_orig = data.shape
145145
if (dx_orig % 2) != 0:
146-
# the horizontal detector size is odd, data needs to be padded/cropped, for now raising the error
147-
raise ValueError("The horizontal detector size must be even")
146+
# if the horizontal detector size is odd, the data needs to be padded
147+
data = cp.pad(data, ((0, 0), (0, 0), (0, 1)), mode="edge")
148148

149149
gamma = beta * ((1 - beta) / (1 + beta)) ** cp.abs(
150150
cp.fft.fftfreq(data.shape[-1]) * data.shape[-1]
@@ -154,7 +154,11 @@ def remove_stripe_ti(
154154
v = v - v[:, 0:1]
155155
v = cp.fft.irfft(cp.fft.rfft(v) * cp.fft.rfft(gamma)).astype(data.dtype)
156156
data[:] += v
157-
return data
157+
if (dx_orig % 2) != 0:
158+
# unpad
159+
return data[:, :, :-1]
160+
else:
161+
return data
158162

159163

160164
######## Optimized version for Vo-all ring removal in tomopy########

tests/test_prep/test_stripe.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ def test_remove_stripe_ti_on_data(data, flats, darks):
3434
assert data_after_stripe_removal.dtype == np.float32
3535

3636

37+
@pytest.mark.parametrize("angles", [180, 181])
38+
@pytest.mark.parametrize("det_x", [11, 18])
39+
@pytest.mark.parametrize("det_y", [5, 7, 8])
40+
def test_remove_stripe_ti_dims_change(angles, det_y, det_x):
41+
data = cp.random.random_sample(size=(angles, det_y, det_x)).astype(cp.float32) * 2.0
42+
corrected_data = remove_stripe_ti(data.copy())
43+
assert corrected_data.shape == (angles, det_y, det_x)
44+
45+
3746
def test_stripe_removal_sorting_cupy(data, flats, darks):
3847
# --- testing the CuPy port of TomoPy's implementation ---#
3948
data = normalize(data, flats, darks, cutoff=10, minus_log=True)

0 commit comments

Comments
 (0)