1-
21"""
32 get_dimers(system::DiffusingMoleculeSystem)
43
@@ -9,6 +8,12 @@ Extract a new DiffusingMoleculeSystem containing only molecules in dimer state.
98
109# Returns
1110- `DiffusingMoleculeSystem`: New system containing only dimers
11+
12+ # Example
13+ ```julia
14+ # Extract only dimers from a system
15+ dimer_system = get_dimers(system)
16+ ```
1217"""
1318function get_dimers(system:: DiffusingMoleculeSystem )
1419 # Extract molecules in dimer state
@@ -35,31 +40,61 @@ Extract dimers from a sequence of system states.
3540
3641# Returns
3742- `Vector{DiffusingMoleculeSystem}`: Sequence of dimer-only states
43+
44+ # Example
45+ ```julia
46+ # Run simulation
47+ params = SmoluchowskiParams()
48+ systems = simulate(params)
49+
50+ # Extract dimers at each timepoint
51+ dimer_systems = get_dimers(systems)
52+ ```
3853"""
3954function get_dimers(systems:: Vector{<:DiffusingMoleculeSystem} )
4055 [get_dimers(system) for system in systems]
4156end
4257
4358"""
44- gen_dimer_images(systems::Vector{DiffusingMoleculeSystem}, psf::AbstractPSF; kwargs...)
59+ gen_dimer_images(systems::Vector{DiffusingMoleculeSystem}, psf::AbstractPSF;
60+ photons::Float64=1000.0, bg::Float64=5.0,
61+ frame_integration::Int=1, poisson_noise::Bool=true)
4562
4663Generate microscope images showing only dimers.
4764
4865# Arguments
4966- `systems::Vector{DiffusingMoleculeSystem}`: Sequence of system states
50- - `psf::PSF `: Point spread function model
67+ - `psf::AbstractPSF `: Point spread function model
5168
52- # Optional kwargs
69+ # Keyword Arguments
70+ - `photons::Float64=1000.0`: Base photon count for emitters
71+ - `bg::Float64=5.0`: Background photon count per pixel
5372- `frame_integration::Int=1`: Number of frames to integrate
5473- `poisson_noise::Bool=true`: Whether to add Poisson noise
5574
5675# Returns
5776- `Array{Float64,3}`: Stack of dimer-only images [ny, nx, frames]
77+
78+ # Example
79+ ```julia
80+ # Run simulation
81+ params = SmoluchowskiParams()
82+ systems = simulate(params)
83+
84+ # Generate images showing only dimers
85+ psf = Gaussian2D(0.15)
86+ dimer_images = gen_dimer_images(systems, psf;
87+ photons=2000.0,
88+ frame_integration=5)
89+ ```
5890"""
5991function gen_dimer_images(systems:: Vector{<:DiffusingMoleculeSystem} , psf:: AbstractPSF ;
60- frame_integration:: Int = 1 , poisson_noise:: Bool = true )
92+ photons:: Float64 = 1000.0 , bg:: Float64 = 5.0 ,
93+ frame_integration:: Int = 1 , poisson_noise:: Bool = true )
6194 dimer_systems = get_dimers(systems)
6295 gen_image_sequence(psf, dimer_systems;
96+ photons= photons,
97+ bg= bg,
6398 frame_integration= frame_integration,
6499 poisson_noise= poisson_noise)
65100end
@@ -74,6 +109,24 @@ Calculate the fraction of molecules in dimer state over time.
74109
75110# Returns
76111- `Vector{Float64}`: Dimer fraction at each timepoint
112+
113+ # Example
114+ ```julia
115+ # Run simulation
116+ params = SmoluchowskiParams()
117+ systems = simulate(params)
118+
119+ # Calculate dimer fraction over time
120+ dimer_fractions = analyze_dimer_fraction(systems)
121+
122+ # Plot the results
123+ using Plots
124+ times = range(0, params.t_max, length=length(systems))
125+ plot(times, dimer_fractions,
126+ xlabel="Time (s)",
127+ ylabel="Fraction of molecules in dimers",
128+ title="Dimer formation dynamics")
129+ ```
77130"""
78131function analyze_dimer_fraction(systems:: Vector{<:DiffusingMoleculeSystem} )
79132 map(systems) do system
@@ -83,3 +136,31 @@ function analyze_dimer_fraction(systems::Vector{<:DiffusingMoleculeSystem})
83136 end
84137end
85138
139+ """
140+ analyze_dimer_lifetime(systems::Vector{DiffusingMoleculeSystem})
141+
142+ Analyze the lifetime distribution of dimers.
143+
144+ # Arguments
145+ - `systems::Vector{DiffusingMoleculeSystem}`: Sequence of system states
146+
147+ # Returns
148+ - `Vector{Float64}`: Distribution of dimer lifetimes
149+
150+ # Note
151+ This function is not yet fully implemented.
152+ """
153+ function analyze_dimer_lifetime(systems:: Vector{<:DiffusingMoleculeSystem} )
154+ # Get time step from metadata
155+ if ! haskey(systems[1 ]. metadata, " simulation_parameters" )
156+ error(" System metadata missing simulation parameters" )
157+ end
158+
159+ params = systems[1 ]. metadata[" simulation_parameters" ]
160+ dt = params. dt
161+
162+ # TODO : Implement dimer lifetime tracking
163+ @warn " Dimer lifetime analysis not yet fully implemented"
164+
165+ return Float64[]
166+ end
0 commit comments