NFFT helpers

Based on NFFT.jl we provide some convenient helper functions:

FourierTools.nfft_ndFunction
nfft_nd(src, dst_coords, dst_size=nothing; is_in_pixels=false, is_local_shift=false)

performs an n-dimensional non-uniform FFT on grids with a regular topology. In comparison to the nfft() routine, which this computed is based on, this version does not require any reshape operations. See plan_nfft_nd for details on the arguments and usage examples. Note that the input can be Real valued and will be automatically converted to Complex.

# A Zoomed transform in 3D
julia> nfft_nd(rand(10,12,12), (t)-> (0.8*t[1], 0.7*t[2], 0.6*t[3]))
source
FourierTools.plan_nfft_ndFunction
plan_nfft_nd(src, dst_coords; is_in_pixels=false, is_local_shift=false, pad_value=nothing, reltol=1e-9)

Plans an n-dimensional non-uniform FFT on grids with a regular topology. In comparison to the nfft() routine, which this computed is based on, this version does not require any reshape operations.

Arguments

  • src: source array
  • dst_coords: array of destination coordinates. This can be either an Array of Tuple or an Array with the last dimension ofsizelength(size(dst_coords))-1` referring to the destination coordinates where the FFT needs to be computed. Alternatively also a function mapping a tuple (of source index positions) to a tuple (of destination index positions). In the recommended mode, the indices are normalized to to Fouier frequency range (roughly speaking from -0.5:0.5).
  • is_in_pixels: A Boolean flag indicating whether dstcoords refers to coordinates in pixels or (default) in relative frequency positions. If `isin_pixels=true` is selected, destination coordinates (1-based indexing) as typical for array indexing is assumed and internally converted to relative positions.
  • is_local_shift: A Boolean controlling wether dst_coords refers to the destination coordinates or the relative distance from standard grid coordinates (size determind from dst_coordinates).
  • pad_value: if supplied, values outside the valid pixel range (roughly -0.5:0.5) are replaced by this complex-valued pad value.
  • is_adjoint: if true this plan is based on the adjoint rather than the ordinary plan
  • reltol: The numerical precision to which the results are computed. This is passed to the nfft routine. Worse precision is faster.
# Lets try a 2D rotation:
julia> using TestImages, NDTools, View5D, IndexFunArrays, FourierTools

julia> img = Float64.(testimage("resolution"));

# define a rotation operation
julia> rot_alpha(a, t) = (cosd(a)*t[1] - sind(a)*t[2], sind(a)*t[1]+cosd(a)*t[2])

julia> new_pos = rot_alpha.(10.0, idx(img, scale=ScaFT))

julia> f = ift(img)

julia> p = plan_nfft_nd(f, new_pos; is_local_shift=false, is_in_pixels=false)

julia> g = real.(p * f)

#display the result
julia> @ve img, g
source
plan_nfft_nd(src::AbstractArray{T,D}, dst_fkt::Function, dst_size=size(src); is_in_pixels=false, is_adjoint=false, kwargs...)

Plans an n-dimensional non-uniform FFT on grids with a regular topology defined via the function dst_fkt.

Arguments

  • src: source array
  • dst_fkt: a function mapping a tuple (of source index positions) to a tuple (of destination index positions). In the recommended mode, the indices are normalized to to Fouier frequency range (roughly speaking from -0.5:0.5). If the named argument is_in_pixels is provided, the function is expected to act on one-index based pixel coordinates. This option is particularly interesting in combination with the argument is_loca_shift.
  • dst_size: this argument is only used for functions. If you require a different result size for dst_coords being a function, state it here.By defaul (dst_size=nothing) the destination size will be inferred form the argument new_pos or assumed to be size(src).
  • is_in_pixels: A Boolean flag indicating whether dstcoords refers to coordinates in pixels or (default) in relative frequency positions. If `isin_pixels=true` is selected, destination coordinates (1-based indexing) as typical for array indexing is assumed and internally converted to relative positions.
  • is_adjoint: if true this plan is based on the adjoint rather than the ordinary plan

For other arguments and examples see the array-version of plan_nfft above.

source