Skip to content

Commit

Permalink
replaced the template for PET algebra testing with a smaller one, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
evgueni-ovtchinnikov committed Dec 9, 2021
1 parent 02b25e2 commit bb1c437
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/xSTIR/pSTIR/tests/test_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ def tearDown(self):
class TestSTIRAcquisitionDataAlgebraFile(unittest.TestCase, TestDataContainerAlgebra):

def setUp(self):
if os.path.exists(os.path.join(
examples_data_path('PET'), 'mMR', 'mMR_template_span11_small.hs')):

template = pet.AcquisitionData(os.path.join(
examples_data_path('PET'), 'mMR', 'mMR_template_span11_small.hs')
)

path = os.path.join(
examples_data_path('PET'), '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
Expand All @@ -68,17 +65,14 @@ def test_division_by_datacontainer_zero(self):
class TestSTIRAcquisitionDataAlgebraMemory(unittest.TestCase, TestDataContainerAlgebra):
def setUp(self):
pet.AcquisitionData.set_storage_scheme('file')
if os.path.exists(os.path.join(
examples_data_path('PET'), 'mMR', 'mMR_template_span11_small.hs')):

template = pet.AcquisitionData(os.path.join(
examples_data_path('PET'), 'mMR', 'mMR_template_span11_small.hs')
)

path = os.path.join(
examples_data_path('PET'), 'thorax_single_slice', 'template_sinogram.hs')
if os.path.exists(path):
template = pet.AcquisitionData(path)

This comment has been minimized.

Copy link
@KrisThielemans

KrisThielemans Dec 9, 2021

Member

is it still fast enough if we keep these to the mMR? Reason I'm asking is that the data organisation for 3D PET is a lot more complicated than for a 2D single slice, so the test is stronger with the 3D case. The InMemory tests should be quite a lot faster than the File ones, so this is possibly still feasible

This comment has been minimized.

Copy link
@evgueni-ovtchinnikov

evgueni-ovtchinnikov Dec 10, 2021

Author Contributor

@KrisThielemans in-memory testing on mMR_template_span11_small.hs takes ~30 sec on my laptop (in-file takes ~110 sec)

This comment has been minimized.

Copy link
@KrisThielemans

KrisThielemans Dec 10, 2021

Member

oh well. still quite slow then. Could then use rebin with e.g. num_tang_poss_to_trim=100. I suppose once we do that, we could probably do it is well for the File one. sorry (do you have any idea how many algebraic operations this is running?)

This comment has been minimized.

Copy link
@evgueni-ovtchinnikov

evgueni-ovtchinnikov Dec 10, 2021

Author Contributor

@KrisThielemans what value should I set num_segments_to_combine to? I tried 1, 3, 5, 9 - all failed

This comment has been minimized.

Copy link
@KrisThielemans

KrisThielemans Dec 10, 2021

Member

ah weird. 1 and 3 should have worked I think. I would recommend 1 (i.e. no additional compression, as this is already data with only 3 segments). What is the error that you're getting?

This comment has been minimized.

Copy link
@evgueni-ovtchinnikov

evgueni-ovtchinnikov Dec 10, 2021

Author Contributor
before rebin:  (1, 357, 126, 344)

WARNING: read_data: error after reading from stream.

ERROR: ProjDataFromStream: error reading data

relevant piece of code:

        path = os.path.join(
            examples_data_path('PET'), 'mMR', 'mMR_template_span11_small.hs')
        if os.path.exists(path):
            template = pet.AcquisitionData(path)
            print('before rebin: ', template.dimensions())
            template = template.rebin(1, num_tang_poss_to_trim=100)
            print('after rebin: ', template.dimensions())

happens with both storage schemes

This comment has been minimized.

Copy link
@KrisThielemans

KrisThielemans Dec 10, 2021

Member

sure. can't rebin template data. one way around it would be to create a new AcquisitionData first from the template, and rebin that

This comment has been minimized.

Copy link
@evgueni-ovtchinnikov

evgueni-ovtchinnikov Dec 10, 2021

Author Contributor

oops, forgot about templates being empty!

however, tests time increased now to 52 sec, apparently because of rebinning time added

This comment has been minimized.

Copy link
@KrisThielemans

KrisThielemans Dec 10, 2021

Member

ah, do we rebin every time then? Anyway, starts to feel like you've wasted too much time on this already...

self.image1 = template.get_uniform_copy(0)
self.image2 = template.get_uniform_copy(0)
# assert False
pet.AcquisitionData.set_storage_scheme('memory')
def test_division_by_datacontainer_zero(self):
# skip this test as currently cSIRF doesn't throw
pass
pass

0 comments on commit bb1c437

Please sign in to comment.