Skip to content
Snippets Groups Projects
Commit 23b05f9b authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Merge branch 'fix_halftomo_backproj' into 'master'

Fix halftomo plain backprojection when using numpy array

Closes #570

See merge request tomotools/nabu!543
parents 6f5b6f19 c6aa4b17
No related branches found
No related tags found
No related merge requests found
Pipeline #219712 failed
......@@ -354,7 +354,7 @@ class BackprojectorBase:
def backproj(self, sino, output=None, do_checks=True):
if self.halftomo and self.rot_center < self.dwidth:
self.sino_mult.prepare_sino(sino)
sino = self.sino_mult.prepare_sino(sino)
self._transfer_to_texture(sino)
d_slice = self._set_output(output, check=do_checks)
self._set_kernel_slice_arg(d_slice)
......
......@@ -99,6 +99,32 @@ class TestHalftomo:
rot_center = sino.shape[-1] - 1 - self.rot_center
return self.test_halftomo_right_side(config, sino=sino, rot_center=rot_center)
def test_halftomo_plain_backprojection(self, config):
backprojector = self._get_backprojector(
config,
self.sino.shape,
rot_center=self.rot_center,
halftomo=True,
padding_mode="edges",
extra_options={"centered_axis": True},
)
d_sino_filtered = backprojector.sino_filter.filter_sino(self.sino) # device array
h_sino_filtered = d_sino_filtered.get()
reference_fbp = backprojector.fbp(self.sino)
def _check(rec, array_type):
assert (
np.max(np.abs(rec - reference_fbp)) < 1e-7
), "Something wrong with halftomo backproj using %s array and configuration %s" % (array_type, str(config))
# Test with device array
rec_from_already_filtered_sino = backprojector.backproj(d_sino_filtered)
_check(rec_from_already_filtered_sino, "device")
# Test with numpy array
rec_from_already_filtered_sino = backprojector.backproj(h_sino_filtered)
_check(rec_from_already_filtered_sino, "numpy")
def test_halftomo_cor_outside_fov(self, config):
sino = np.ascontiguousarray(self.sino[:, : self.sino.shape[-1] // 2])
backprojector = self._get_backprojector(config, sino.shape, rot_center=self.rot_center, halftomo=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment