@@ -58,12 +58,14 @@ using SMLMSim
5858
5959# Set diffusion simulation parameters
6060params = DiffusionSMLMParams(
61- density = 0.5 , # molecules per μm²
62- box_size = 10.0 , # μm
63- diff_monomer = 0.1 , # μm²/s
64- k_off = 0.2 , # s⁻¹ dimer dissociation rate
65- dt = 0.01 , # s simulation timestep
66- t_max = 10.0 # s total simulation time
61+ density = 0.5 , # molecules per μm²
62+ box_size = 10.0 , # μm
63+ diff_monomer = 0.1 , # μm²/s
64+ k_off = 0.2 , # s⁻¹ dimer dissociation rate
65+ dt = 0.01 , # s simulation timestep
66+ t_max = 10.0 , # s total simulation time
67+ camera_framerate = 10.0 , # 10 fps (100ms per frame)
68+ camera_exposure = 0.1 # 100ms exposure integrates 10 timesteps per frame
6769)
6870
6971# Run diffusion simulation
@@ -106,16 +108,53 @@ Create camera images from simulation results.
106108using MicroscopePSFs # Needed for PSF types
107109
108110# Generate images from diffusion simulation output
111+ # Note: Frame timing is controlled by DiffusionSMLMParams (camera_framerate, camera_exposure)
112+ # Multiple simulation timesteps are automatically integrated during simulate()
109113psf = GaussianPSF(0.15 ) # 150nm PSF width
110- # Use smld_model to avoid double-counting localization errors
111- images = gen_images(smld, psf;
112- frame_integration= 10 , # 10 simulation time steps for each camera frame
113- support= 1.0 # PSF support range
114- )
114+ images = gen_images(smld, psf;
115+ support= 1.0 , # PSF support radius in μm (faster than default Inf)
116+ poisson_noise= true # Add shot noise
117+ )
115118
116119println(" Generated $(size(images,3 )) camera images." )
117120```
118121
122+ ### sCMOS Camera with Realistic Noise
123+
124+ SMLMSim supports realistic sCMOS camera noise modeling with per-pixel calibration.
125+
126+ ``` julia
127+ using SMLMSim
128+ using MicroscopePSFs
129+
130+ # Create an sCMOS camera (128×128 pixels, 100nm pixels, 1.6 e⁻ read noise)
131+ camera_scmos = SCMOSCamera(128 , 128 , 0.1 , 1.6 )
132+
133+ # Run static simulation with sCMOS camera
134+ params = StaticSMLMParams(density= 1.0 , σ_psf= 0.13 )
135+ smld_true, smld_model, smld_noisy = simulate(
136+ params,
137+ pattern= Nmer2D(n= 8 , d= 0.1 ),
138+ camera= camera_scmos
139+ )
140+
141+ # Generate images with full sCMOS noise model
142+ # (quantum efficiency, Poisson, read noise, gain, offset)
143+ psf = GaussianPSF(0.15 )
144+ images_scmos = gen_images(smld_noisy, psf, bg= 10.0 , camera_noise= true )
145+
146+ # For diffusion simulations
147+ diff_params = DiffusionSMLMParams(density= 0.5 , box_size= 10.0 )
148+ smld_diff = simulate(diff_params; camera= camera_scmos, override_count= 10 )
149+ ```
150+
151+ The sCMOS noise model applies:
152+ 1 . ** Quantum efficiency** : Photon → photoelectron conversion
153+ 2 . ** Poisson noise** : Shot noise on photoelectrons
154+ 3 . ** Read noise** : Gaussian noise per pixel
155+ 4 . ** Gain** : Electron → ADU conversion
156+ 5 . ** Offset** : Dark level addition
157+
119158## Example Workflow: Static Simulation & Visualization
120159
121160``` julia
@@ -150,10 +189,63 @@ display(fig)
150189# save("smlm_hexamer.png", fig)
151190```
152191
192+ ## Example Workflow: Diffusion with Realistic sCMOS Noise
193+
194+ This example demonstrates a complete workflow for single-particle tracking with realistic camera noise:
195+
196+ ``` julia
197+ using SMLMSim
198+ using MicroscopePSFs
199+ using Statistics
200+
201+ # Create sCMOS camera with realistic noise parameters
202+ camera_scmos = SCMOSCamera(64 , 64 , 0.1 , 1.6 ) # 64×64 pixels, 100nm/px, 1.6 e⁻ read noise
203+
204+ # Run diffusion simulation
205+ params = DiffusionSMLMParams(
206+ density = 1.0 , # 1 molecule/μm²
207+ box_size = 6.4 , # 6.4×6.4 μm field
208+ diff_monomer = 0.1 , # 0.1 μm²/s diffusion
209+ t_max = 0.5 , # 0.5 second total
210+ camera_framerate = 100.0 # 100 fps
211+ )
212+ smld = simulate(params; camera= camera_scmos, photons= 200.0 )
213+
214+ # Generate images with full sCMOS noise model
215+ # (quantum efficiency, Poisson, read noise, gain, offset)
216+ psf = GaussianPSF(0.13 ) # 130nm PSF
217+ images_scmos = gen_images(smld, psf, bg= 10.0 , camera_noise= true )
218+
219+ # For comparison: same data with ideal camera (Poisson noise only)
220+ camera_ideal = IdealCamera(64 , 64 , 0.1 )
221+ smld_ideal = BasicSMLD(smld. emitters, camera_ideal, smld. n_frames, smld. n_datasets)
222+ images_ideal = gen_images(smld_ideal, psf, bg= 10.0 , poisson_noise= true )
223+
224+ # Compare statistics
225+ println(" sCMOS: mean=$(round(mean(images_scmos), digits= 1 )) ADU, std=$(round(std(images_scmos), digits= 1 )) " )
226+ println(" Ideal: mean=$(round(mean(images_ideal), digits= 1 )) photons, std=$(round(std(images_ideal), digits= 1 )) " )
227+ # sCMOS includes offset (~100 ADU) and spatially-varying gain/readnoise
228+ ```
229+
153230## Further Information
154231
155232For more detailed examples, API documentation, and explanations of the underlying models, please see the [ Full Documentation] ( https://JuliaSMLM.github.io/SMLMSim.jl/dev ) .
156233
234+ ### Demo Scripts
235+
236+ The ` dev/ ` folder contains demonstration scripts showing sCMOS camera functionality:
237+
238+ - ** ` dev/scmos_quick_demo.jl ` ** - Fast verification that sCMOS works (~ 5 seconds)
239+ - ** ` dev/scmos_video.jl ` ** - Generate MP4 showing sCMOS vs Ideal side-by-side
240+ - ** ` dev/scmos_demo.jl ` ** - Full diffusion simulation with extreme sCMOS artifacts
241+
242+ Run from repository root:
243+ ``` bash
244+ julia --project dev/scmos_quick_demo.jl
245+ ```
246+
247+ Outputs are saved to ` dev/outputs/ ` (gitignored).
248+
157249## Contributors
158250
159251- [ JuliaSMLM Team] ( https://github.com/JuliaSMLM )
0 commit comments