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

STIR.AcquisitionSensitivityModel.[un]normalise does not catch std::runtime_error thrown by STIR causing SIRF crash #1298

Open
KrisThielemans opened this issue Jan 17, 2025 · 3 comments
Assignees

Comments

@KrisThielemans
Copy link
Member

KrisThielemans commented Jan 17, 2025

stir.BinNormalisation.apply etc can throw exceptions (e.g. when not being able to write to file in the example below). They are currently not caught, see e.g. here, but there are many other places),
leading to python just exiting:

>>> m=sirf.STIR.AcquisitionData('SIRFmultfactors_withatn_3.hs')
>>> asm.set_up(p)
>>> xx=asm.unnormalise(p)

WARNING: write_data: error after writing to stream.


ERROR: ProjDataFromStream::set_viewgram: viewgram (view=0, segment=-11, timing_pos=-5) corrupted due to problems with writing or the scale factor (out of disk space?)
terminate called after throwing an instance of 'std::runtime_error'
  what():  ProjDataFromStream::set_viewgram: viewgram (view=0, segment=-11, timing_pos=-5) corrupted due to problems with writing or the scale factor (out of disk space?)
Aborted
$ bash>

Looks like we need to TRY...CATCH stuff around these calls.

@evgueni-ovtchinnikov
Copy link
Contributor

@KrisThielemans can I have your Python script and your data please so I could reproduce the crash?

@KrisThielemans
Copy link
Member Author

sorry, as it crashed, I don't have the history anymore, but essentially

p = pet.AcquisitionData('some-read-only.hs')
n = pet.AcquisitionData('norm.hs')
asm= pet.AcquisitionSensitivityModel(n)
n.set_up(p)
asm.unnormalise(p)

@evgueni-ovtchinnikov
Copy link
Contributor

n.set_up(p) is obviously a mistake - should be asm.set_up(p)

error messages are missing in asm.[un]normalise methods of AcquisitionSensitivityModel, which cannot be applied to a read-only object (there are alternative forward/invert methods that return the [un]normalised AcquisitionData object)

will do a PR now

@evgueni-ovtchinnikov evgueni-ovtchinnikov changed the title STIR.AcquisitionSensitivityModel.forward etc can crash python STIR.AcquisitionSensitivityModel.[un]normalise does not catch std::runtime_error thrown by STIR causing SIRF crash Feb 27, 2025
@evgueni-ovtchinnikov evgueni-ovtchinnikov changed the title STIR.AcquisitionSensitivityModel.[un]normalise does not catch std::runtime_error thrown by STIR causing SIRF crash STIR.AcquisitionSensitivityModel.[un]normalise does not catch std::runtime_error thrown by STIR causing SIRF crash Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants