@@ -52,6 +52,7 @@ Represents fitted 2D localization results with uncertainties and temporal/tracki
5252- `bg::T`: fitted background in photons/pixel
5353- `σ_x::T`: uncertainty in x position in microns
5454- `σ_y::T`: uncertainty in y position in microns
55+ - `σ_xy::T`: covariance between x and y uncertainties (microns², 0 = axis-aligned)
5556- `σ_photons::T`: uncertainty in photon count
5657- `σ_bg::T`: uncertainty in background in photons/pixel
5758- `frame::Int`: frame number in acquisition sequence
@@ -66,6 +67,7 @@ mutable struct Emitter2DFit{T} <: AbstractEmitter
6667 bg:: T
6768 σ_x:: T
6869 σ_y:: T
70+ σ_xy:: T
6971 σ_photons:: T
7072 σ_bg:: T
7173 frame:: Int
@@ -88,6 +90,9 @@ Represents fitted 3D localization results with uncertainties and temporal/tracki
8890- `σ_x::T`: uncertainty in x position in microns
8991- `σ_y::T`: uncertainty in y position in microns
9092- `σ_z::T`: uncertainty in z position in microns
93+ - `σ_xy::T`: covariance between x and y (microns², 0 = uncorrelated)
94+ - `σ_xz::T`: covariance between x and z (microns², 0 = uncorrelated)
95+ - `σ_yz::T`: covariance between y and z (microns², 0 = uncorrelated)
9196- `σ_photons::T`: uncertainty in photon count
9297- `σ_bg::T`: uncertainty in background in photons/pixel
9398- `frame::Int`: frame number in acquisition sequence
@@ -104,6 +109,9 @@ mutable struct Emitter3DFit{T} <: AbstractEmitter
104109 σ_x:: T
105110 σ_y:: T
106111 σ_z:: T
112+ σ_xy:: T
113+ σ_xz:: T
114+ σ_yz:: T
107115 σ_photons:: T
108116 σ_bg:: T
109117 frame:: Int
115123
116124"""
117125 Emitter2DFit{T}(x, y, photons, bg, σ_x, σ_y, σ_photons, σ_bg;
118- frame=0 , dataset=1, track_id=0, id=0) where T
126+ σ_xy=zero(T), frame=1 , dataset=1, track_id=0, id=0) where T
119127
120128Convenience constructor for 2D localization fit results with optional identification parameters.
121129
@@ -131,6 +139,7 @@ Convenience constructor for 2D localization fit results with optional identifica
131139- `σ_bg::T`: uncertainty in background level
132140
133141## Optional Keywords
142+ - `σ_xy::T=0`: covariance between x and y uncertainties (microns², 0 = axis-aligned)
134143- `frame::Int=1`: frame number in acquisition sequence
135144- `dataset::Int=1`: identifier for specific acquisition/dataset
136145- `track_id::Int=0`: identifier for linking localizations across frames
@@ -146,23 +155,24 @@ emitter = Emitter2DFit{Float64}(
146155 50.0, 2.0 # σ_photons, σ_bg
147156)
148157
149- # Create emitter with specific frame and dataset
158+ # Create emitter with covariance for rotated uncertainty ellipse
150159emitter = Emitter2DFit{Float64}(
151160 1.0, 2.0, 1000.0, 10.0, 0.01, 0.01, 50.0, 2.0;
152- frame=5, dataset=2
161+ σ_xy=0.005, frame=5, dataset=2
153162)
154163```
155164"""
156- function Emitter2DFit{T}(x:: T , y:: T , photons:: T , bg:: T ,
165+ function Emitter2DFit{T}(x:: T , y:: T , photons:: T , bg:: T ,
157166 σ_x:: T , σ_y:: T , σ_photons:: T , σ_bg:: T ;
158- frame:: Int = 1 , dataset:: Int = 1 , track_id:: Int = 0 , id:: Int = 0 ) where T
159- Emitter2DFit{T}(x, y, photons, bg, σ_x, σ_y, σ_photons, σ_bg,
167+ σ_xy :: T = zero(T), frame:: Int = 1 , dataset:: Int = 1 , track_id:: Int = 0 , id:: Int = 0 ) where T
168+ Emitter2DFit{T}(x, y, photons, bg, σ_x, σ_y, σ_xy, σ_photons, σ_bg,
160169 frame, dataset, track_id, id)
161170end
162171
163172"""
164173 Emitter3DFit{T}(x, y, z, photons, bg, σ_x, σ_y, σ_z, σ_photons, σ_bg;
165- frame=0, dataset=1, track_id=0, id=0) where T
174+ σ_xy=zero(T), σ_xz=zero(T), σ_yz=zero(T),
175+ frame=1, dataset=1, track_id=0, id=0) where T
166176
167177Convenience constructor for 3D localization fit results with optional identification parameters.
168178
@@ -180,6 +190,9 @@ Convenience constructor for 3D localization fit results with optional identifica
180190- `σ_bg::T`: uncertainty in background level
181191
182192## Optional Keywords
193+ - `σ_xy::T=0`: covariance between x and y (microns², 0 = uncorrelated)
194+ - `σ_xz::T=0`: covariance between x and z (microns², 0 = uncorrelated)
195+ - `σ_yz::T=0`: covariance between y and z (microns², 0 = uncorrelated)
183196- `frame::Int=1`: frame number in acquisition sequence
184197- `dataset::Int=1`: identifier for specific acquisition/dataset
185198- `track_id::Int=0`: identifier for linking localizations across frames
@@ -195,17 +208,18 @@ emitter = Emitter3DFit{Float64}(
195208 50.0, 2.0 # σ_photons, σ_bg
196209)
197210
198- # Create emitter with specific frame and tracking
211+ # Create emitter with full 3D covariance
199212emitter = Emitter3DFit{Float64}(
200213 1.0, 2.0, -0.5, 1000.0, 10.0, 0.01, 0.01, 0.02, 50.0, 2.0;
201- frame=5, track_id=1
214+ σ_xy=0.005, σ_xz=0.002, σ_yz=0.003, frame=5, track_id=1
202215)
203216```
204217"""
205- function Emitter3DFit{T}(x:: T , y:: T , z:: T , photons:: T , bg:: T ,
218+ function Emitter3DFit{T}(x:: T , y:: T , z:: T , photons:: T , bg:: T ,
206219 σ_x:: T , σ_y:: T , σ_z:: T , σ_photons:: T , σ_bg:: T ;
220+ σ_xy:: T = zero(T), σ_xz:: T = zero(T), σ_yz:: T = zero(T),
207221 frame:: Int = 1 , dataset:: Int = 1 , track_id:: Int = 0 , id:: Int = 0 ) where T
208- Emitter3DFit{T}(x, y, z, photons, bg, σ_x, σ_y, σ_z, σ_photons, σ_bg,
222+ Emitter3DFit{T}(x, y, z, photons, bg, σ_x, σ_y, σ_z, σ_xy, σ_xz, σ_yz, σ_photons, σ_bg,
209223 frame, dataset, track_id, id)
210224end
211225
@@ -263,6 +277,7 @@ function Base.show(io::IO, ::MIME"text/plain", e::Emitter2DFit{T}) where T
263277 println(io, " Uncertainties:" )
264278 println(io, " σ_x: $(e. σ_x) μm" )
265279 println(io, " σ_y: $(e. σ_y) μm" )
280+ e. σ_xy != 0 && println(io, " σ_xy: $(e. σ_xy) μm²" )
266281 println(io, " σ_photons: $(e. σ_photons) " )
267282 println(io, " σ_bg: $(e. σ_bg) " )
268283 println(io, " Frame: $(e. frame) " )
@@ -289,6 +304,13 @@ function Base.show(io::IO, ::MIME"text/plain", e::Emitter3DFit{T}) where T
289304 println(io, " σ_x: $(e. σ_x) μm" )
290305 println(io, " σ_y: $(e. σ_y) μm" )
291306 println(io, " σ_z: $(e. σ_z) μm" )
307+ has_cov = e. σ_xy != 0 || e. σ_xz != 0 || e. σ_yz != 0
308+ if has_cov
309+ println(io, " Covariances:" )
310+ e. σ_xy != 0 && println(io, " σ_xy: $(e. σ_xy) μm²" )
311+ e. σ_xz != 0 && println(io, " σ_xz: $(e. σ_xz) μm²" )
312+ e. σ_yz != 0 && println(io, " σ_yz: $(e. σ_yz) μm²" )
313+ end
292314 println(io, " σ_photons: $(e. σ_photons) " )
293315 println(io, " σ_bg: $(e. σ_bg) " )
294316 println(io, " Frame: $(e. frame) " )
0 commit comments