Functions

TransferFunctions.psfFunction

Intensity point spread function i.e. the intensity ratio and phase shift of the sample intensity density

source

Utility Functions and Traits

TransferFunctions.roundupcenterFunction
TransferFunctions.roundupcenter(arr::AbstractArray)

Calculate center index of arr rounded-up (i.e. fft center)

Examples

julia> TF.roundupcenter(ones(15,15))
(8, 8)

julia> TF.roundupcenter(ones(16,16))
(9, 9)

julia> TF.roundupcenter(ones(15,15,15))
(8, 8, 8)
source
TransferFunctions.exactcenterFunction
 TransferFunctions.exactcenter(a::AbstractArray)

Calculate the exact center index of a

Examples

julia> TF.exactcenter(ones(15,15))
(8.0, 8.0)

julia> TF.exactcenter(ones(16,16))
(8.5, 8.5)

julia> TF.exactcenter(ones(15,15,15))
(8.0, 8.0, 8.0)
source

Apodization

TransferFunctions.apodizeFunction
apodize(apo::Apodization, A::AbstractArray{<:Number,N}, cutoff::Real, width::Real) where {N}

Apply apodization to the input array A.

Arguments

  • apo::Apodization: The type of apodization to apply.
  • A::AbstractArray{<:Number,N}: The input array to be apodized.
  • cutoff::Real: The cutoff frequency for the apodization.
  • width::Real: The width of the transition region for the apodization.
source
TransferFunctions.taperedgesFunction
taperedges([apo], A, width::Int, [border="replicate"]; dims=1:N)
taperedges([apo], A, (w1,...,wM), [border="replicate"]; dims =1:M)
taperedges([apo], A, ((w1_start,...,wM_start), (w1_end,...,wM_end)), [border="replicate"]; dims=1:M)

Taper a given width of the array A's edges using apo::Apodization

  • apo: Apodization function to use for the tapering. Default is Cosine.
  • border="replicate" : Similarly as with imfilter, the array A may be extended to avoid loss of the data at the edges
  • width::NTuple{M,Int} or Int or Tuple{NTuple{M,Int},NTuple{M,Int}}: The width of tapering at the edges.
  • dims::NTuple{M,Int}: The dimensions along which to taper the edges.
source

Apodization Functions

TransferFunctions.CosineType
Cosine == PowerCosine{1} <: Apodization
  • zero-phase function: $w₀(r) = \cos(πr/2)$
  • instrument function: $I(k) = 4\cos(2k)/(π(1 - 16k²))$
source
TransferFunctions.GaussianType
Gaussian(σ::Real) <: Apodization

Gaussian apodization function with a given standard deviation σ.

  • zero-phase function: $w₀(r) = e^{-r²/2σ²}$
source
TransferFunctions.FlatTopType
FlatTop == SineSum{5, (0.21557895, 0.41663158, 0.277263158, 0.083578947, 0.006947365) } <: Apodization

MATLAB varaint of the flat-top filter

source

Deprecations

TransferFunctions.padtosizeFunction
TransferFunctions.padtosize(a::AbstractArray{T,N}, size...; fourier=false, padvalue=0)
TransferFunctions.padtosize(a::AbstractArray{T,N}, size; fourier=false, padvalue=0)

Pad a to a size

Padding is done in a way which ensures that if a is symmetric and decreases to zero on the edges (!!) such that eltype(fft(a)) <: Real, then, if possible, output is symmetric under the DFT and elyptype(fft(a_padded)) <: Real). If a is in the Fourier domain, then fourier should de set to true.

Arguments:

  • size: size of the output array. If size isa Integer then size along all the dimensions is size
  • fourier: a is in the Fourier domain (default: false).

Examples:

julia> TF.padtosize(reshape(1:4, 2,2), 3, 3)
3×3 Matrix{Int64}:
 0  0  0
 0  1  3
 0  2  4

julia> TF.padtosize(reshape(1:4, 2,2), 4, 4)
4×4 Matrix{Int64}:
 0  0  0  0
 0  1  3  0
 0  2  4  0
 0  0  0  0

julia> TF.padtosize(reshape(1:4, 2,2), 3, 3; fourier=true)
3×3 Matrix{Int64}:
 4  2  0
 3  1  0
 0  0  0

julia> TF.padtosize(reshape(1:4, 2,2), 4, 4; fourier=true)
4×4 Matrix{Int64}:
 1  0  0  3
 0  0  0  0
 0  0  0  0
 2  0  0  4

julia> ones(1,1) |> fft
1×1 Matrix{ComplexF64}:
 1.0 + 0.0im

julia> TF.padtosize(ones(1,1), 2,2) |> fft
2×2 Matrix{ComplexF64}:
  1.0+0.0im  -1.0+0.0im
 -1.0+0.0im   1.0+0.0im

julia> ones(2,2) |> fft
2×2 Matrix{ComplexF64}:
 4.0+0.0im  0.0+0.0im
 0.0+0.0im  0.0+0.0im

julia> TF.padtosize(ones(2,2), 3, 3) |> fft # can be made symmetric
3×3 Matrix{ComplexF64}:
  4.0+0.0im  -2.0+0.0im  -2.0+0.0im
 -2.0+0.0im   1.0+0.0im   1.0+0.0im
 -2.0+0.0im   1.0+0.0im   1.0+0.0im

julia> TF.padtosize(ones(2,2), 4, 4) |> fft # cannot be symmetric
4×4 Matrix{ComplexF64}:
  4.0+0.0im  -2.0-2.0im  0.0+0.0im  -2.0+2.0im
 -2.0-2.0im   0.0+2.0im  0.0+0.0im   2.0+0.0im
  0.0+0.0im   0.0+0.0im  0.0+0.0im   0.0+0.0im
 -2.0+2.0im   2.0+0.0im  0.0+0.0im   0.0-2.0im

julia> @assert all(-10^-5 .< imag(fft(TF.padtosize(ones(2,2), 5, 5))) .< 10^-5) # .== 0 (numerical errors)
source