SIRF icon indicating copy to clipboard operation
SIRF copied to clipboard

Contiguity checks for STIR image data

Open evgueni-ovtchinnikov opened this issue 7 months ago • 7 comments

  • fixes #1316
  • ~test demo script asarray.py provided~
  • ~requires STIR branch contiguous_Arrays (https://github.com/UCL/STIR/pull/1592)~

Checklist

  • [x] I have performed a self-review of my code
  • [ ] I have added docstrings/doxygen in line with the guidance in the developer guide
  • [ ] I have implemented unit tests that cover any new or modified functionality
  • [x] The code builds and runs on my machine
  • [ ] CHANGES.md has been updated with any functionality change

evgueni-ovtchinnikov avatar May 07 '25 13:05 evgueni-ovtchinnikov

Latest performance comparison (with this PR #1317 + https://github.com/UCL/STIR/pull/1592 + #1314) - the last column shows timings we can get with asarray.

test     sirf    as_array +   numpy  +   fill   =  total   asarray
x * 2  7.28e-02  5.21e-01 + 5.53e-03 + 5.18e-01 = 1.04e+00 8.37e-03
x + 2  7.87e-02  5.26e-01 + 5.76e-03 + 4.99e-01 = 1.03e+00 7.77e-03
x + y  9.43e-02  1.08e+00 + 6.31e-03 + 5.02e-01 = 1.59e+00 1.16e-02
x * y  1.11e-01  1.06e+00 + 6.85e-03 + 5.07e-01 = 1.57e+00 9.82e-03
x / y  1.28e-01  1.01e+00 + 7.28e-03 + 5.13e-01 = 1.53e+00 8.14e-03

evgueni-ovtchinnikov avatar May 07 '25 17:05 evgueni-ovtchinnikov

~10-15 times faster? Great!

KrisThielemans avatar May 07 '25 18:05 KrisThielemans

I just rebased this PR to be off master so it can be self-contained and easy to merge :)

I'll rebase #1314 afterwards.

casperdcl avatar May 08 '25 08:05 casperdcl

Might need this on AquisitionData too @KrisThielemans?

casperdcl avatar May 10 '25 10:05 casperdcl

I think in the need we need the array_interface stuff (and hence this property I guess) in DataContainer, defaulting to false. Overloaded in STIR.ImageData as currently done, and overloaded in STIR.AcquisitionDataInMemory to `true.

TBH, it is a somewhat strange property to have on DataContainer, as we'd be using it essentially to say "yup, you can have array interface access, and it happens to be that the underlying is contiguous, such that we can support it." Naming of the property is therefore probably a bit wrong.

KrisThielemans avatar May 10 '25 12:05 KrisThielemans

What about renaming contiguous to supports_array_view or so?

KrisThielemans avatar May 10 '25 15:05 KrisThielemans

makes sense to me... /CC @evgueni-ovtchinnikov ☝️

casperdcl avatar May 12 '25 14:05 casperdcl

Potentially @evgueni-ovtchinnikov implemented supports_array_view in the branch data-algebra-opt (#1318)

https://github.com/SyneRBI/SIRF/blob/fce31b7311df6ef3874159c22c49034fe73089b7/src/common/include/sirf/common/DataContainer.h#L65-L68

paskino avatar May 20 '25 13:05 paskino