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

Example-demo visual_sample.py does not work because the BaseRadon.backprojection does not have a 'extend' argument #32

Open
DimitriosBellos opened this issue Dec 2, 2021 · 0 comments

Comments

@DimitriosBellos
Copy link

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))
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

1 participant