Relative Difference Prior - Computing gradient can return image with Nan values
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 160
- Forks
- 113
- Avg merge
- 12d 15h
- Merged PRs (30d)
- 1
Description
I have observed an issue that objective function gradients, from images with voxel values of 0 or very small, having Nan values. Setting the penalty_strength to 0 resolves this issue. Therefore the issue likely lies with Relative Difference Prior (RDP). The issue does not occur with the Quadratic Prior. I have only observed this issue on a Linux system but could not replicate it on MacOS using the same data.
The gradient computation involves divisions. To prevent the division by zeros there is a check if both compared voxels and epsilon have zero value. This issue might be caused by very small voxel values (passing the >0 check) being squared, which may result in in the denominator being set to zero and hence the Nan values.
Relevant code: https://github.com/UCL/STIR/blob/621154460e7f1bf6e0b82a08418663baacba945f/src/recon_buildblock/RelativeDifferencePrior.cxx#L387-L398
A resolution to this is to use an epsilon > 0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/recon_buildblock/RelativeDifferencePrior.cxx around lines 387-398, focusing on the gradient divisions and the zero/epsilon check. Reproduce the issue with zero or very small voxel values on Linux, then verify that the Relative Difference Prior gradient contains no NaN values when epsilon is greater than zero.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100