1use serde::{Deserialize, Serialize};
2
3use super::PixelDataType;
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub struct Metadata {
7 pub contents: Option<Contents>,
8 pub channels: Option<Vec<Channel>>,
9}
10
11#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12pub struct Contents {
13 pub channel_count: u32,
14 pub frame_count: u32,
15}
16
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18pub struct Channel {
19 pub channel: ChannelMeta,
20 pub loops: Option<LoopIndices>,
21 pub microscope: Microscope,
22 pub volume: Volume,
23}
24
25#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
26pub struct ChannelMeta {
27 pub name: String,
28 pub index: u32,
29 pub color: Color,
30 pub emission_lambda_nm: Option<f64>,
31 pub excitation_lambda_nm: Option<f64>,
32}
33
34#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
35pub struct Color {
36 pub r: u8,
37 pub g: u8,
38 pub b: u8,
39 pub a: u8,
40}
41
42impl Color {
43 pub fn from_abgr_u32(val: u32) -> Self {
44 Self {
45 r: (val & 0xFF) as u8,
46 g: ((val >> 8) & 0xFF) as u8,
47 b: ((val >> 16) & 0xFF) as u8,
48 a: ((val >> 24) & 0xFF) as u8,
49 }
50 }
51
52 pub fn as_hex(&self) -> String {
53 format!("#{:02x}{:02x}{:02x}", self.r, self.g, self.b)
54 }
55}
56
57#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
58pub struct LoopIndices {
59 pub ne_time_loop: Option<u32>,
60 pub time_loop: Option<u32>,
61 pub xy_pos_loop: Option<u32>,
62 pub z_stack_loop: Option<u32>,
63 pub custom_loop: Option<u32>,
64}
65
66#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
67pub struct Microscope {
68 pub objective_magnification: Option<f64>,
69 pub objective_name: Option<String>,
70 pub objective_numerical_aperture: Option<f64>,
71 pub zoom_magnification: Option<f64>,
72 pub immersion_refractive_index: Option<f64>,
73 pub projective_magnification: Option<f64>,
74 pub pinhole_diameter_um: Option<f64>,
75}
76
77#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
78pub struct Volume {
79 pub axes_calibrated: (bool, bool, bool),
80 pub axes_calibration: (f64, f64, f64),
81 pub axes_interpretation: (AxisInterpretation, AxisInterpretation, AxisInterpretation),
82 pub bits_per_component_in_memory: u32,
83 pub bits_per_component_significant: u32,
84 pub camera_transformation_matrix: (f64, f64, f64, f64),
85 pub component_count: u32,
86 pub component_data_type: PixelDataType,
87 pub voxel_count: (u32, u32, u32),
88 pub component_maxima: Option<Vec<f64>>,
89 pub component_minima: Option<Vec<f64>>,
90 pub pixel_to_stage_transformation_matrix: Option<(f64, f64, f64, f64, f64, f64)>,
91}
92
93#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
94#[serde(rename_all = "lowercase")]
95pub enum AxisInterpretation {
96 Distance,
97 Time,
98}