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
<!– TODO: <21-11-24> –>
Components of the Model
SIMIlluminationPatterns.Synthetic.ModelComponent — Type
Synthetic.ModelComponentA 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>)– transformdataoptionally depending on theground_truth.
Below are the implemented ModelComponents in the natural order of application. <!– TODO: <21-11-24> –>
Illumination
SIMIlluminationPatterns.Synthetic.Illumination — Type
Illumination <: ModelComponentIlluminate 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))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)Noise
SIMIlluminationPatterns.Synthetic.AdditiveNoise — Type
AdditiveNoise{D<:Distribution} <: ModelComponentAdditive 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 — 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);SIMIlluminationPatterns.Synthetic.PhotonShotNoise — Type
PhotonShotNoise <: ModelComponentAdd 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 — 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);<!– TODO: <21-11-24> –>
Microscopy transfer
SIMIlluminationPatterns.Synthetic.OpticalTransfer — Type
OpticalTransfer <: `ModelComponent`Simulate light transfer through the optical system by via a transfer function (TransferFunction)
Examples
julia> using TransferFunctions: BornWolf
julia> bw = BornWolf(444u"nm", 1.4, 1.2);
julia> ot = OpticalTransfer(bw);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)<!– TODO: <21-11-24> –>
Other Model Components
SIMIlluminationPatterns.Synthetic.DownSampling — Type
Synthetic.DownSampling <: Synthetic.ModelComponentReduce 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 — 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)Ground Truth Models
Fluorescent Microspheres (beads)
SIMIlluminationPatterns.Synthetic.GroundTruthGenerator — Type
Synthetic.GroundTruthGeneratorA 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.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 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 noiseillumination_patterns::Vector{<:Union{Nothing,IlluminationPattern}}=[nothing]: Illumination patterns to illuminate the image with; a separate output image is returned for each pattern (nothingresults 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:
- 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)