SIMIlluminationPatterns.FrequencyUnitsType
SIMIlluminationPatterns.FrequencyUnits{U}

A supertype for units of dimension Unitful.𝐋 ^ -1. Equivalent to Unitful.Units{U, Unitful.𝐋 ^ -1}.

See also: Unitful.Units.

source
SIMIlluminationPatterns.HarmonicType

Harmonic (sinusoidal) illumination pattern in the form

\[ I(\vec{r})=1+{\frac{m}{2}}\cos\left(2π⋅ (kₓ⋅(\vec{r})ₓ + k_y ⋅ (\vec{r})_y) + \phi\right)\]

Harmonic(m::Real, θ::Real, ν::Frequency, ϕ::Real)
Harmonic(m::Real, (ν_x, ν_y)::Tuple{Frequency,Frequency}, ϕ::Real)
Harmonic(m::Real, (ν_x, ν_y)::Tuple{Real,Real}, ϕ::Real, Δxy::Length)
Harmonic(m::Real, (ν_x, ν_y)::Tuple{Real,Real}, ϕ::Real, (Δx, Δy)::Tuple{Length,Length})

Harmonic(m::Real, θ::Real, λ::Length, ϕ::Real)
Harmonic(m::Real, (λ_x, λ_y)::Tuple{Length,Length}, ϕ::Real)
Harmonic(m::Real, θ::Real, λ::Real, ϕ::Real, Δxy::Length)
Harmonic(m::Real, θ::Real, λ::Real, ϕ::Real, (Δx, Δy)::Tuple{Length,Length})

Harmonic(m::Real, (δ_x, δ_y)::Tuple{Real, Real}, size::Union{Tuple{Real, Real}, Real}, ϕ::Real, Δxy::Length)
Harmonic(m::Real, (δ_x, δ_y)::Tuple{Real, Real}, size::Union{Tuple{Real, Real}, Real}, ϕ::Real, (Δx, Δy)::Tuple{Length,Length})

Parameters have types Real, Frequency or Unitful.Length and denote:

  • m: modulation factor
  • θ: orientation angle (from the $x$-axis) (\theta)
  • ν: frequency (\nu)
  • (ν_x, ν_y): wave vector ('shift' in physical units) ($(ν_x, ν_y) = (\sin(θ) ⋅ ν , \, \cos(θ) ⋅ ν)$)
  • (δ_x, δ_y): shift in pixels
  • size: size of acquisition image, from which the shift (δ_x, δ_y) is determined
  • λ: wavelength (\lambda)
  • (λ_x, λ_y): wavepeak vector ($(λ_x, λ_y) = (\sin(θ) ⋅ λ , \, \cos(θ) ⋅ λ)$)
  • ϕ: phase offset (\phi)
  • Δxy or (Δx, Δy): $x$-axis and $y$-axis pixel sizes

Examples

julia> h1 = Harmonic(1, π/2, 1/(2*61u"nm"), π/4)
Harmonic2D(m=1.0, θ=1.57, ν=0.0082 nm^-1, ϕ=0.785)

julia> h2 = Harmonic(1, (0u"nm^-1", 1/(2*61u"nm")), π/4);

julia> h3 = Harmonic(1, (0, 1/2), π/4, 61u"nm");

julia> h4 = Harmonic(1, (0, 1/4), π/4, (61u"nm", 30.5u"nm"));

julia> h5 = Harmonic(1, π/2, 2*61u"nm", π/4);

julia> h6 = Harmonic(1, (0u"nm", 2*61u"nm"), π/4);

julia> # h7 = Harmonic(1, π/2, 2, π/4, 61u"nm") # FIX

julia> # h8 = Harmonic(1, π/2, 2, π/4, (61u"nm", 61u"nm")) # FIX

julia> h9 = Harmonic(1, (0, 256), (512, 512), π/4, 61u"nm");

julia> h10 = Harmonic(1, (0, 128), (512, 512), π/4, (61u"nm", 30.5u"nm"));

julia> h1 == h2 == h3 == h4 == h5 == h6 == h9 == h10
true
source
SIMIlluminationPatterns.IlluminationPatternType

Super type for N-dimensional illumation patterns. Any particular illumination pattern is a subtype of this. See the documentation for IlluminationPattern interface to see how to implement your own illumination pattern subtype.

See also: Harmonic2D

Implementation

When implementing a new subtype A <: IlluminationPattern{N} you need to implement the following methods:

  • (pattern::A)(r::Vararg{Length, N})::Real representing the intensity of pattern at the position r

and these optional methods:

TODO

The inner constructor of the subtype A should check that N::Integer unless your subtype has a specified dimension.

struct A1{N} <: IlluminationPattern{N}
    function A{N}() where {N}
        @assert N isa Integer
        new{N}()
    end
end

struct A2 <: IlluminationPattern{2}
    function A2()
        # No need for any assertions
        new()
    end
end
source
SIMIlluminationPatterns.SampledIlluminationPatternType
SampledIlluminationPattern{T<:Real,N,IP<:IlluminationPattern{N}}
SampledIlluminationPattern([T=Float64], ip::IlluminationPattern, Δxy)

N-dimensional sampled illumination pattern. You can fix the pixels sizes (Δxy) and sample the pattern on your sensor and optical system setup.

Examples

julia> h = Harmonic(1.0, π / 4, 2 / 61u"nm", 0.0)
Harmonic2D(m=1.0, θ=0.785, ν=0.0328 nm^-1, ϕ=0.0)

julia> sampled_ip = SampledIlluminationPattern(h, (30u"nm", 30u"nm"))
Harmonic2D(m=1.0, θ=0.785, ν=0.0328 nm^-1, ϕ=0.0)(Δxy = 30 nm) with eltype Float64

julia> sampled_ip(3, 4.5)
1.1048934112868387

julia> sampled_ip(CartesianIndex(1,1))
0.6126893879715403

julia> img = rand(10,10);

julia> sampled_ip((5, 5))
5×5 Matrix{Float64}:
 1.5       0.832154  0.612689  1.42788   1.10004
 0.832154  0.612689  1.42788   1.10004   0.504955
 0.612689  1.42788   1.10004   0.504955  1.23233
 1.42788   1.10004   0.504955  1.23233   1.33906
 1.10004   0.504955  1.23233   1.33906   0.54003

julia> sampled_ip((10, 10)) == sampled_ip(img)
true

julia> sampled_ip(CartesianIndices(img)) != sampled_ip(img) # BEWARE! This is not equivalent
true

julia> sampled_ip(CartesianIndices((0:9, 0:9))) == sampled_ip(img) # This is equivalent
true
source
SIMIlluminationPatterns.separation_matrixMethod
separation_matrix(ϕ::NTuple{3,<:Real}, μ::NTuple{3,<:Real}=(1, 1, 1))
separation_matrix(ϕ_0::Real,...) # Assume equidistant phases

Construct a separation matrix M with eltype(M) = Complex{T} for given phase shifts ϕ and modulations μ.

The matrix M is such that for acquisitions $D_1(\tilde{k})$, $D_2(\tilde{k})$ and $D_3(\tilde{k})$ the components are separated as

\[ \begin{pmatrix} C_{0}(\tilde{k}) \\ C_{-1}(\tilde{k}) \\ C_{+1}(\tilde{k}) \end{pmatrix} = \begin{pmatrix} H(\tilde{k})S(\tilde{k}) \\ H(\tilde{k})S(\tilde{k} - \tilde{\nu}) \\ H(\tilde{k})S(\tilde{k} + \tilde{\nu}) \end{pmatrix} = \begin{pmatrix} 1 & \tfrac{\mu_1}{2} e^{-i\phi_1} & \tfrac{\mu_1}{2} e^{i \phi_1} \\ 1 & \tfrac{\mu_2}{2} e^{-i\phi_2} & \tfrac{\mu_2}{2} e^{i \phi_2} \\ 1 & \tfrac{\mu_3}{2} e^{-i\phi_3} & \tfrac{\mu_3}{2} e^{i \phi_3} \end{pmatrix}^{-1} \begin{pmatrix} D_{1}(\tilde{k}) \\ D_{2}(\tilde{k}) \\ D_{3}(\tilde{k}) \end{pmatrix}\]

source
SIMIlluminationPatterns.separation_matrixFunction
separation_matrix(ϕ::NTuple{3,<:Real}, μ::NTuple{3,<:Real}=(1, 1, 1))
separation_matrix(ϕ_0::Real,...) # Assume equidistant phases

Construct a separation matrix M with eltype(M) = Complex{T} for given phase shifts ϕ and modulations μ.

The matrix M is such that for acquisitions $D_1(\tilde{k})$, $D_2(\tilde{k})$ and $D_3(\tilde{k})$ the components are separated as

\[ \begin{pmatrix} C_{0}(\tilde{k}) \\ C_{-1}(\tilde{k}) \\ C_{+1}(\tilde{k}) \end{pmatrix} = \begin{pmatrix} H(\tilde{k})S(\tilde{k}) \\ H(\tilde{k})S(\tilde{k} - \tilde{\nu}) \\ H(\tilde{k})S(\tilde{k} + \tilde{\nu}) \end{pmatrix} = \begin{pmatrix} 1 & \tfrac{\mu_1}{2} e^{-i\phi_1} & \tfrac{\mu_1}{2} e^{i \phi_1} \\ 1 & \tfrac{\mu_2}{2} e^{-i\phi_2} & \tfrac{\mu_2}{2} e^{i \phi_2} \\ 1 & \tfrac{\mu_3}{2} e^{-i\phi_3} & \tfrac{\mu_3}{2} e^{i \phi_3} \end{pmatrix}^{-1} \begin{pmatrix} D_{1}(\tilde{k}) \\ D_{2}(\tilde{k}) \\ D_{3}(\tilde{k}) \end{pmatrix}\]

source

Utils

Band Separation

Unitful.jl Units

SIMIlluminationPatterns.FrequencyType
SIMIlluminationPatterns.Frequency{T, U}

A supertype for quantities and levels of dimension Unitful.𝐋 ^ -1 with a value of type T and units U.

See also: Unitful.Quantity, Unitful.Level.

source
SIMIlluminationPatterns.FrequencyUnitsType
SIMIlluminationPatterns.FrequencyUnits{U}

A supertype for units of dimension Unitful.𝐋 ^ -1. Equivalent to Unitful.Units{U, Unitful.𝐋 ^ -1}.

See also: Unitful.Units.

source