Synthetic Microscopy Data

SIMIlluminationPatterns.Synthetic — Module

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.ModelComponent — Type
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.Illumination — Type
Illumination <: ModelComponent

Illuminate the image with a sampled illumination pattern.

Examples

julia> ip = Harmonic(1.0, [2 / 61u"nm", 0u"nm^-1"], 0.0, 1 / (61u"nm")^2);

julia> ill = Illumination(ip)
Illumination(Harmonic{Float64}(m=1.0, Pθ=[0.0328 nm^-1, 0.0 nm^-1], ϕ=0.0, I0=0.000269 nm^-2))
source
SIMIlluminationPatterns.Synthetic.apply — Method
apply(ill::Illumination, data::SpatialArray)

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

The current sampling API is SIMIlluminationPatterns.sample(pattern, data). The example below uses that API; apply(::Illumination, ::SpatialArray) still needs to be updated to sample the pattern on the input grid.

Examples

julia> img = SpatialArray(testimage("moonsurface.tiff"), 61u"nm");

julia> ip = Harmonic(1.0, [2 / 61u"nm", 0u"nm^-1"], 0.0, 1 / (61u"nm")^2);

julia> sampled_ip = SIMIlluminationPatterns.sample(ip, img);

julia> size(sampled_ip)
(256, 256)
source

Noise

SIMIlluminationPatterns.Synthetic.apply — Method
apply(noise::AdditiveNoise, data)

Add noise to data from noise.dist

Examples

julia> img = SpatialArray(testimage("moonsurface.tiff"), 61u"nm");

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

julia> img_δ = apply(noise, img);
source
SIMIlluminationPatterns.Synthetic.apply — Method
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 = SpatialArray(testimage("moonsurface.tiff"), 61u"nm");

julia> noise_ps = PhotonShotNoise(0.1);

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

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

Microscopy transfer

SIMIlluminationPatterns.Synthetic.apply — Method
apply(ot::OpticalTransfer, data::SpatialArray)

Simulate light transfer by applying the stored transfer function to a SpatialArray in the Fourier domain. The transfer function is sampled on the sampling grid of data, so it must match its dimensionality.

Examples

julia> using TransferFunctions: CircularPupilOTF

julia> otf_model = CircularPupilOTF(488u"nm", 1.4, 1.0, 0.9);

julia> img = SpatialArray(Float64.(testimage("moonsurface.tiff")), 61u"nm");

julia> ot = OpticalTransfer(otf_model);

julia> img_ot = apply(ot, img);

julia> size(img_ot)
(256, 256)
source

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

Other Model Components

SIMIlluminationPatterns.Synthetic.DownSampling — Type
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.apply — Method
apply(ds::DownSampling, data)

Examples

julia> img = SpatialArray(testimage("moonsurface.tiff"), 61u"nm");

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.GroundTruthGenerator — Type
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.synthetic_beads_image — Function
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
  • illumination_patterns::Vector{<:Union{Nothing,IlluminationPattern}}=[nothing]: Illumination patterns to illuminate the image with; a separate output image is returned for each pattern (nothing results in an unilluminated image)
  • optical_transfer_function=CircularPupilOTF(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