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

RDP gradient can generate NaNs if epsilon is zero #1394

Closed
KrisThielemans opened this issue Mar 6, 2024 · 2 comments
Closed

RDP gradient can generate NaNs if epsilon is zero #1394

KrisThielemans opened this issue Mar 6, 2024 · 2 comments

Comments

@KrisThielemans
Copy link
Collaborator

Reconstructing the mMR NEMA data gives me NaNs in the background of the image, then quickly ruining everything of course. Obviously, when epsilon=0, the function is not differentiable at x,y=0. We try to set the gradient to zero, but apparently still miss some cases. Relevant code is

elemT current;
if (this->epsilon == 0.0 && current_image_estimate[z][y][x] == 0.0
&& current_image_estimate[z + dz][y + dy][x + dx] == 0.0)
{
// handle the undefined nature of the gradient
current = 0.0;
}
else
{
current
= weights[dz][dy][dx]
* (((current_image_estimate[z][y][x] - current_image_estimate[z + dz][y + dy][x + dx])
* (this->gamma
* abs(current_image_estimate[z][y][x] - current_image_estimate[z + dz][y + dy][x + dx])
+ current_image_estimate[z][y][x] + 3 * current_image_estimate[z + dz][y + dy][x + dx]
+ 2 * this->epsilon))
/ (square((current_image_estimate[z][y][x] + current_image_estimate[z + dz][y + dy][x + dx])
+ this->gamma
* abs(current_image_estimate[z][y][x]
- current_image_estimate[z + dz][y + dy][x + dx])
+ this->epsilon)));
}

@Imraj-Singh have you seen this?

@robbietuk
Copy link
Collaborator

Could be because of small x/y values?

@KrisThielemans
Copy link
Collaborator Author

This was fixed by #1410

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