Skip to content

Conversation

@nHackel
Copy link
Collaborator

@nHackel nHackel commented Sep 1, 2025

As discussed in here, it is currently not possible to use the plan_nfft interface when multiple packages such as NFFT and NonuniformFFTs are loaded in the same session. The underlying issue is that both packages refer to the same function and usually have no dedicated type to dispatch one, as both want to dispatch on "normal" user array types.

This PR adds a "backend"-based selection of the NFFT plan implementation, which allows a user to chose which backend to use for a given plan_nfft call. This utilizes an additional first parameter which specifies the backend to use:

using AbstractNFFTs, NFFT, NonuniformFFTs
J, N = 8, 16
k = range(-0.4, stop=0.4, length=J)
plan_nfft(NFFT.backend(), k, N) # NFFT plan
plan_nfft(NonuniformFFTs.backend(), k, N) # Nonuniform plan

To hide this additional type from the users of upstream packages, AbstractNFFTs now features an active backend global constant, similar to how Makie allows one to switch between its backends:

using NFFT # internally calls NFFT.activate!()
J, N = 8, 16
k = range(-0.4, stop=0.4, length=J)
plan_nfft(k, N) # NFFT plan

using NonuniformFFTs
plan_nfft(k, N) # Nonuniform plan

NFFT.activate!()
plan_nfft(k, N) # NFFT plan again

with(nfft_backend => NonuniformFFTs.backend()) do
    plan_nfft(k, N) # Nonuniform plan but doesn't affect outer scope
end

This PR allows upstream packages such as LinearOperatorCollection (PR) or MRIOperators to define themselves in terms of AbstractNFFTs and use exchangable NFFT providers.

@nHackel nHackel merged commit a65c30b into master Nov 7, 2025
3 of 6 checks passed
nHackel referenced this pull request in MagneticResonanceImaging/MRIReco.jl Nov 10, 2025
* Adapt to NFFT backend changes

* Remove further symmetrize keyword

* Remove explicit precompute pass since those are handled by NFFTOp (again)

* Increase MRIOperators version to 0.4

* Bump MRIBase from 0.4.5 to 0.4.6

* Bump MRIReco from 0.9.0 to 0.9.1

* Bump MRISimulation from 0.1.3 to 0.1.4

* Capture additional keyword arguments s.t. they are not passed to NFFTOp
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

Successfully merging this pull request may close these issues.

2 participants