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
Center parameter not implemented for all GPU methods #425
Comments
Hi @lriordanchen, the GPU algorithm sets up the problem differently than the CPU algorithms -- instead of keeping the ROI stationary and calculating the chord through the pixel at a given projection angle, it rotates the entire ROI to be perpendicular with the projection angle and interpolates the new pixels. at this point, the algorithms proceeds essentially the same as the CPU algorithms except all the weights are 1. Then the ROI is back rotated and interpolated to the original coordinates. So TL;DR -- you need to pad your sinogram with ones or zeros so a rotation of 45 degrees doesn't result in a data loss. For the built-in phantoms, here is an example of the padding being applied: tomopy/benchmarking/phantom.py Line 36 in cfeb9ca
@dgursoy or @carterbox can probably give you more exact/accurate instructions on how to do this though. |
@jrmadsen, you're describing a different problem than what @lriordanchen is reporting. The problem here is that in an experiment, the center of rotation for the object isn't always perfectly aligned with the field of view. This is why we have the Lines 162 to 247 in cfeb9ca
Right now, it looks like we are assuming that the center of rotation is located at Lines 244 to 245 in cfeb9ca
However, the old sirt uses the I haven't run my own tests to confirm this is the case, but if @lriordanchen posts a photo of one of their reconstructions, we can easily confirm that this is the center issue and not a padding issue. @lriordanchen, as a temporary measure, you can adjust the rotation centers of the sinograms before handing them off to SIRT by shifting them along the x-axis. However, the reason why the |
This is both a bug and feature request. At the very least, there should be a warning that |
Ah ok. Thanks for correcting this. Yes it should not be difficult to adapt the affine transform in utils.cu to handle this. |
Thanks @jrmadsen and @carterbox! Here is an example of what I was seeing: Below I have an slice generated by running without the gpu: and here I have the same image generated by running with the gpu: Do you agree that it is a problem with the rotation center? Also, I found the same thing happened with mlem. Adding on to the feature request in issue #422, would it be possible to have the padding @jrmadsen talked about automatically taken care of after the code has determined not to fallback to the cpu? That way the result, whether arrived at by using the gpu as asked for or by using the cpu as fallback, is calculated correctly. Thanks again for all your help. |
Thanks for bringing this up. Currently the GPU implementation assumes that the center is at the middle of the detector's field of view no matter what you provide with the But in the long run we need to fix it in TomoPy. This requires implementation of rotation around an arbitrary point and deserves a new pull request. First, we should generate a warning for users that I'll post it here once the PR is open. |
@jdgelb as mentioned by @dgursoy for now you can just shift with:
assuming you had a 1024 detector (512 - 484) = 28 |
I think the @jdgelb astra issue is different from the tomopy GPU. I was getting ready to open a new issue but since it's related I'll post it here. In the astra implementation, tomopy accounts for the center parameter by setting the ExtraDetectorOffset option on the projection geometry object. However, this doesn't actually change the reconstruction in astra, as demonstrated in this MWE. The example is a modification of sample s003, with the addition of the extra detector offset on line 34. If I run the example, the reconstruction is the same no matter what value I put in for center. I'm not sure on whether astra or tomopy has the issue, though. |
Hello,
I'm having trouble implementing the GPU support.
When I run the reconstruction without GPU support, it works as expected, but when I add in the line to run it on the GPU, the reconstruction contains artifacts consistent with using the incorrect rotation center in the reconstruction algorithm.
So when I comment out the line <accelerated=True, device="gpu" >, the reconstruction looks reasonable but when I run it as above, I see the characteristic loops and double edges as if the rotation center is incorrect. What could be the reason for this, and how can I get this to reconstruct correctly when I run on the GPU?
I'm running on:
The text was updated successfully, but these errors were encountered: