Skip to main content

fpm_rs/diagnostics/
context.rs

1use ndarray::Array2;
2
3use super::{FrameDiagnosticRecord, RawFrameStatisticsRecord};
4
5/// Diagnostic quantity a callback asks the runner to compute for a hook.
6#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub enum DiagnosticRequest {
8    /// Weight-normalized scalar objective for the current completed work.
9    Objective,
10    /// Objective value for every acquisition frame.
11    PerFrameError,
12    /// Raw measured-intensity distribution statistics for each frame.
13    RawFrameStats,
14    /// Per-frame reference-versus-prediction comparison metrics.
15    FrameSummaries,
16    /// High-resolution reconstructed object amplitude snapshot.
17    ObjectAmplitude,
18    /// High-resolution wrapped reconstructed object phase in radians.
19    ObjectPhase,
20    /// Low-resolution pupil amplitude and wrapped phase snapshots.
21    Pupil,
22    /// Predicted-minus-measured intensity image for every acquisition frame.
23    ResidualImages,
24}
25
26/// Optional diagnostics computed for one callback hook.
27#[derive(Clone, Debug, Default)]
28pub struct Diagnostics {
29    /// Weight-normalized objective, when requested.
30    pub objective: Option<f64>,
31    /// Objective in acquisition-frame order, when requested.
32    pub per_frame_objective: Option<Vec<f64>>,
33    /// Raw frame statistics in acquisition-frame order, when requested.
34    pub raw_frame_statistics: Option<Vec<RawFrameStatisticsRecord>>,
35    /// Frame comparison records in acquisition-frame order, when requested.
36    pub frame_diagnostics: Option<Vec<FrameDiagnosticRecord>>,
37    /// Owned high-resolution `(row, column)` object amplitude snapshot.
38    pub object_amplitude: Option<Array2<f64>>,
39    /// Owned high-resolution wrapped object phase snapshot in radians.
40    pub object_phase: Option<Array2<f64>>,
41    /// Owned low-resolution pupil amplitude snapshot.
42    pub pupil_amplitude: Option<Array2<f64>>,
43    /// Owned low-resolution wrapped pupil phase snapshot in radians.
44    pub pupil_phase: Option<Array2<f64>>,
45    /// Owned predicted-minus-measured intensity images in acquisition-frame order.
46    pub residual_images: Option<Vec<Array2<f64>>>,
47}