mrphys / tensorflow-nufft

Fast, Native Non-Uniform Fast Fourier Transform for TensorFlow
https://mrphys.github.io/tensorflow-nufft/
Apache License 2.0
23 stars 4 forks source link

Test Case NUFFT1 and Real Valued Data #27

Closed stefanhiemer closed 2 years ago

stefanhiemer commented 2 years ago

Hi everyone,

first of all thanks for the nice package. Now to my two points:

  1. I want to apply NUFFT to transform atoms and features located on the atoms. I later want to apply it to my (e. g. https://www.nature.com/articles/s41467-022-30530-1). The interesting point to me is to be able to systematically map the off-grid atoms to images and back while using some advantages (e. g. convolution via multiplication in fourier space, per atom predictions, etc. pp.). I constructed a test case with 100 atom at random positions and random (real) values. When I do the transformation via NUFFT type 1 and the backtransform via NUFFT type 2, the backtransformed values are too large. Rescaling by the per sample maximum value fixes this somewhat, but it is not the proper way. I guess I am missing something about reweighting/rescaling or something goes wrong in the code. I'd be grateful for some input. I think it might also be an interesting example case.

test_tfnufft1 .txt

  1. In my case the values are real valued data and there are faster algorithms for real valued FFTs than the general method. Is there any plan to include this into the module?

Thanks and Regards Stefan

jmontalt commented 2 years ago

Hi @stefanhiemer, what an interesting application! Glad to know you might find it useful.

Unfortunately, NUFFT normalization is not trivial and there is no factor that will guarantee orthonormality in the general case. You may want to have a look at this thread. Briefly, you need to account for the FFT normalization (based on grid shape), but also for the sampling density in non-uniform space. Check out this example. To estimate the density for an arbitrary set of points, you may find this function useful.

As for the real-valued NUFFT, I do not plan to add this functionality myself for the foreseeable future, as the amount of work is not insignificant. That being said, I understand the purpose and would be happy to accept a contribution and maintain the feature.

jmontalt commented 2 years ago

I'm assuming this question has been answered. Feel free to reopen otherwise!