Skip to content

Commit

Permalink
TST: Create tests for accelerated SIRT and MLEM reconstruction algori…
Browse files Browse the repository at this point in the history
…thms (#487)

Previously, there have not been any methods to test that CUDA enabled TomoPy has been built properly. This introduces one unit test for each of the two CUDA eligible reconstruction algorithms, SIRT and MLEM.

Co-authored-by: Daniel Ching <carterbox@users.noreply.github.com>
  • Loading branch information
dreycenfoiles and carterbox committed Jun 5, 2020
1 parent 27926c0 commit ec54a1e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Binary file added test/test_tomopy/test_data/mlem_accel.npy
Binary file not shown.
Binary file added test/test_tomopy/test_data/sirt_accel.npy
Binary file not shown.
29 changes: 17 additions & 12 deletions test/test_tomopy/test_recon/test_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ def test_gridrec(self):
recon(self.prj, self.ang, algorithm='gridrec', filter_name='parzen'),
read_file('gridrec_parzen.npy'), rtol=1e-2)
assert_allclose(
recon(self.prj, self.ang, algorithm='gridrec', filter_name='butterworth'),
recon(self.prj, self.ang, algorithm='gridrec',
filter_name='butterworth'),
read_file('gridrec_butterworth.npy'), rtol=1e-2)

def test_mlem(self):
# FIXME: Make separate tests for each back-end
os.environ["TOMOPY_USE_C_MLEM"] = "1"
assert_allclose(
recon(self.prj, self.ang, algorithm='mlem', num_iter=4),
read_file('mlem.npy'), rtol=1e-2)
result = recon(self.prj, self.ang, algorithm='mlem', num_iter=4)
assert_allclose(result, read_file('mlem.npy'), rtol=1e-2)

def test_mlem_accel(self):
result = recon(self.prj, self.ang, algorithm='mlem', num_iter=4,
accelerated=True)
assert_allclose(result, read_file('mlem_accel.npy'), rtol=1e-2)

def test_osem(self):
assert_allclose(
Expand Down Expand Up @@ -148,11 +151,13 @@ def test_pml_quad(self):
read_file('pml_quad.npy'), rtol=1e-2)

def test_sirt(self):
# FIXME: Make separate tests for each back-end
os.environ["TOMOPY_USE_C_SIRT"] = "1"
r_sirt = recon(self.prj, self.ang, algorithm='sirt', num_iter=4)
c_sirt = read_file('sirt.npy')
assert_allclose(r_sirt, c_sirt, rtol=1e-2)
result = recon(self.prj, self.ang, algorithm='sirt', num_iter=4)
assert_allclose(result, read_file('sirt.npy'), rtol=1e-2)

def test_sirt_accel(self):
result = recon(self.prj, self.ang, algorithm='sirt',
num_iter=4, accelerated=True)
assert_allclose(result, read_file('sirt_accel.npy'), rtol=1e-2)

def test_tv(self):
assert_allclose(
Expand All @@ -167,4 +172,4 @@ def test_grad(self):
def test_tikh(self):
assert_allclose(
recon(self.prj, self.ang, algorithm='tikh', num_iter=4),
read_file('tikh.npy'), rtol=1e-2)
read_file('tikh.npy'), rtol=1e-2)

0 comments on commit ec54a1e

Please sign in to comment.