[SyneRBI/SIRF] Implement adding Hessian diagonal in SIRF (PR #1370)

3 views
Skip to first unread message

Evgueni Ovtchinnikov

unread,
Jan 28, 2026, 10:13:38 AMJan 28
to SyneRBI/SIRF, Subscribed

Changes in this pull request

Testing performed

Related issues

Fixes #1369

Checklist before requesting a review

  • 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
  • The code builds and runs on my machine
  • CHANGES.md has been updated with any functionality change

Contribution Notes

Please read and adhere to the contribution guidelines.

Please tick the following:

  • The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in SIRF (the Work) under the terms and conditions of the Apache-2.0 License.

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

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

Commit Summary

File Changes

(1 file)

Patch Links:


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/1370@github.com>

Evgueni Ovtchinnikov

unread,
Jan 28, 2026, 12:32:05 PMJan 28
to SyneRBI/SIRF, Push

@evgueni-ovtchinnikov pushed 1 commit.

  • ae578b8 added constructor for xSTIR RDP from Gibbs RDP


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1370/before/0980bdd4dc393c943dfe5d810dc68c92d5d80e2d/after/ae578b8da4e5dfdb03493da0fb634d15bf4093a3@github.com>

Kris Thielemans

unread,
Jan 29, 2026, 8:12:05 AMJan 29
to SyneRBI/SIRF, Subscribed
KrisThielemans left a comment (SyneRBI/SIRF#1370)

I think the best strategy is to just use GibbsRelativeDifferencePenalty everywhere. It should be backwards compatible with RelativeDifferencePrior. @ColomboMatte0 is that correct? (we don't need the surrogate stuff here AFAIK)


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/1370/c3817605963@github.com>

Matteo Colombo

unread,
Jan 29, 2026, 11:36:51 AMJan 29
to SyneRBI/SIRF, Subscribed
ColomboMatte0 left a comment (SyneRBI/SIRF#1370)

It is backwards compatible with all the methods implemented in RelativedifferencePrior , we do not have SPS stuff for the RDP.


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/1370/c3818862149@github.com>

Evgueni Ovtchinnikov

unread,
Feb 2, 2026, 9:01:14 AMFeb 2
to SyneRBI/SIRF, Push

@evgueni-ovtchinnikov pushed 1 commit.

  • c9ee3cc trying Kris' suggestion to derive SIRF RDP from STIR Gibbs penalty


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1370/before/ae578b8da4e5dfdb03493da0fb634d15bf4093a3/after/c9ee3ccd50a38bebdf8165ed5f99e2eb5787d7c5@github.com>

Evgueni Ovtchinnikov

unread,
Feb 3, 2026, 8:58:53 AMFeb 3
to SyneRBI/SIRF, Push

@evgueni-ovtchinnikov pushed 1 commit.

  • b67e1b0 replaced STIR RDP with SIRF RDP derived from Gibbs penalty


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1370/before/c9ee3ccd50a38bebdf8165ed5f99e2eb5787d7c5/after/b67e1b0e5dd4d6a3ecdcd8abb4d57b4c5a380a5a@github.com>

Evgueni Ovtchinnikov

unread,
Feb 5, 2026, 2:07:43 PMFeb 5
to SyneRBI/SIRF, Push

@evgueni-ovtchinnikov pushed 1 commit.

  • 77754b4 added method compute_Hessian_gradient to SIRF RelativeDifferencePrior


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1370/before/b67e1b0e5dd4d6a3ecdcd8abb4d57b4c5a380a5a/after/77754b437fa2d3cd4f1db3e092ce75be566b3870@github.com>

Kris Thielemans

unread,
Feb 12, 2026, 5:31:53 AMFeb 12
to SyneRBI/SIRF, Subscribed
KrisThielemans left a comment (SyneRBI/SIRF#1370)

@ColomboMatte0 can you suggest a test for this functionality?


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/1370/c3890043869@github.com>

Evgueni Ovtchinnikov

unread,
Feb 12, 2026, 7:32:15 AMFeb 12
to SyneRBI/SIRF, Push

@evgueni-ovtchinnikov pushed 1 commit.

  • bcb5a6e removed some commented-out lines [ci skip]


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1370/before/77754b437fa2d3cd4f1db3e092ce75be566b3870/after/bcb5a6e1e1c8f60d9408bd490e332c90400cd0f1@github.com>

Evgueni Ovtchinnikov

unread,
Feb 16, 2026, 12:37:38 PMFeb 16
to SyneRBI/SIRF, Subscribed
evgueni-ovtchinnikov left a comment (SyneRBI/SIRF#1370)

@ColomboMatte0 could you please suggest a Python test for this functionality. Thank you, E.


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/1370/c3909735680@github.com>

Matteo Colombo

unread,
Feb 16, 2026, 4:13:03 PMFeb 16
to SyneRBI/SIRF, Subscribed
ColomboMatte0 left a comment (SyneRBI/SIRF#1370)

sorry i lost the previous notification, you mean a test for the hessian diagonal? not really sure what you mean with hessian gradient


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/1370/c3910539502@github.com>

Kris Thielemans

unread,
Feb 16, 2026, 4:51:35 PMFeb 16
to SyneRBI/SIRF, Subscribed
KrisThielemans left a comment (SyneRBI/SIRF#1370)

Yes. For the diagonal (not the gradient). Not sure if we have one in STIR that could be replicated?


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/1370/c3910652643@github.com>

Matteo Colombo

unread,
Feb 16, 2026, 5:27:04 PMFeb 16
to SyneRBI/SIRF, Subscribed
ColomboMatte0 left a comment (SyneRBI/SIRF#1370)

i remember i tested it numerically using finite differences from the gradient but probably those tests were not added in my PR, i can add it tomorrow, shouldn't be a big deal.


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/1370/c3910760610@github.com>

Matteo Colombo

unread,
Feb 16, 2026, 5:35:39 PMFeb 16
to SyneRBI/SIRF, Subscribed
ColomboMatte0 left a comment (SyneRBI/SIRF#1370)

$$ H_{ii} \approx \frac{\nabla_i f(x + \epsilon e_i) - \nabla_i f(x - \epsilon e_i)}{2\epsilon} $$

you can test the correctness by computing this, let me know if you want me to implement it somewhere.


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/1370/c3910789570@github.com>

Kris Thielemans

unread,
Feb 17, 2026, 2:26:25 AMFeb 17
to SyneRBI/SIRF, Subscribed
KrisThielemans left a comment (SyneRBI/SIRF#1370)

Good idea. I suggest to use

$$ H_{ii} \approx \frac{\nabla_i f(x + \epsilon e_i) - \nabla_i f(x)}{\epsilon} $$

a bit easier to implement, and also avoids potential issues with the RDP which is only defined on non-negative images.


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/1370/c3912791207@github.com>

Kris Thielemans

unread,
Mar 23, 2026, 10:51:59 AMMar 23
to SyneRBI/SIRF, Subscribed
KrisThielemans left a comment (SyneRBI/SIRF#1370)

I doubt @ColomboMatte0 will have the time for this, unfortunately. Shouldn't be too hard to build on our current "gradient of a function" tests. Just one more loop...


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/1370/c4111227282@github.com>

Matteo Colombo

unread,
Mar 24, 2026, 3:47:35 AMMar 24
to SyneRBI/SIRF, Subscribed
ColomboMatte0 left a comment (SyneRBI/SIRF#1370)

i can do it. but shall i open a new quick PR for STIR? or you want me to add the test where exactly?


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/1370/c4116084724@github.com>

Matteo Colombo

unread,
Mar 24, 2026, 3:52:49 AMMar 24
to SyneRBI/SIRF, Subscribed
ColomboMatte0 left a comment (SyneRBI/SIRF#1370)

here src/xSTIR/pSTIR/tests/tests_qp_lc_rdp.py?


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/1370/c4116107483@github.com>

Evgueni Ovtchinnikov

unread,
Mar 24, 2026, 4:22:12 AMMar 24
to SyneRBI/SIRF, Subscribed
evgueni-ovtchinnikov left a comment (SyneRBI/SIRF#1370)

@ColomboMatte0 yes, that's a good place, please go ahead with a quick PR. Thanks a lot!


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/1370/c4116268946@github.com>

Kris Thielemans

unread,
Mar 24, 2026, 5:57:39 AM (14 days ago) Mar 24
to SyneRBI/SIRF, Push

@KrisThielemans pushed 1 commit.

  • eb8edbb Add numerical test for Hessian diagonal (#1385)


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1370/before/bcb5a6e1e1c8f60d9408bd490e332c90400cd0f1/after/eb8edbb75455ca6fd9b5d5260f6a37f7585f98c5@github.com>

Kris Thielemans

unread,
Mar 24, 2026, 7:01:52 AM (14 days ago) Mar 24
to SyneRBI/SIRF, Subscribed
KrisThielemans left a comment (SyneRBI/SIRF#1370)

Test failures:

src/xSTIR/pSTIR/tests/tests_qp_lc_rdp.py:97: in Hessian_diagonal_test
    test.check_if_less(abs(numerical - analytical) / max_H, 0.01)
...
E               ValueError: +++ test 29 failed: np.float32(0.011938471) >= 0.01

Bounds are always very hard to set in this stuff. @ColomboMatte0 what do you think? (Did you run it locally?)


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/1370/c4117278446@github.com>

Matteo Colombo

unread,
Mar 24, 2026, 8:19:39 AM (14 days ago) Mar 24
to SyneRBI/SIRF, Subscribed
ColomboMatte0 left a comment (SyneRBI/SIRF#1370)

yes I tested it locally on a dataset and it worked on my end. I suspect the CI is running the test on a different dataset. A quick workaround could be to slightly increase the tolerance for this specific test, given that we are using a one-sided derivative.


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/1370/c4117769108@github.com>

Matteo Colombo

unread,
Mar 24, 2026, 8:27:41 AM (14 days ago) Mar 24
to SyneRBI/SIRF, Subscribed
ColomboMatte0 left a comment (SyneRBI/SIRF#1370)

@KrisThielemans I ran the test locally with the CI dataset and reproduced the failure — the one-sided first-order finite difference has O(ε) truncation error which exceeds 1% on some voxels.

Two options:

Option A — relax tolerance to 2% (already in #1386)

Option B — use a second-order one-sided finite difference, keeping the 1% tolerance:

$$ H_{ii} \approx \frac{-3 , \nabla_i f(x) + 4 , \nabla_i f(x + \varepsilon , e_i) - \nabla_i f(x + 2\varepsilon , e_i)}{2\varepsilon} $$

This is O(ε²) instead of O(ε), still one-sided (safe for RDP with non-negative images), but requires one extra gradient evaluation per test voxel.

Let me know which you prefer and I'll update the PR.


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/1370/c4117837288@github.com>

Kris Thielemans

unread,
Mar 24, 2026, 9:23:44 AM (14 days ago) Mar 24
to SyneRBI/SIRF, Subscribed
KrisThielemans left a comment (SyneRBI/SIRF#1370)

thanks. Although I like the second order formulation, I think it's probably not so easy to get right with fast changing priors such as the RDP around zero. I think the main aim here is to have a consistency check and indeed code check (as indeed you found some!).

I'll therefore accept your PR.

Obviously, if we don't have this in STIR yet, it would be useful to add it there as well (sorry for the duplication!). Feel free to try the 2nd order one there :-)

thanks again


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/1370/c4118263654@github.com>

Kris Thielemans

unread,
Mar 24, 2026, 9:24:07 AM (14 days ago) Mar 24
to SyneRBI/SIRF, Push

@KrisThielemans pushed 1 commit.

  • b459171 Relax Hessian diagonal test tolerance from 1% to 2%


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1370/before/eb8edbb75455ca6fd9b5d5260f6a37f7585f98c5/after/b4591714bc75c31e57b1bd2132298263df42742b@github.com>

Kris Thielemans

unread,
Mar 26, 2026, 6:39:08 AM (12 days ago) Mar 26
to SyneRBI/SIRF, Subscribed

Merged #1370 into master.


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/1370/issue_event/23927152700@github.com>

Reply all
Reply to author
Forward
0 new messages