torch-radon
torch-radon copied to clipboard
Example-demo visual_sample.py does not work because the BaseRadon.backprojection does not have a 'extend' argument
Hi
Thank you for publishing this code! It is truly amazing. After I solved the torch.rfft torch.irfft incompatibility (I want to believe successfully) using two wrapper functions (I post them below) I tried to run the visual_sample.py example but I got the following error
Traceback (most recent call last):
File "/home/user/torch-radon/examples/visual_sample.py", line 29, in <module>
backprojection = radon.backprojection(sinogram, extend=True)
File "/home/user/miniconda3/lib/python3.9/site-packages/torch_radon-1.0.0-py3.9-linux-x86_64.egg/torch_radon/utils.py", line 30, in wrapped
y = f(self, x, *args, **kwargs)
TypeError: backprojection() got an unexpected keyword argument 'extend'
Should I just delete the 'extend' argument?
The wrapper functions I used to solve the torch.rfft and torch.irfft incompatibility:
def rfft_wrapper(input, signal_ndim, normalized=False):
if signal_ndim < 1 or signal_ndim > 3:
print("Signal ndim out of range, was", signal_ndim, "but expected a value between 1 and 3, inclusive")
return
dims = (-1)
if signal_ndim == 2:
dims = (-2, -1)
if signal_ndim == 3:
dims = (-3, -2, -1)
norm = "backward"
if normalized:
norm = "ortho"
return torch.view_as_real(torch.fft.fftn(input, dim=dims, norm=norm))
def irfft_wrapper(input, signal_ndim, normalized=False):
if signal_ndim < 1 or signal_ndim > 3:
print("Signal ndim out of range, was", signal_ndim, "but expected a value between 1 and 3, inclusive")
return
dims = (-1)
if signal_ndim == 2:
dims = (-2, -1)
if signal_ndim == 3:
dims = (-3, -2, -1)
norm = "backward"
if normalized:
norm = "ortho"
return torch.view_as_real(torch.fft.ifftn(input, dim=dims, norm=norm))