[SyneRBI/SIRF] Trying to accelerate PET algebra tests for larger data (PR #1027)

2 views
Skip to first unread message

Evgueni Ovtchinnikov

unread,
Dec 14, 2021, 11:53:35 AM12/14/21
to SyneRBI/SIRF, Subscribed

trying to fix #1013 for larger data


You can view, comment on, or merge this pull request online at:

  https://github.com/SyneRBI/SIRF/pull/1027

Commit Summary

  • 0565a50 trying to accelerate tests for larger data

File Changes

(1 file)

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Kris Thielemans

unread,
Dec 14, 2021, 5:22:44 PM12/14/21
to SyneRBI/SIRF, Subscribed

@KrisThielemans commented on this pull request.

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

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


In src/xSTIR/pSTIR/tests/test_algebra.py:

>      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'),

not used?

Edoardo Pasca

unread,
Dec 15, 2021, 3:31:17 AM12/15/21
to SyneRBI/SIRF, Subscribed

I think setUp should just rebin the data as you propose:

        self.set_storage_scheme()
        sirf_path = os.environ.get('SIRF_PATH')
        
        path = os.path.join(examples_data_path('PET'),
                            'mMR', 'mMR_template_span11_small.hs')
        
        template = pet.AcquisitionData(path)
        # 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)

Also the file data.hs that you create the first time you run the unit test (actually setUp) should be deleted at the end of the test, during tearDown, making the trick not really viable.

Edoardo Pasca

unread,
Dec 15, 2021, 3:34:27 AM12/15/21
to SyneRBI/SIRF, Subscribed

@paskino requested changes on this pull request.

See my comment #1027 (comment)

Evgueni Ovtchinnikov

unread,
Dec 15, 2021, 5:25:12 AM12/15/21
to SyneRBI/SIRF, Subscribed

@evgueni-ovtchinnikov commented on this pull request.


In src/xSTIR/pSTIR/tests/test_algebra.py:

>      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'),

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

Evgueni Ovtchinnikov

unread,
Dec 15, 2021, 5:44:55 AM12/15/21
to SyneRBI/SIRF, Subscribed

I think setUp should just rebin the data

rebinning in each test takes twice as long (30 sec vs 14 sec)

admittedly my fix is quite ugly, but I do not understand how unittest works, so cannot suggest anything else at the moment

Edoardo Pasca

unread,
Dec 15, 2021, 6:18:50 AM12/15/21
to SyneRBI/SIRF, Subscribed

Each unit tests will be preceded by a call to setUp and call to tearDown. The idea here is to create whatever temporary thing required for the test and clear it away even if the test fails.

Your fix is functional, but does go against the whole idea of setUp and tearDown. Why not add small PET AcquisitionData and ImageData files in the repository?

Edoardo Pasca

unread,
Jan 17, 2022, 4:14:35 AM1/17/22
to SyneRBI/SIRF, Subscribed

https://github.com/SyneRBI/SIRF/blob/0565a5085983228d7e30f39718ff267983632792/src/xSTIR/pSTIR/tests/test_algebra.py#L46

The file created during the first unittest will end up in ${SIRF_PATH}/tests, which is in the source directory. Does this mean that git will not like it when running a second time?

If so, I believe we should delete the data.hs file once done with the tests. I'm not so sure if there is a single test class created to keep the count of how many tests have been run.

A possible solution is to be pragmatic and think that this file will be used by the PET Python algebra only and we can create it in the build directory so that we reduce the pollution of the source and install directories to a minimum. I'd be in favour of this solution.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1027/c1014297290@github.com>

Edoardo Pasca

unread,
Feb 4, 2025, 1:14:51 PM2/4/25
to SyneRBI/SIRF, Subscribed

I suggest to close this as issue has been fixed by using a smaller template for the test data.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1027/c2634721956@github.com>

Kris Thielemans

unread,
Feb 5, 2025, 2:34:05 AM2/5/25
to SyneRBI/SIRF, Subscribed

fine for me


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1027/c2635931246@github.com>

Edoardo Pasca

unread,
Feb 13, 2025, 5:43:36 AM2/13/25
to SyneRBI/SIRF, Subscribed

Closed #1027.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1027/issue_event/16294440051@github.com>

Edoardo Pasca

unread,
Feb 13, 2025, 5:43:37 AM2/13/25
to SyneRBI/SIRF, Subscribed

Closing as completed by bb1c437


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1027/c2656195004@github.com>

Reply all
Reply to author
Forward
0 new messages