Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to accelerate PET algebra tests for larger data #1027

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 43 additions & 13 deletions src/xSTIR/pSTIR/tests/test_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,30 @@ def tearDown(self):
class TestSTIRAcquisitionDataAlgebraFile(unittest.TestCase, TestDataContainerAlgebra):

def setUp(self):
path = os.path.join(
examples_data_path('PET'), 'thorax_single_slice', 'template_sinogram.hs')
self.set_storage_scheme()
sirf_path = os.environ.get('SIRF_PATH')
data_path = os.path.join(sirf_path, 'tests', 'data.hs')
if os.path.exists(data_path):
print('reading data from %s' % data_path)
data = pet.AcquisitionData(data_path)
self.image1 = data.get_uniform_copy(0)
self.image2 = data.get_uniform_copy(0)
self.set_storage_scheme()
return
path = os.path.join(examples_data_path('PET'),
'mMR', 'mMR_template_span11_small.hs')
# 'thorax_single_slice', 'template_sinogram.hs')
if os.path.exists(path):
template = pet.AcquisitionData(path)
self.image1 = template.get_uniform_copy(0)
self.image2 = template.get_uniform_copy(0)
# assert False
self.set_storage_scheme()


print(template.dimensions())
data = template.get_uniform_copy(0)
data = data.rebin(3, num_views_to_combine=6, num_tang_poss_to_trim=200)
print('rebinned to ', data.dimensions())
self.image1 = data
self.image2 = data.get_uniform_copy(0)
print('saving data to %s' % data_path)
self.image1.write(data_path)

def tearDown(self):
pass

Expand All @@ -63,16 +77,32 @@ def test_division_by_datacontainer_zero(self):


class TestSTIRAcquisitionDataAlgebraMemory(unittest.TestCase, TestDataContainerAlgebra):

def setUp(self):
pet.AcquisitionData.set_storage_scheme('file')
path = os.path.join(
examples_data_path('PET'), 'thorax_single_slice', 'template_sinogram.hs')
sirf_path = os.environ.get('SIRF_PATH')
data_path = os.path.join(sirf_path, 'tests', 'data.hs')
if os.path.exists(data_path):
print('reading data from %s' % data_path)
data = pet.AcquisitionData(data_path)
self.image1 = data.get_uniform_copy(0)
self.image2 = data.get_uniform_copy(0)
return
path = os.path.join(examples_data_path('PET'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. I didn't check current run-time.

Where does tests/data.hs sit? Is it checked in ? (I didn't check)

testing time is now 14 sec

data.hs and data.s are created, if not present, in SIRF/tests by the first test - do not know how to delete them after all tests finished (CMake can, I presume?)

not used?

sorry, do not get what you refer to

'mMR', 'mMR_template_span11_small.hs')
# 'thorax_single_slice', 'template_sinogram.hs')
if os.path.exists(path):
template = pet.AcquisitionData(path)
self.image1 = template.get_uniform_copy(0)
self.image2 = template.get_uniform_copy(0)
# assert False
print(template.dimensions())
data = template.get_uniform_copy(0)
data = data.rebin(3, num_views_to_combine=6, num_tang_poss_to_trim=200)
print('rebinned to ', data.dimensions())
self.image1 = data.get_uniform_copy(0)
self.image2 = data.get_uniform_copy(0)
pet.AcquisitionData.set_storage_scheme('memory')
print('saving data to %s' % data_path)
self.image1.write(data_path)

def test_division_by_datacontainer_zero(self):
# skip this test as currently cSIRF doesn't throw
pass