Skip to main content

fpm_rs/measurements/
metadata.rs

1use serde::{Deserialize, Serialize};
2
3/// Acquisition metadata associated with one measurement frame.
4#[derive(Clone, Debug, Serialize, Deserialize)]
5pub struct FrameMetadata {
6    /// Zero-based index in the current measurement stack.
7    pub frame_index: usize,
8    /// Optional individual illumination-source index; `None` can denote coded illumination.
9    pub illumination_index: Option<usize>,
10    /// Frame index in the original acquisition before subsetting or reordering.
11    #[serde(default)]
12    pub original_frame_index: Option<usize>,
13    /// Illumination index in the original acquisition before subsetting.
14    #[serde(default)]
15    pub original_illumination_index: Option<usize>,
16    /// Positive exposure time in caller-defined units; ratios are used for normalization.
17    pub exposure_time: f64,
18    /// Non-negative reconstruction weight; zero excludes the frame from the objective.
19    pub weight: f64,
20    /// Optional human-readable acquisition label.
21    pub label: Option<String>,
22}
23
24impl FrameMetadata {
25    /// Creates unit-exposure, unit-weight metadata whose current and original frame and
26    /// illumination indices all equal `frame_index`.
27    pub fn new(frame_index: usize) -> Self {
28        Self {
29            frame_index,
30            illumination_index: Some(frame_index),
31            original_frame_index: Some(frame_index),
32            original_illumination_index: Some(frame_index),
33            exposure_time: 1.0,
34            weight: 1.0,
35            label: None,
36        }
37    }
38}