Synthetic Microscopy Data

SIMIlluminationPatterns.SyntheticModule

Serves to generate synthetic SIM data from a ground truth image.

The model of synthetic data generation is characterised by a list of ModelComponents which can be for instance:

  • Noise – black current noise, background noise, photon shot noise (additive / multiplicative / etc. data dependent / independent)
  • Downsampling – downsampling the data so that the reconstruction could have the same size as the ground truth (DownSampling)
  • Illumination – illumination of the focal plane / sample volume
  • Optical transfer – transfer of the light through the optical system
source

<!– TODO: <21-11-24> –>

Components of the Model

SIMIlluminationPatterns.Synthetic.ModelComponentType
Synthetic.ModelComponent

A struct that represents a component of the model of synthetic data generation.

Implementation

Any type A <: ModelComponent that implements this interface must define:

  • apply(c::A, data; <keyword arguments>) or apply(c:A, data, ground_truth; <keyword arguments>) – transform data optionally depending on the ground_truth.
source

Below are the implemented ModelComponents in the natural order of application. <!– TODO: <21-11-24> –>

Illumination

SIMIlluminationPatterns.Synthetic.IlluminationType
Illumination <: ModelComponent

Illuminate the image with a sampled illumination pattern.

Examples

julia> ip = Harmonic(1.0, π / 4, 2 / 61u"nm", 0.0);

julia> sampled_ip = SampledIlluminationPattern(ip, 61u"nm");

julia> ill = Illumination(sampled_ip)
Illumination(Harmonic2D(m=1.0, θ=0.785, ν=0.0328 nm^-1, ϕ=0.0)(Δxy = 61 nm) with eltype Float64)
source
SIMIlluminationPatterns.Synthetic.applyMethod
apply(ill::Illumination, data::AbstractArray)

Illuminate the image data with the sampled illumination pattern ill.pattern.

Examples

julia> img = testimage("moonsurface.tiff");

julia> ip = Harmonic(1.0, π / 4, 2 / 61u"nm", 0.0);

julia> sampled_ip = SampledIlluminationPattern(ip, 61u"nm");

julia> ill = Illumination(sampled_ip);

julia> img_sim = apply(ill, img);
source

Noise

SIMIlluminationPatterns.Synthetic.applyMethod
apply(noise::AdditiveNoise, data)

Add noise to data from noise.dist

Examples

julia> img = testimage("moonsurface.tiff");

julia> noise = AdditiveNoise(Normal(0, 0.1));

julia> img_δ = apply(noise, img);
source
SIMIlluminationPatterns.Synthetic.applyMethod
apply(psn::PhotonShotNoise, data, ground_truth)

Add Poisson noise to data where the $λ$ parameter of the Poisson distribution is proportional to the ground_truth (see PhotonShotNoise)

Examples

julia> data = ground_truth = testimage("moonsurface.tiff");

julia> noise_ps = PhotonShotNoise(0.1);

julia> apply(noise_ps, data, ground_truth);
source

<!– TODO: <21-11-24> –>

Microscopy transfer

SIMIlluminationPatterns.Synthetic.OpticalTransferType
OpticalTransfer <: `ModelComponent`

Simulate light transfer through the optical system by via a transfer function (SampledTransferFuction)

Examples

julia> using TransferFunctions: BornWolf, SampledPSF

julia> bw = BornWolf(444u"nm", 1.4, 1.2);

julia> sampled_bw = SampledPSF(bw, 61u"nm");

julia> ot = OpticalTransfer(sampled_bw)
OpticalTransfer(SampledPSF{2, BornWolf{Float64}}(BornWolf{Float64}(444.0 nm, 1.4, 1.2), (61 nm, 61 nm), (0, 0)))
source
SIMIlluminationPatterns.Synthetic.applyMethod
apply(ot::OpticalTransfer, data::AbstractArray)

Simulate the light transfer by convolving with a transfer function ot.transfer_function.

Examples

julia> using TransferFunctions: BornWolf, SampledPSF

julia> bw = BornWolf(444u"nm", 1.4, 1.2);

julia> sampled_bw = SampledPSF(bw, 61u"nm");

julia> img = testimage("moonsurface.tiff");

julia> ot = OpticalTransfer(sampled_bw);

julia> apply(ot,img);
source

<!– TODO: <21-11-24> –>

Other Model Components

SIMIlluminationPatterns.Synthetic.DownSamplingType
Synthetic.DownSampling <: Synthetic.ModelComponent

Reduce the sampling of the data by a factor of ratio with the reduce function reduce

Fields: ratio::Int, reduce::Function

Examples

julia> ds = DownSampling(3)
DownSampling(3) with reduce `mean`

julia> ds = DownSampling()
DownSampling(2) with reduce `mean`

julia> ds = DownSampling(reduce=maximum)
DownSampling(2) with reduce `maximum`
source
SIMIlluminationPatterns.Synthetic.applyMethod
apply(ds::DownSampling, data)

Examples

julia> img = testimage("moonsurface.tiff");

julia> ds = DownSampling(2);

julia> size(img)
(256, 256)

julia> img_ds = apply(ds, img);

julia> size(img_ds)
(128, 128)
source

Ground Truth Models

Fluorescent Microspheres (beads)

SIMIlluminationPatterns.Synthetic.GroundTruthGeneratorType
Synthetic.GroundTruthGenerator

A struct that generates a ground truth synthetic image based on stored latent variables.

Implementation

Any type that implements this interface must define:

  • generate(gtg::GroundTruthGenerator) – generate the ground truth image
source
SIMIlluminationPatterns.Synthetic.beadFunction
bead([T=Float64], d::Length, α::PerLength, (Δxy::Length,Δxy::Length))
bead(d, α, Δxy::Length)

Generate a model of a bead with diameter d and pixel-sizes Δxy.

Arguments

  • α::PerLength=1u"nm^-1: evanescent wave attenuation constant in the TIR-FM microscopy modulation. For a normal acquisition without total internal reflection 0u"nm^-1" is setting.
  • pixel_grid_length::Int = 10: length of each pixel in the grid
  • peak_intensity = 1.0: peak intensity value
  • subpixel_shift =(0, 0)

Examples

julia> Synthetic.bead(100u"nm", 30.5u"nm");

julia> Synthetic.bead(95u"nm", (30.5u"nm", 25u"nm"));

julia> Synthetic.bead(Float32, 0.1u"μm", 30.5u"nm");

julia> Synthetic.bead(0.1u"μm", 30.5u"nm"; α=0.01u"nm^-1")
7×7 OffsetArray(::Matrix{Float64}, -3:3, -3:3) with eltype Float64 with indices -3:3×-3:3:
 0.0  0.0        0.0       0.0        0.0       0.0        0.0
 0.0  0.0        0.0       0.0705075  0.0       0.0        0.0
 0.0  0.0        0.606779  0.892914   0.606779  0.0        0.0
 0.0  0.0705075  0.892914  1.0        0.892914  0.0705075  0.0
 0.0  0.0        0.606779  0.892914   0.606779  0.0        0.0
 0.0  0.0        0.0       0.0705075  0.0       0.0        0.0
 0.0  0.0        0.0       0.0        0.0       0.0        0.0

julia> Synthetic.bead(0.1u"μm", 50.5u"nm"; subpixel_shift=(-0.3,-0.2))
5×5 OffsetArray(::Matrix{Float64}, -2:2, -2:2) with eltype Float64 with indices -2:2×-2:2:
 0.0  0.0       0.0       0.0        0.0
 0.0  0.333333  0.737374  0.0808081  0.0
 0.0  0.59596   1.0       0.20202    0.0
 0.0  0.020202  0.141414  0.0        0.0
 0.0  0.0       0.0       0.0        0.0

julia> Synthetic.bead(0.1u"μm", 50.5u"nm"; peak_intensity=0.5)
5×5 OffsetArray(::Matrix{Float64}, -2:2, -2:2) with eltype Float64 with indices -2:2×-2:2:
 0.0  0.0   0.0   0.0   0.0
 0.0  0.03  0.23  0.03  0.0
 0.0  0.23  0.5   0.23  0.0
 0.0  0.03  0.23  0.03  0.0
 0.0  0.0   0.0   0.0   0.0
source
SIMIlluminationPatterns.Synthetic.beadsFunction
beads(T=Float64; <keyword arguments>)

Generate a synthetic microscopy image of fluorescent beads with realistic optical properties.

Arguments

  • image_size::Tuple{Int,Int}=(1024, 1024): Size of the output image in pixels
  • N::Int=1000: Number of beads to generate
  • pxsize::Tuple{Quantity,Quantity}=(30.5u"nm", 30.5u"nm"): Pixel size in physical units
  • bead_radius::Quantity=0.05u"μm": Radius of each bead
  • min_distance::Quantity=0.06u"μm": Minimum allowed distance between bead centers
  • α_evanescent::Quantity=1/200u"nm": Evanescent field decay constant
source
SIMIlluminationPatterns.Synthetic.synthetic_beads_imageFunction
synthetic_beads_image(T=Float64; <keyword arguments>)

Generate a synthetic microscopy image Matrix{T} of fluorescent beads with realistic optical properties.

Arguments

  • image_size::Tuple{Int,Int}=(1024, 1024): Size of the output image in pixels
  • N::Int=1000: Number of beads to generate
  • pxsize::Tuple{Quantity,Quantity}=(30.5u"nm", 30.5u"nm"): Pixel size in physical units
  • bead_radius::Quantity=0.05u"μm": Radius of each bead
  • min_distance::Quantity=0.06u"μm": Minimum allowed distance between bead centers
  • α_evanescent::Quantity=1/200u"nm": Evanescent field decay constant
  • noise_model::Distribution=Normal{Float32}(2.0503677f-12, 4*0.005893613f0): Statistical model for image noise
  • optical_transfer_function=IdealOTFwithCurvature(488u"nm", 1.4, 1.0, 0.9): Optical transfer function for microscope simulation

Extended help

Generates a synthetic microscopy image of fluorescent beads, simulating:

  1. Random placement of beads with minimum separation distance (min_distance)
  2. Evanescent field illumination
  3. Realistic noise
  4. Optical transfer function effects

The beads are positioned randomly but maintain a minimum separation distance. Each bead's intensity is modulated by the evanescent field decay. The image is then convolved with the specified optical transfer function and noise is added according to the provided noise model.

Examples

# Generate a synthetic image with default parameters
img = synthetic_beads_image()

# Generate a 512x512 image with fewer beads
img = synthetic_beads_image(Float32; image_size=(512,512), N=500)
source