@@ -27,7 +27,7 @@ using MicroscopePSFs
2727
2828# Set up simulation parameters
2929params = DiffusionSMLMParams(
30- density = 0.5 , # molecules per μm²
30+ density = 2.0 , # molecules per μm²
3131 box_size = 10.0, # μm
3232 diff_monomer = 0.1, # μm²/s
3333 diff_dimer = 0.05, # μm²/s
@@ -136,14 +136,12 @@ camera = IdealCamera(1:pixels, 1:pixels, pixelsize)
136136# Create PSF model
137137psf = MicroscopePSFs.GaussianPSF(0.15) # 150nm PSF width
138138
139- # Generate microscope images with frame integration
140- # The frame_integration parameter determines how many simulation time
141- # points are integrated into each output frame
142- # Note: For diffusion simulations, the smld already contains correct positions without
143- # localization uncertainty, so we can use it directly for generating camera images
139+ # Generate microscope images from simulation
140+ # For diffusion simulations, the camera integration time (exposure) has already been
141+ # modeled in the simulation process, so each frame already includes the positions
142+ # from all emitters that appeared during the exposure window
144143images = gen_images(smld, psf;
145144 bg=5.0, # background photons per pixel
146- frame_integration=10, # integrate 10 simulation steps per frame
147145 poisson_noise=true # add photon counting noise
148146)
149147
@@ -162,11 +160,12 @@ heatmap!(ax, transpose(images[:, :, frame_to_show]), colormap=:inferno)
162160fig
163161```
164162
165- The ` frame_integration ` parameter is crucial for realistic diffusion imaging :
163+ The simulation already handles motion blur effects in a realistic way :
166164
167- - With high values, each camera frame integrates multiple diffusion steps, creating motion blur effects typical in real microscopy
168- - The integrated frames combine positions from multiple simulation time points, accurately modeling camera exposure
169- - Fast-moving particles appear more blurred while slow or stationary ones remain sharp
165+ - The ` camera_exposure ` parameter in the simulation determines how long each camera frame integrates photons
166+ - During the exposure window, multiple emitter positions from the same track_id are captured
167+ - This naturally creates motion blur effects where fast-moving particles appear more blurred
168+ - The resulting images accurately represent what would be seen in real microscopy experiments
170169
171170## Analyzing Dimer Formation
172171
@@ -311,15 +310,14 @@ fig = display_frames(images_all, images_dimers, frame_indices)
311310
312311## Two Interacting Particles
313312
314- This example shows two particles interacting in a small box with reflecting boundary conditions:
313+ This example shows two particles interacting in a small box with reflecting boundary conditions, using the new starting conditions feature to place them at specific initial positions :
315314
316315``` @example
317316using SMLMSim
318317using CairoMakie
319318
320319# Set up a minimal simulation with just two particles
321320params = DiffusionSMLMParams(
322- density = 2.0, # 2 particles in a 1×1 μm box
323321 box_size = 1.0, # 1 μm box for close interactions
324322 diff_monomer = 0.1, # μm²/s
325323 diff_dimer = 0.05, # μm²/s
@@ -329,20 +327,42 @@ params = DiffusionSMLMParams(
329327 dt = 0.01, # s
330328 t_max = 5.0, # s
331329 boundary = "reflecting", # Reflecting boundaries
332- camera_framerate = 10.0 # fps
330+ camera_framerate = 10.0 # fps
331+ )
332+
333+ # Create two particles with specific initial positions
334+ particle1 = DiffusingEmitter2D{Float64}(
335+ 0.2, 0.2, # Position in lower-left quadrant
336+ 1000.0, # Photons
337+ 0.0, # Initial timestamp
338+ 1, # Initial frame
339+ 1, # Dataset
340+ 1, # track_id
341+ :monomer, # Initial state
342+ nothing # No partner initially
343+ )
344+
345+ particle2 = DiffusingEmitter2D{Float64}(
346+ 0.8, 0.8, # Position in upper-right quadrant
347+ 1000.0, # Photons
348+ 0.0, # Initial timestamp
349+ 1, # Initial frame
350+ 1, # Dataset
351+ 2, # track_id
352+ :monomer, # Initial state
353+ nothing # No partner initially
333354)
334355
335- # Run simulation - override density to get exactly 2 particles
336- smld = simulate(params; override_count=2, photons=1000.0 )
356+ # Run simulation with custom starting positions
357+ smld = simulate(params; starting_conditions=[particle1, particle2] )
337358
338- # Get trajectories using the built-in function
339359track_smlds = get_tracks(smld)
340360
341361# Convert to the format needed for plotting
342362trajectories = []
343363for track_smld in track_smlds
344364 # Get ID from first emitter
345- id = track_smld.emitters[1].id
365+ id = track_smld.emitters[1].track_id
346366
347367 # Sort by timestamp
348368 sort!(track_smld.emitters, by = e -> e.timestamp)
0 commit comments