Skip to content

Python: addition of as_array() and fill(numpy.ndarray)#1632

Merged
KrisThielemans merged 6 commits intoUCL:masterfrom
KrisThielemans:numpy_as_array
Oct 16, 2025
Merged

Python: addition of as_array() and fill(numpy.ndarray)#1632
KrisThielemans merged 6 commits intoUCL:masterfrom
KrisThielemans:numpy_as_array

Conversation

@KrisThielemans
Copy link
Copy Markdown
Collaborator

@KrisThielemans KrisThielemans commented Oct 14, 2025

This adds np_arr = stir_object.as_array() and stir_object.fill(np_arr) directly via SWIG. These should be faster than the stirextra functions, as they are implemented in C++.

Usage is the same as in SIRF, which makes it easier to convert SIRF to STIR Python.

@KrisThielemans
Copy link
Copy Markdown
Collaborator Author

KrisThielemans commented Oct 14, 2025

Current status: ProjDataInMemory::as_array() still missing, also more tests for its fill.

@markus-jehl @christanmod, want to give it a go? Would be good to have some timings on the difference with stirextra.to_numpy etc.

@KrisThielemans KrisThielemans marked this pull request as ready for review October 14, 2025 22:47
@KrisThielemans
Copy link
Copy Markdown
Collaborator Author

KrisThielemans commented Oct 14, 2025

This should be ready aside from:

  • clean-up history
  • test ProjData.as_array() (currently we test only ProjDataInMemory.as_array())
  • edit stirextra.to_numpy to use as_array() presumably
  • add release notes

Would still be great to get some info on timing

- adds C++/swig implementations of these functions in Array
- adds C++/swig implementation of fill(numpy.ndarray) for ProjDataInMemory
@KrisThielemans KrisThielemans added this to the v6.3 milestone Oct 14, 2025
@KrisThielemans KrisThielemans merged commit 65fb3ab into UCL:master Oct 16, 2025
12 checks passed
@KrisThielemans KrisThielemans deleted the numpy_as_array branch October 16, 2025 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant