Skip to content

Commit 8fd273b

Browse files
committed
fix for stripe titarenko
1 parent 69baaf5 commit 8fd273b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_remove_stripe_ti_on_data(data, flats, darks):
3636

3737
@pytest.mark.parametrize("angles", [180, 181])
3838
@pytest.mark.parametrize("det_x", [11, 18])
39-
@pytest.mark.parametrize("det_y", [5, 7])
39+
@pytest.mark.parametrize("det_y", [5, 7, 8])
4040
def test_remove_stripe_ti_dims_change(angles, det_y, det_x):
4141
data = cp.random.random_sample(size=(angles, det_y, det_x)).astype(cp.float32) * 2.0
4242
corrected_data = remove_stripe_ti(data.copy())

0 commit comments

Comments
 (0)