Synthetic Microscopy Data
SIMIlluminationPatterns.Synthetic
— ModuleServes to generate synthetic SIM data from a ground truth image.
The model of synthetic data generation is characterised by a list of ModelComponent
s 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
<!– TODO: <21-11-24> –>
Components of the Model
SIMIlluminationPatterns.Synthetic.ModelComponent
— TypeSynthetic.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>)
orapply(c:A, data, ground_truth; <keyword arguments>)
– transformdata
optionally depending on theground_truth
.
Below are the implemented ModelComponent
s in the natural order of application. <!– TODO: <21-11-24> –>
Illumination
SIMIlluminationPatterns.Synthetic.Illumination
— TypeIllumination <: 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)
SIMIlluminationPatterns.Synthetic.apply
— Methodapply(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);
Noise
SIMIlluminationPatterns.Synthetic.AdditiveNoise
— TypeAdditiveNoise{D<:Distribution} <: ModelComponent
Additive noise component of the synthetic data model.
See also PhotonShotNoise
Examples
julia> noise = AdditiveNoise(Normal(0, 0.1))
AdditiveNoise(Normal{Float64}(μ=0.0, σ=0.1))
SIMIlluminationPatterns.Synthetic.apply
— Methodapply(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);
SIMIlluminationPatterns.Synthetic.PhotonShotNoise
— TypePhotonShotNoise <: ModelComponent
Add Poisson noise simulating the photon shot noise (inherent to the quantum nature of light) to the data
See also AdditiveNoise
Examples
julia> noise_ps = PhotonShotNoise(0.1)
PhotonShotNoise(0.1)
SIMIlluminationPatterns.Synthetic.apply
— Methodapply(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);
<!– TODO: <21-11-24> –>
Microscopy transfer
SIMIlluminationPatterns.Synthetic.OpticalTransfer
— TypeOpticalTransfer <: `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)))
SIMIlluminationPatterns.Synthetic.apply
— Methodapply(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);
<!– TODO: <21-11-24> –>
Other Model Components
SIMIlluminationPatterns.Synthetic.DownSampling
— TypeSynthetic.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`
SIMIlluminationPatterns.Synthetic.apply
— Methodapply(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)
Ground Truth Models
Fluorescent Microspheres (beads)
SIMIlluminationPatterns.Synthetic.GroundTruthGenerator
— TypeSynthetic.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
SIMIlluminationPatterns.Synthetic.bead
— Functionbead([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 gridpeak_intensity = 1.0
: peak intensity valuesubpixel_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")
5×5 OffsetArray(::Matrix{Float64}, -2:2, -2:2) with eltype Float64 with indices -2:2×-2:2:
0.0 0.0 0.0705075 0.0 0.0
0.0 0.606779 0.892914 0.606779 0.0
0.0705075 0.892914 1.0 0.892914 0.0705075
0.0 0.606779 0.892914 0.606779 0.0
0.0 0.0 0.0705075 0.0 0.0
julia> Synthetic.bead(0.1u"μm", 50.5u"nm"; subpixel_shift=(-0.3,-0.2))
3×3 OffsetArray(::Matrix{Float64}, -1:1, -1:1) with eltype Float64 with indices -1:1×-1:1:
0.333333 0.737374 0.0808081
0.59596 1.0 0.20202
0.020202 0.141414 0.0
julia> Synthetic.bead(0.1u"μm", 50.5u"nm"; peak_intensity=0.5)
3×3 OffsetArray(::Matrix{Float64}, -1:1, -1:1) with eltype Float64 with indices -1:1×-1:1:
0.03 0.23 0.03
0.23 0.5 0.23
0.03 0.23 0.03
SIMIlluminationPatterns.Synthetic.beads
— Functionbeads(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 pixelsN::Int=1000
: Number of beads to generatepxsize::Tuple{Quantity,Quantity}=(30.5u"nm", 30.5u"nm")
: Pixel size in physical unitsbead_radius::Quantity=0.05u"μm"
: Radius of each beadmin_distance::Quantity=0.06u"μm"
: Minimum allowed distance between bead centersα_evanescent::Quantity=1/200u"nm"
: Evanescent field decay constant
SIMIlluminationPatterns.Synthetic.synthetic_beads_image
— Functionsynthetic_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 pixelsN::Int=1000
: Number of beads to generatepxsize::Tuple{Quantity,Quantity}=(30.5u"nm", 30.5u"nm")
: Pixel size in physical unitsbead_radius::Quantity=0.05u"μm"
: Radius of each beadmin_distance::Quantity=0.06u"μm"
: Minimum allowed distance between bead centersα_evanescent::Quantity=1/200u"nm"
: Evanescent field decay constantnoise_model::Distribution=Normal{Float32}(2.0503677f-12, 4*0.005893613f0)
: Statistical model for image noiseoptical_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:
- Random placement of beads with minimum separation distance (
min_distance
) - Evanescent field illumination
- Realistic noise
- 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)