Observer Models
Flexpose implements multiple mathematical observer models to evaluate image quality, including Ideal, NPWE, and SNRU observers.
Observer Registry
flexpose.observer
Base Observer & Context
flexpose.observer.base
BaseObserver
Bases: ABC
Source code in flexpose/observer/base.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
compute_gamma(params)
abstractmethod
Compute the observer performance metric gamma for a single acquisition.
Parameters
params : AcquisitionParams - focus_size_xy: focal spot (x, y) in cm - exposure_time_s: integration time in seconds
Returns
float A positive scalar gamma. Implementations should raise ValueError if required context (e.g., weights, detector curves) is missing or if inputs are invalid.
Source code in flexpose/observer/base.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
flexpose.observer.context
ImagingContext
dataclass
Read-only container for shared imaging primitives used by observers.
Attributes
freq : (F,) ndarray Spatial frequency axis (cycles per unit length). dqe_interp : CubicSpline | None Interpolator over freq for detector DQE (already normalized if provided). mtf_interp : CubicSpline | None Interpolator over freq for detector MTF. sid : float Source-to-image distance. sod : float Source-to-object distance. velocity_xy : (2,) tuple[float, float] Object velocity along x and y. size_xy : (2,) tuple[float, float] Object size along x and y (used by task MTFs). shape : str Object shape: 'cylinder'|'disk'|'rectangular' (same as ContrastObject.shape).
Source code in flexpose/observer/context.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
magnification
property
Imaging magnification = SID / SOD.
dqe()
Detector DQE sampled on self.freq; clipped to non-negative.
Source code in flexpose/observer/context.py
40 41 42 43 44 45 46 | |
mtf_detector()
Detector MTF sampled on self.freq; clipped to non-negative.
Source code in flexpose/observer/context.py
48 49 50 51 52 53 54 | |
build_context(config)
Construct ImagingContext from ConfigData. - Frequency grid uses min(object.size_xy) to define Nyquist and spans [1e-5, 2*Nyquist]. - DQE is normalized by its first tabulated value.
Source code in flexpose/observer/context.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
Implementations
flexpose.observer.ideal
flexpose.observer.npwe
flexpose.observer.snru
Modulation Transfer Functions (MTF)
flexpose.observer.system_mtf
flexpose.observer.task_mtf
Task Weights
flexpose.observer.weights
Weights
dataclass
Weights for observer performance metric, defined per dimension and sampled on the same frequency axis as the MTFs.
Source code in flexpose/observer/weights.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
from_spec(freq, size_xy, spec)
classmethod
Build weights from a single spec
- None or '' => flat weights (ones)
- 'auto' => Gaussian around 1/(2d) with sigma=0.05*loc (per current code)
- Path/str => TSV table (freq, [wx, wy] or single column applied to both); cubic-spline onto freq
Source code in flexpose/observer/weights.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
init_band(freq, size_xy)
classmethod
Auto = Gaussian "band" around 1/(2d) with sigma = 0.05loc Normalized to integrate to 1 per dim, but not necessarily bounded by 1 at each freq.
Source code in flexpose/observer/weights.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
init_from_table(freq, size_xy, path)
classmethod
TSV with columns
freq [cycles/cm], weight_x, weight_y
Or just (freq, w) to apply same weights to both dims.
Source code in flexpose/observer/weights.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
with_area_normalized()
Return a copy where each dim integrates to 1.0 over freq (trapezoidal).
Source code in flexpose/observer/weights.py
45 46 47 48 49 50 51 52 53 54 55 | |
Diagnostics
flexpose.observer.diagnostics
save_observer_diagnostics(obs, params, out_path, *, logger=None, options=None)
Save a PNG summarizing the components used by the observer on each axis
Plots per axis
- Task MTF
- System MTF (focus x motion)
- (Optional) System x Detector MTF
- (Optional) Detector MTF and DQE (on a secondary axis)
- Task Weight (scaled to [0, 1] for plotting if selected)
Returns:
| Type | Description |
|---|---|
Path
|
The saved path. |
Source code in flexpose/observer/diagnostics.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |