Skip to content

Commit

Permalink
FBP split processing respect panel origin
Browse files Browse the repository at this point in the history
  • Loading branch information
gfardell committed Jul 20, 2023
1 parent bbd97ca commit 0d100c6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
28 changes: 23 additions & 5 deletions Wrappers/Python/cil/recon/FBP.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,12 @@ def _setup_PO_for_chunks(self, num_slices):
self.data_slice = ag_slice.allocate()
self.operator = self._PO_class(ig_slice,ag_slice)

def _process_chunk(self, i, step, out):
def _process_chunk(self, i, step):
self.data_slice.fill(np.squeeze(self.input.array[:,i:i+step,:]))
if not self.filter_inplace:
self._pre_filtering(self.data_slice)
out.array[i:i+step,:,:] = self.operator.adjoint(self.data_slice).array[:]

return self.operator.adjoint(self.data_slice).array


def run(self, out=None, verbose=1):
Expand Down Expand Up @@ -569,15 +570,32 @@ def run(self, out=None, verbose=1):
#process dataset by requested chunk size
self._setup_PO_for_chunks(self.slices_per_chunk)
for i in range(0, tot_slices-remainder, self.slices_per_chunk):
self._process_chunk(i, self.slices_per_chunk, ret)

if 'bottom' in self.acquisition_geometry.config.panel.origin:
start = i
end = i + self.slices_per_chunk
else:
start = tot_slices -i - self.slices_per_chunk
end = tot_slices - i

ret.array[start:end,:,:] = self._process_chunk(i, self.slices_per_chunk)

if verbose:
pbar.update(1)

#process excess rows
if remainder:
i = tot_slices-remainder
self._setup_PO_for_chunks(remainder)
self._process_chunk(i, remainder, ret)

if 'bottom' in self.acquisition_geometry.config.panel.origin:
start = tot_slices-remainder
end = tot_slices
else:
start = 0
end = remainder

ret.array[start:end,:,:] = self._process_chunk(i, remainder)

if verbose:
pbar.update(1)

Expand Down
23 changes: 22 additions & 1 deletion Wrappers/Python/test/test_reconstructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def test_results_3D_astra(self):
def test_results_3D_split(self):

reconstructor = FBP(self.acq_data)
reconstructor.set_split_processing(1)
reconstructor.set_split_processing(8)

reco = reconstructor.run(verbose=0)
np.testing.assert_allclose(reco.as_array(), self.img_data.as_array(),atol=1e-3)
Expand All @@ -663,6 +663,27 @@ def test_results_3D_split(self):
np.testing.assert_allclose(reco.as_array(), reco2.as_array(), atol=1e-8)


@unittest.skipUnless(has_tigre and has_nvidia and has_ipp, "TIGRE or IPP not installed")
def test_results_3D_split_reverse(self):

acq_data = self.acq_data.copy()
acq_data.geometry.config.panel.origin = 'top-left'

reconstructor = FBP(acq_data)
reconstructor.set_split_processing(8)

expected_image = np.flip(self.img_data.as_array(),0)

reco = reconstructor.run(verbose=0)
np.testing.assert_allclose(reco.as_array(), expected_image,atol=1e-3)

reco2 = reco.copy()
reco2.fill(0)
reconstructor.run(out=reco2, verbose=0)
np.testing.assert_allclose(reco.as_array(), reco2.as_array(), atol=1e-8)



@unittest.skipUnless(has_tigre and has_nvidia and has_ipp, "TIGRE or IPP not installed")
def test_results_2D_tigre(self):

Expand Down

0 comments on commit 0d100c6

Please sign in to comment.