ome_metadata/
ome.rs

1use anyhow::{Result, anyhow};
2use enum_utils::{FromStr, IterVariants};
3#[cfg(feature = "python")]
4use pyo3::types::{PyDict, PyInt, PyString};
5#[cfg(feature = "python")]
6use pyo3::{Bound, IntoPyObject, PyErr, PyResult, Python};
7use serde::{Deserialize, Serialize};
8use std::cmp::PartialEq;
9
10#[cfg(feature = "python")]
11macro_rules! impl_enum_into_py_object {
12    ($($t:ty $(,)?)*) => {
13        $(
14            impl<'py> IntoPyObject<'py> for $t {
15                type Target = PyString;
16                type Output = Bound<'py, Self::Target>;
17                type Error = PyErr;
18
19                fn into_pyobject(self, py: Python<'py>) -> PyResult<Self::Output> {
20                    Ok(format!("{:?}", self).into_pyobject(py)?)
21                }
22            }
23        )*
24    };
25}
26
27#[cfg(feature = "python")]
28macro_rules! impl_empty_struct_into_py_object {
29    ($($t:ty $(,)?)*) => {
30        $(
31            impl<'py> IntoPyObject<'py> for $t {
32                type Target = PyInt;
33                type Output = Bound<'py, Self::Target>;
34                type Error = PyErr;
35
36                fn into_pyobject(self, py: Python<'py>) -> PyResult<Self::Output> {
37                    Ok(0usize.into_pyobject(py)?)
38                }
39            }
40        )*
41    };
42}
43
44#[cfg(feature = "python")]
45macro_rules! impl_boxed_struct_into_py_object {
46    ($($t:ty $(,)?)*) => {
47        $(
48            impl<'py> IntoPyObject<'py> for Box<$t> {
49                type Target = PyDict;
50                type Output = Bound<'py, Self::Target>;
51                type Error = PyErr;
52
53                fn into_pyobject(self, py: Python<'py>) -> PyResult<Self::Output> {
54                    (*self).into_pyobject(py)
55                }
56            }
57        )*
58    };
59}
60
61#[cfg(feature = "python")]
62impl_enum_into_py_object!(
63    ArcType,
64    BinDataCompressionType,
65    BinningType,
66    ChannelIlluminationType,
67    ChannelAcquisitionModeType,
68    ChannelContrastMethodType,
69    DetectorType,
70    ExperimentItemType,
71    FilamentType,
72    FilterType,
73    FontFamilyType,
74    LaserType,
75    LaserLaserMediumType,
76    LaserPulseType,
77    MarkerType,
78    MicrobeamManipulationItemType,
79    MicroscopeType,
80    NamingConventionType,
81    ObjectiveCorrectionType,
82    ObjectiveImmersionType,
83    ObjectiveSettingsMediumType,
84    PixelsDimensionOrderType,
85    PixelType,
86    ShapeFillRuleType,
87    ShapeFontStyleType
88);
89
90#[cfg(feature = "python")]
91impl_empty_struct_into_py_object!(MetadataOnly, XmlAnnotationValue);
92#[cfg(feature = "python")]
93impl_boxed_struct_into_py_object!(Channel, Image);
94
95#[cfg_attr(feature = "python", derive(IntoPyObject))]
96#[derive(Clone, Debug, Serialize, Deserialize)]
97pub struct AffineTransform {
98    #[serde(rename = "@A00")]
99    pub a00: f32,
100    #[serde(rename = "@A10")]
101    pub a10: f32,
102    #[serde(rename = "@A01")]
103    pub a01: f32,
104    #[serde(rename = "@A11")]
105    pub a11: f32,
106    #[serde(rename = "@A02")]
107    pub a02: f32,
108    #[serde(rename = "@A12")]
109    pub a12: f32,
110}
111#[cfg_attr(feature = "python", derive(IntoPyObject))]
112#[derive(Clone, Debug, Serialize, Deserialize)]
113pub struct Annotation {
114    #[serde(rename = "@ID")]
115    pub id: String,
116    #[serde(default, rename = "@Namespace")]
117    pub namespace: Option<String>,
118    #[serde(default, rename = "@Annotator")]
119    pub annotator: Option<String>,
120    #[serde(default, rename = "Description")]
121    pub description: Option<String>,
122    #[serde(default, rename = "AnnotationRef")]
123    pub annotation_ref: Vec<AnnotationRef>,
124}
125#[cfg_attr(feature = "python", derive(IntoPyObject))]
126#[derive(Clone, Debug, Serialize, Deserialize)]
127pub struct AnnotationRef {
128    #[serde(rename = "@ID")]
129    pub id: String,
130}
131#[cfg_attr(feature = "python", derive(IntoPyObject))]
132#[derive(Clone, Debug, Serialize, Deserialize)]
133pub struct Arc {
134    #[serde(default, rename = "@Manufacturer")]
135    pub manufacturer: Option<String>,
136    #[serde(default, rename = "@Model")]
137    pub model: Option<String>,
138    #[serde(default, rename = "@SerialNumber")]
139    pub serial_number: Option<String>,
140    #[serde(default, rename = "@LotNumber")]
141    pub lot_number: Option<String>,
142    #[serde(rename = "@ID")]
143    pub id: String,
144    #[serde(default, rename = "@Power")]
145    pub power: Option<f32>,
146    #[serde(default = "Arc::default_power_unit", rename = "@PowerUnit")]
147    pub power_unit: UnitsPower,
148    #[serde(default, rename = "@Type")]
149    pub r#type: Option<ArcType>,
150    #[serde(default, rename = "AnnotationRef")]
151    pub annotation_ref: Vec<AnnotationRef>,
152}
153impl Arc {
154    pub fn default_power_unit() -> UnitsPower {
155        UnitsPower::W
156    }
157}
158#[derive(Clone, Debug, Serialize, Deserialize)]
159pub enum ArcType {
160    #[serde(rename = "Hg")]
161    Hg,
162    #[serde(rename = "Xe")]
163    Xe,
164    #[serde(rename = "HgXe")]
165    HgXe,
166    #[serde(rename = "Other")]
167    Other,
168}
169#[cfg_attr(feature = "python", derive(IntoPyObject))]
170#[derive(Clone, Debug, Serialize, Deserialize)]
171pub struct BinData {
172    #[serde(default = "BinData::default_compression", rename = "@Compression")]
173    pub compression: BinDataCompressionType,
174    #[serde(rename = "@BigEndian")]
175    pub big_endian: bool,
176    #[serde(rename = "@Length")]
177    pub length: i64,
178    #[serde(rename = "$text")]
179    pub content: String,
180}
181impl BinData {
182    pub fn default_compression() -> BinDataCompressionType {
183        BinDataCompressionType::None
184    }
185}
186#[derive(Clone, Debug, Serialize, Deserialize)]
187pub enum BinDataCompressionType {
188    #[serde(rename = "zlib")]
189    Zlib,
190    #[serde(rename = "bzip2")]
191    Bzip2,
192    #[serde(rename = "none")]
193    None,
194}
195#[cfg_attr(feature = "python", derive(IntoPyObject))]
196#[derive(Clone, Debug, Serialize, Deserialize)]
197pub struct BinaryFile {
198    #[serde(rename = "@FileName")]
199    pub file_name: String,
200    #[serde(rename = "@Size")]
201    pub size: i64,
202    #[serde(default, rename = "@MIMEType")]
203    pub mime_type: Option<String>,
204    #[serde(rename = "$value")]
205    pub content: BinaryFileContent,
206}
207#[cfg_attr(feature = "python", derive(IntoPyObject))]
208#[derive(Clone, Debug, Serialize, Deserialize)]
209pub enum BinaryFileContent {
210    #[serde(rename = "External")]
211    External(External),
212    #[serde(rename = "BinData")]
213    BinData(BinData),
214}
215#[derive(Clone, Debug, Serialize, Deserialize)]
216pub enum BinningType {
217    #[serde(rename = "1x1")]
218    _1X1,
219    #[serde(rename = "2x2")]
220    _2X2,
221    #[serde(rename = "4x4")]
222    _4X4,
223    #[serde(rename = "8x8")]
224    _8X8,
225    #[serde(rename = "Other")]
226    Other,
227}
228#[cfg_attr(feature = "python", derive(IntoPyObject))]
229#[derive(Clone, Debug, Serialize, Deserialize)]
230pub struct BooleanAnnotation {
231    #[serde(rename = "@ID")]
232    pub id: String,
233    #[serde(default, rename = "@Namespace")]
234    pub namespace: Option<String>,
235    #[serde(default, rename = "@Annotator")]
236    pub annotator: Option<String>,
237    #[serde(default, rename = "Description")]
238    pub description: Option<String>,
239    #[serde(default, rename = "AnnotationRef")]
240    pub annotation_ref: Vec<AnnotationRef>,
241    #[serde(rename = "Value")]
242    pub value: bool,
243}
244#[cfg_attr(feature = "python", derive(IntoPyObject))]
245#[derive(Clone, Debug, Serialize, Deserialize)]
246pub struct Channel {
247    #[serde(rename = "@ID")]
248    pub id: String,
249    #[serde(default, rename = "@Name")]
250    pub name: Option<String>,
251    #[serde(default, rename = "@SamplesPerPixel")]
252    pub samples_per_pixel: Option<i32>,
253    #[serde(default, rename = "@IlluminationType")]
254    pub illumination_type: Option<ChannelIlluminationType>,
255    #[serde(default, rename = "@PinholeSize")]
256    pub pinhole_size: Option<f32>,
257    #[serde(
258        default = "Channel::default_pinhole_size_unit",
259        rename = "@PinholeSizeUnit"
260    )]
261    pub pinhole_size_unit: UnitsLength,
262    #[serde(default, rename = "@AcquisitionMode")]
263    pub acquisition_mode: Option<ChannelAcquisitionModeType>,
264    #[serde(default, rename = "@ContrastMethod")]
265    pub contrast_method: Option<ChannelContrastMethodType>,
266    #[serde(default, rename = "@ExcitationWavelength")]
267    pub excitation_wavelength: Option<f32>,
268    #[serde(
269        default = "Channel::default_excitation_wavelength_unit",
270        rename = "@ExcitationWavelengthUnit"
271    )]
272    pub excitation_wavelength_unit: UnitsLength,
273    #[serde(default, rename = "@EmissionWavelength")]
274    pub emission_wavelength: Option<f32>,
275    #[serde(
276        default = "Channel::default_emission_wavelength_unit",
277        rename = "@EmissionWavelengthUnit"
278    )]
279    pub emission_wavelength_unit: UnitsLength,
280    #[serde(default, rename = "@Fluor")]
281    pub fluor: Option<String>,
282    #[serde(default, rename = "@NDFilter")]
283    pub nd_filter: Option<f32>,
284    #[serde(default, rename = "@PockelCellSetting")]
285    pub pockel_cell_setting: Option<i32>,
286    #[serde(default = "Channel::default_color", rename = "@Color")]
287    pub color: i32,
288    #[serde(default, rename = "LightSourceSettings")]
289    pub light_source_settings: Option<LightSourceSettings>,
290    #[serde(default, rename = "DetectorSettings")]
291    pub detector_settings: Option<DetectorSettings>,
292    #[serde(default, rename = "FilterSetRef")]
293    pub filter_set_ref: Option<AnnotationRef>,
294    #[serde(default, rename = "AnnotationRef")]
295    pub annotation_ref: Vec<AnnotationRef>,
296    #[serde(default, rename = "LightPath")]
297    pub light_path: Option<LightPath>,
298}
299impl Channel {
300    pub fn default_pinhole_size_unit() -> UnitsLength {
301        UnitsLength::um
302    }
303    pub fn default_color() -> i32 {
304        0
305    }
306    pub fn default_excitation_wavelength_unit() -> UnitsLength {
307        UnitsLength::nm
308    }
309    pub fn default_emission_wavelength_unit() -> UnitsLength {
310        UnitsLength::nm
311    }
312}
313#[derive(Clone, Debug, Serialize, Deserialize)]
314pub enum ChannelAcquisitionModeType {
315    #[serde(rename = "WideField")]
316    WideField,
317    #[serde(rename = "LaserScanningConfocalMicroscopy")]
318    LaserScanningConfocalMicroscopy,
319    #[serde(rename = "SpinningDiskConfocal")]
320    SpinningDiskConfocal,
321    #[serde(rename = "SlitScanConfocal")]
322    SlitScanConfocal,
323    #[serde(rename = "MultiPhotonMicroscopy")]
324    MultiPhotonMicroscopy,
325    #[serde(rename = "StructuredIllumination")]
326    StructuredIllumination,
327    #[serde(rename = "SingleMoleculeImaging")]
328    SingleMoleculeImaging,
329    #[serde(rename = "TotalInternalReflection")]
330    TotalInternalReflection,
331    #[serde(rename = "FluorescenceLifetime")]
332    FluorescenceLifetime,
333    #[serde(rename = "SpectralImaging")]
334    SpectralImaging,
335    #[serde(rename = "FluorescenceCorrelationSpectroscopy")]
336    FluorescenceCorrelationSpectroscopy,
337    #[serde(rename = "NearFieldScanningOpticalMicroscopy")]
338    NearFieldScanningOpticalMicroscopy,
339    #[serde(rename = "SecondHarmonicGenerationImaging")]
340    SecondHarmonicGenerationImaging,
341    #[serde(rename = "PALM")]
342    Palm,
343    #[serde(rename = "STORM")]
344    Storm,
345    #[serde(rename = "STED")]
346    Sted,
347    #[serde(rename = "TIRF")]
348    Tirf,
349    #[serde(rename = "FSM")]
350    Fsm,
351    #[serde(rename = "LCM")]
352    Lcm,
353    #[serde(rename = "Other")]
354    Other,
355    #[serde(rename = "BrightField")]
356    BrightField,
357    #[serde(rename = "SweptFieldConfocal")]
358    SweptFieldConfocal,
359    #[serde(rename = "SPIM")]
360    Spim,
361}
362#[derive(Clone, Debug, Serialize, Deserialize)]
363pub enum ChannelContrastMethodType {
364    #[serde(rename = "Brightfield")]
365    Brightfield,
366    #[serde(rename = "Phase")]
367    Phase,
368    #[serde(rename = "DIC")]
369    Dic,
370    #[serde(rename = "HoffmanModulation")]
371    HoffmanModulation,
372    #[serde(rename = "ObliqueIllumination")]
373    ObliqueIllumination,
374    #[serde(rename = "PolarizedLight")]
375    PolarizedLight,
376    #[serde(rename = "Darkfield")]
377    Darkfield,
378    #[serde(rename = "Fluorescence")]
379    Fluorescence,
380    #[serde(rename = "Other")]
381    Other,
382}
383#[derive(Clone, Debug, Serialize, Deserialize)]
384pub enum ChannelIlluminationType {
385    #[serde(rename = "Transmitted")]
386    Transmitted,
387    #[serde(rename = "Epifluorescence")]
388    Epifluorescence,
389    #[serde(rename = "Oblique")]
390    Oblique,
391    #[serde(rename = "NonLinear")]
392    NonLinear,
393    #[serde(rename = "Other")]
394    Other,
395}
396#[cfg_attr(feature = "python", derive(IntoPyObject))]
397#[derive(Clone, Debug, Serialize, Deserialize)]
398pub struct CommentAnnotation {
399    #[serde(rename = "@ID")]
400    pub id: String,
401    #[serde(default, rename = "@Namespace")]
402    pub namespace: Option<String>,
403    #[serde(default, rename = "@Annotator")]
404    pub annotator: Option<String>,
405    #[serde(default, rename = "Description")]
406    pub description: Option<String>,
407    #[serde(default, rename = "AnnotationRef")]
408    pub annotation_ref: Vec<AnnotationRef>,
409    #[serde(rename = "Value")]
410    pub value: String,
411}
412#[cfg_attr(feature = "python", derive(IntoPyObject))]
413#[derive(Clone, Debug, Serialize, Deserialize)]
414pub struct Dataset {
415    #[serde(default, rename = "@Name")]
416    pub name: Option<String>,
417    #[serde(rename = "@ID")]
418    pub id: String,
419    #[serde(default, rename = "Description")]
420    pub description: Option<String>,
421    #[serde(default, rename = "ExperimenterRef")]
422    pub experimenter_ref: Option<AnnotationRef>,
423    #[serde(default, rename = "ExperimenterGroupRef")]
424    pub experimenter_group_ref: Option<AnnotationRef>,
425    #[serde(default, rename = "ImageRef")]
426    pub image_ref: Vec<AnnotationRef>,
427    #[serde(default, rename = "AnnotationRef")]
428    pub annotation_ref: Vec<AnnotationRef>,
429}
430#[cfg_attr(feature = "python", derive(IntoPyObject))]
431#[derive(Clone, Debug, Serialize, Deserialize)]
432pub struct Detector {
433    #[serde(default, rename = "@Manufacturer")]
434    pub manufacturer: Option<String>,
435    #[serde(default, rename = "@Model")]
436    pub model: Option<String>,
437    #[serde(default, rename = "@SerialNumber")]
438    pub serial_number: Option<String>,
439    #[serde(default, rename = "@LotNumber")]
440    pub lot_number: Option<String>,
441    #[serde(default, rename = "@Gain")]
442    pub gain: Option<f32>,
443    #[serde(default, rename = "@Voltage")]
444    pub voltage: Option<f32>,
445    #[serde(default = "Detector::default_voltage_unit", rename = "@VoltageUnit")]
446    pub voltage_unit: UnitsElectricPotential,
447    #[serde(default, rename = "@Offset")]
448    pub offset: Option<f32>,
449    #[serde(default, rename = "@Zoom")]
450    pub zoom: Option<f32>,
451    #[serde(default, rename = "@AmplificationGain")]
452    pub amplification_gain: Option<f32>,
453    #[serde(rename = "@ID")]
454    pub id: String,
455    #[serde(default, rename = "@Type")]
456    pub r#type: Option<DetectorType>,
457    #[serde(default, rename = "AnnotationRef")]
458    pub annotation_ref: Vec<AnnotationRef>,
459}
460impl Detector {
461    pub fn default_voltage_unit() -> UnitsElectricPotential {
462        UnitsElectricPotential::V
463    }
464}
465#[cfg_attr(feature = "python", derive(IntoPyObject))]
466#[derive(Clone, Debug, Serialize, Deserialize)]
467pub struct DetectorSettings {
468    #[serde(rename = "@ID")]
469    pub id: String,
470    #[serde(default, rename = "@Offset")]
471    pub offset: Option<f32>,
472    #[serde(default, rename = "@Gain")]
473    pub gain: Option<f32>,
474    #[serde(default, rename = "@Voltage")]
475    pub voltage: Option<f32>,
476    #[serde(
477        default = "DetectorSettings::default_voltage_unit",
478        rename = "@VoltageUnit"
479    )]
480    pub voltage_unit: UnitsElectricPotential,
481    #[serde(default, rename = "@Zoom")]
482    pub zoom: Option<f32>,
483    #[serde(default, rename = "@ReadOutRate")]
484    pub read_out_rate: Option<f32>,
485    #[serde(
486        default = "DetectorSettings::default_read_out_rate_unit",
487        rename = "@ReadOutRateUnit"
488    )]
489    pub read_out_rate_unit: UnitsFrequency,
490    #[serde(default, rename = "@Binning")]
491    pub binning: Option<BinningType>,
492    #[serde(default, rename = "@Integration")]
493    pub integration: Option<i32>,
494}
495impl DetectorSettings {
496    pub fn default_voltage_unit() -> UnitsElectricPotential {
497        UnitsElectricPotential::V
498    }
499    pub fn default_read_out_rate_unit() -> UnitsFrequency {
500        UnitsFrequency::Hz
501    }
502}
503#[derive(Clone, Debug, Serialize, Deserialize)]
504pub enum DetectorType {
505    #[serde(rename = "CCD")]
506    Ccd,
507    #[serde(rename = "IntensifiedCCD")]
508    IntensifiedCcd,
509    #[serde(rename = "AnalogVideo")]
510    AnalogVideo,
511    #[serde(rename = "PMT")]
512    Pmt,
513    #[serde(rename = "Photodiode")]
514    Photodiode,
515    #[serde(rename = "Spectroscopy")]
516    Spectroscopy,
517    #[serde(rename = "LifetimeImaging")]
518    LifetimeImaging,
519    #[serde(rename = "CorrelationSpectroscopy")]
520    CorrelationSpectroscopy,
521    #[serde(rename = "FTIR")]
522    Ftir,
523    #[serde(rename = "EMCCD")]
524    Emccd,
525    #[serde(rename = "APD")]
526    Apd,
527    #[serde(rename = "CMOS")]
528    Cmos,
529    #[serde(rename = "EBCCD")]
530    Ebccd,
531    #[serde(rename = "Other")]
532    Other,
533}
534#[cfg_attr(feature = "python", derive(IntoPyObject))]
535#[derive(Clone, Debug, Serialize, Deserialize)]
536pub struct Dichroic {
537    #[serde(default, rename = "@Manufacturer")]
538    pub manufacturer: Option<String>,
539    #[serde(default, rename = "@Model")]
540    pub model: Option<String>,
541    #[serde(default, rename = "@SerialNumber")]
542    pub serial_number: Option<String>,
543    #[serde(default, rename = "@LotNumber")]
544    pub lot_number: Option<String>,
545    #[serde(rename = "@ID")]
546    pub id: String,
547    #[serde(default, rename = "AnnotationRef")]
548    pub annotation_ref: Vec<AnnotationRef>,
549}
550#[cfg_attr(feature = "python", derive(IntoPyObject))]
551#[derive(Clone, Debug, Serialize, Deserialize)]
552pub struct DoubleAnnotation {
553    #[serde(rename = "@ID")]
554    pub id: String,
555    #[serde(default, rename = "@Namespace")]
556    pub namespace: Option<String>,
557    #[serde(default, rename = "@Annotator")]
558    pub annotator: Option<String>,
559    #[serde(default, rename = "Description")]
560    pub description: Option<String>,
561    #[serde(default, rename = "AnnotationRef")]
562    pub annotation_ref: Vec<AnnotationRef>,
563    #[serde(rename = "Value")]
564    pub value: f64,
565}
566#[cfg_attr(feature = "python", derive(IntoPyObject))]
567#[derive(Clone, Debug, Serialize, Deserialize)]
568pub struct Ellipse {
569    #[serde(default, rename = "@FillColor")]
570    pub fill_color: Option<i32>,
571    #[serde(default, rename = "@FillRule")]
572    pub fill_rule: Option<ShapeFillRuleType>,
573    #[serde(default, rename = "@StrokeColor")]
574    pub stroke_color: Option<i32>,
575    #[serde(default, rename = "@StrokeWidth")]
576    pub stroke_width: Option<f32>,
577    #[serde(
578        default = "Ellipse::default_stroke_width_unit",
579        rename = "@StrokeWidthUnit"
580    )]
581    pub stroke_width_unit: UnitsLength,
582    #[serde(default, rename = "@StrokeDashArray")]
583    pub stroke_dash_array: Option<String>,
584    #[serde(default, rename = "@Text")]
585    pub text: Option<String>,
586    #[serde(default, rename = "@FontFamily")]
587    pub font_family: Option<FontFamilyType>,
588    #[serde(default, rename = "@FontSize")]
589    pub font_size: Option<i32>,
590    #[serde(default = "Ellipse::default_font_size_unit", rename = "@FontSizeUnit")]
591    pub font_size_unit: UnitsLength,
592    #[serde(default, rename = "@FontStyle")]
593    pub font_style: Option<ShapeFontStyleType>,
594    #[serde(default, rename = "@Locked")]
595    pub locked: Option<bool>,
596    #[serde(rename = "@ID")]
597    pub id: String,
598    #[serde(default, rename = "@TheZ")]
599    pub the_z: Option<i32>,
600    #[serde(default, rename = "@TheT")]
601    pub the_t: Option<i32>,
602    #[serde(default, rename = "@TheC")]
603    pub the_c: Option<i32>,
604    #[serde(rename = "@X")]
605    pub x: f32,
606    #[serde(rename = "@Y")]
607    pub y: f32,
608    #[serde(rename = "@RadiusX")]
609    pub radius_x: f32,
610    #[serde(rename = "@RadiusY")]
611    pub radius_y: f32,
612    #[serde(default, rename = "Transform")]
613    pub transform: Option<AffineTransform>,
614    #[serde(default, rename = "AnnotationRef")]
615    pub annotation_ref: Vec<AnnotationRef>,
616}
617impl Ellipse {
618    pub fn default_stroke_width_unit() -> UnitsLength {
619        UnitsLength::Pixel
620    }
621    pub fn default_font_size_unit() -> UnitsLength {
622        UnitsLength::Pixel
623    }
624}
625#[cfg_attr(feature = "python", derive(IntoPyObject))]
626#[derive(Clone, Debug, Serialize, Deserialize)]
627pub struct Experiment {
628    #[serde(default, rename = "@Type")]
629    pub r#type: Option<ExperimentType>,
630    #[serde(rename = "@ID")]
631    pub id: String,
632    #[serde(default, rename = "Description")]
633    pub description: Option<String>,
634    #[serde(default, rename = "ExperimenterRef")]
635    pub experimenter_ref: Option<AnnotationRef>,
636    #[serde(default, rename = "MicrobeamManipulation")]
637    pub microbeam_manipulation: Vec<MicrobeamManipulation>,
638}
639#[derive(Clone, Debug, Serialize, Deserialize)]
640pub enum ExperimentItemType {
641    #[serde(rename = "FP")]
642    Fp,
643    #[serde(rename = "FRET")]
644    Fret,
645    #[serde(rename = "TimeLapse")]
646    TimeLapse,
647    #[serde(rename = "FourDPlus")]
648    FourDPlus,
649    #[serde(rename = "Screen")]
650    Screen,
651    #[serde(rename = "Immunocytochemistry")]
652    Immunocytochemistry,
653    #[serde(rename = "Immunofluorescence")]
654    Immunofluorescence,
655    #[serde(rename = "FISH")]
656    Fish,
657    #[serde(rename = "Electrophysiology")]
658    Electrophysiology,
659    #[serde(rename = "IonImaging")]
660    IonImaging,
661    #[serde(rename = "Colocalization")]
662    Colocalization,
663    #[serde(rename = "PGIDocumentation")]
664    PgiDocumentation,
665    #[serde(rename = "FluorescenceLifetime")]
666    FluorescenceLifetime,
667    #[serde(rename = "SpectralImaging")]
668    SpectralImaging,
669    #[serde(rename = "Photobleaching")]
670    Photobleaching,
671    #[serde(rename = "SPIM")]
672    Spim,
673    #[serde(rename = "Other")]
674    Other,
675}
676#[cfg_attr(feature = "python", derive(IntoPyObject))]
677#[derive(Clone, Debug, Serialize, Deserialize, Default)]
678pub struct ExperimentType(pub Vec<ExperimentItemType>);
679#[cfg_attr(feature = "python", derive(IntoPyObject))]
680#[derive(Clone, Debug, Serialize, Deserialize)]
681pub struct Experimenter {
682    #[serde(rename = "@ID")]
683    pub id: String,
684    #[serde(default, rename = "@FirstName")]
685    pub first_name: Option<String>,
686    #[serde(default, rename = "@MiddleName")]
687    pub middle_name: Option<String>,
688    #[serde(default, rename = "@LastName")]
689    pub last_name: Option<String>,
690    #[serde(default, rename = "@Email")]
691    pub email: Option<String>,
692    #[serde(default, rename = "@Institution")]
693    pub institution: Option<String>,
694    #[serde(default, rename = "@UserName")]
695    pub user_name: Option<String>,
696    #[serde(default, rename = "AnnotationRef")]
697    pub annotation_ref: Vec<AnnotationRef>,
698}
699#[cfg_attr(feature = "python", derive(IntoPyObject))]
700#[derive(Clone, Debug, Serialize, Deserialize)]
701pub struct ExperimenterGroup {
702    #[serde(default, rename = "@Name")]
703    pub name: Option<String>,
704    #[serde(rename = "@ID")]
705    pub id: String,
706    #[serde(default, rename = "Description")]
707    pub description: Option<String>,
708    #[serde(default, rename = "ExperimenterRef")]
709    pub experimenter_ref: Vec<AnnotationRef>,
710    #[serde(default, rename = "Leader")]
711    pub leader: Vec<AnnotationRef>,
712    #[serde(default, rename = "AnnotationRef")]
713    pub annotation_ref: Vec<AnnotationRef>,
714}
715#[cfg_attr(feature = "python", derive(IntoPyObject))]
716#[derive(Clone, Debug, Serialize, Deserialize)]
717pub struct External {
718    #[serde(rename = "@href")]
719    pub href: String,
720    #[serde(rename = "@SHA1")]
721    pub sha_1: String,
722    #[serde(default = "External::default_compression", rename = "@Compression")]
723    pub compression: BinDataCompressionType,
724}
725impl External {
726    pub fn default_compression() -> BinDataCompressionType {
727        BinDataCompressionType::None
728    }
729}
730#[cfg_attr(feature = "python", derive(IntoPyObject))]
731#[derive(Clone, Debug, Serialize, Deserialize)]
732pub struct Filament {
733    #[serde(default, rename = "@Manufacturer")]
734    pub manufacturer: Option<String>,
735    #[serde(default, rename = "@Model")]
736    pub model: Option<String>,
737    #[serde(default, rename = "@SerialNumber")]
738    pub serial_number: Option<String>,
739    #[serde(default, rename = "@LotNumber")]
740    pub lot_number: Option<String>,
741    #[serde(rename = "@ID")]
742    pub id: String,
743    #[serde(default, rename = "@Power")]
744    pub power: Option<f32>,
745    #[serde(default = "Filament::default_power_unit", rename = "@PowerUnit")]
746    pub power_unit: UnitsPower,
747    #[serde(default, rename = "@Type")]
748    pub r#type: Option<FilamentType>,
749    #[serde(default, rename = "AnnotationRef")]
750    pub annotation_ref: Vec<AnnotationRef>,
751}
752impl Filament {
753    pub fn default_power_unit() -> UnitsPower {
754        UnitsPower::W
755    }
756}
757#[derive(Clone, Debug, Serialize, Deserialize)]
758pub enum FilamentType {
759    #[serde(rename = "Incandescent")]
760    Incandescent,
761    #[serde(rename = "Halogen")]
762    Halogen,
763    #[serde(rename = "Other")]
764    Other,
765}
766#[cfg_attr(feature = "python", derive(IntoPyObject))]
767#[derive(Clone, Debug, Serialize, Deserialize)]
768pub struct FileAnnotation {
769    #[serde(rename = "@ID")]
770    pub id: String,
771    #[serde(default, rename = "@Namespace")]
772    pub namespace: Option<String>,
773    #[serde(default, rename = "@Annotator")]
774    pub annotator: Option<String>,
775    #[serde(default, rename = "Description")]
776    pub description: Option<String>,
777    #[serde(default, rename = "AnnotationRef")]
778    pub annotation_ref: Vec<AnnotationRef>,
779    #[serde(rename = "BinaryFile")]
780    pub binary_file: BinaryFile,
781}
782#[cfg_attr(feature = "python", derive(IntoPyObject))]
783#[derive(Clone, Debug, Serialize, Deserialize)]
784pub struct Filter {
785    #[serde(default, rename = "@Manufacturer")]
786    pub manufacturer: Option<String>,
787    #[serde(default, rename = "@Model")]
788    pub model: Option<String>,
789    #[serde(default, rename = "@SerialNumber")]
790    pub serial_number: Option<String>,
791    #[serde(default, rename = "@LotNumber")]
792    pub lot_number: Option<String>,
793    #[serde(default, rename = "@Type")]
794    pub r#type: Option<FilterType>,
795    #[serde(default, rename = "@FilterWheel")]
796    pub filter_wheel: Option<String>,
797    #[serde(rename = "@ID")]
798    pub id: String,
799    #[serde(default, rename = "TransmittanceRange")]
800    pub transmittance_range: Option<TransmittanceRange>,
801    #[serde(default, rename = "AnnotationRef")]
802    pub annotation_ref: Vec<AnnotationRef>,
803}
804#[cfg_attr(feature = "python", derive(IntoPyObject))]
805#[derive(Clone, Debug, Serialize, Deserialize)]
806pub struct FilterSet {
807    #[serde(default, rename = "@Manufacturer")]
808    pub manufacturer: Option<String>,
809    #[serde(default, rename = "@Model")]
810    pub model: Option<String>,
811    #[serde(default, rename = "@SerialNumber")]
812    pub serial_number: Option<String>,
813    #[serde(default, rename = "@LotNumber")]
814    pub lot_number: Option<String>,
815    #[serde(rename = "@ID")]
816    pub id: String,
817    #[serde(default, rename = "ExcitationFilterRef")]
818    pub excitation_filter_ref: Vec<AnnotationRef>,
819    #[serde(default, rename = "DichroicRef")]
820    pub dichroic_ref: Option<AnnotationRef>,
821    #[serde(default, rename = "EmissionFilterRef")]
822    pub emission_filter_ref: Vec<AnnotationRef>,
823}
824#[derive(Clone, Debug, Serialize, Deserialize)]
825pub enum FilterType {
826    #[serde(rename = "Dichroic")]
827    Dichroic,
828    #[serde(rename = "LongPass")]
829    LongPass,
830    #[serde(rename = "ShortPass")]
831    ShortPass,
832    #[serde(rename = "BandPass")]
833    BandPass,
834    #[serde(rename = "MultiPass")]
835    MultiPass,
836    #[serde(rename = "NeutralDensity")]
837    NeutralDensity,
838    #[serde(rename = "Tuneable")]
839    Tuneable,
840    #[serde(rename = "Other")]
841    Other,
842}
843#[cfg_attr(feature = "python", derive(IntoPyObject))]
844#[derive(Clone, Debug, Serialize, Deserialize)]
845pub struct Folder {
846    #[serde(rename = "@ID")]
847    pub id: String,
848    #[serde(default, rename = "@Name")]
849    pub name: Option<String>,
850    #[serde(default, rename = "Description")]
851    pub description: Option<String>,
852    #[serde(default, rename = "FolderRef")]
853    pub folder_ref: Vec<AnnotationRef>,
854    #[serde(default, rename = "ImageRef")]
855    pub image_ref: Vec<AnnotationRef>,
856    #[serde(default, rename = "ROIRef")]
857    pub roi_ref: Vec<AnnotationRef>,
858    #[serde(default, rename = "AnnotationRef")]
859    pub annotation_ref: Vec<AnnotationRef>,
860}
861#[derive(Clone, Debug, Serialize, Deserialize)]
862pub enum FontFamilyType {
863    #[serde(rename = "serif")]
864    Serif,
865    #[serde(rename = "sans-serif")]
866    SansSerif,
867    #[serde(rename = "cursive")]
868    Cursive,
869    #[serde(rename = "fantasy")]
870    Fantasy,
871    #[serde(rename = "monospace")]
872    Monospace,
873}
874#[cfg_attr(feature = "python", derive(IntoPyObject))]
875#[derive(Clone, Debug, Serialize, Deserialize)]
876pub struct GenericExcitationSource {
877    #[serde(default, rename = "@Manufacturer")]
878    pub manufacturer: Option<String>,
879    #[serde(default, rename = "@Model")]
880    pub model: Option<String>,
881    #[serde(default, rename = "@SerialNumber")]
882    pub serial_number: Option<String>,
883    #[serde(default, rename = "@LotNumber")]
884    pub lot_number: Option<String>,
885    #[serde(rename = "@ID")]
886    pub id: String,
887    #[serde(default, rename = "@Power")]
888    pub power: Option<f32>,
889    #[serde(
890        default = "GenericExcitationSource::default_power_unit",
891        rename = "@PowerUnit"
892    )]
893    pub power_unit: UnitsPower,
894    #[serde(default, rename = "AnnotationRef")]
895    pub annotation_ref: Vec<AnnotationRef>,
896    #[serde(default, rename = "Map")]
897    pub map: Option<MapType>,
898}
899impl GenericExcitationSource {
900    pub fn default_power_unit() -> UnitsPower {
901        UnitsPower::W
902    }
903}
904#[cfg_attr(feature = "python", derive(IntoPyObject))]
905#[derive(Clone, Debug, Serialize, Deserialize)]
906pub struct Image {
907    #[serde(rename = "@ID")]
908    pub id: String,
909    #[serde(default, rename = "@Name")]
910    pub name: Option<String>,
911    #[serde(default, rename = "AcquisitionDate")]
912    pub acquisition_date: Option<String>,
913    #[serde(default, rename = "ExperimenterRef")]
914    pub experimenter_ref: Option<AnnotationRef>,
915    #[serde(default, rename = "Description")]
916    pub description: Option<String>,
917    #[serde(default, rename = "ExperimentRef")]
918    pub experiment_ref: Option<AnnotationRef>,
919    #[serde(default, rename = "ExperimenterGroupRef")]
920    pub experimenter_group_ref: Option<AnnotationRef>,
921    #[serde(default, rename = "InstrumentRef")]
922    pub instrument_ref: Option<AnnotationRef>,
923    #[serde(default, rename = "ObjectiveSettings")]
924    pub objective_settings: Option<ObjectiveSettings>,
925    #[serde(default, rename = "ImagingEnvironment")]
926    pub imaging_environment: Option<ImagingEnvironment>,
927    #[serde(default, rename = "StageLabel")]
928    pub stage_label: Option<StageLabel>,
929    #[serde(rename = "Pixels")]
930    pub pixels: Pixels,
931    #[serde(default, rename = "ROIRef")]
932    pub roi_ref: Vec<AnnotationRef>,
933    #[serde(default, rename = "MicrobeamManipulationRef")]
934    pub microbeam_manipulation_ref: Vec<AnnotationRef>,
935    #[serde(default, rename = "AnnotationRef")]
936    pub annotation_ref: Vec<AnnotationRef>,
937}
938#[cfg_attr(feature = "python", derive(IntoPyObject))]
939#[derive(Clone, Debug, Serialize, Deserialize)]
940pub struct ImagingEnvironment {
941    #[serde(default, rename = "@Temperature")]
942    pub temperature: Option<f32>,
943    #[serde(
944        default = "ImagingEnvironment::default_temperature_unit",
945        rename = "@TemperatureUnit"
946    )]
947    pub temperature_unit: UnitsTemperature,
948    #[serde(default, rename = "@AirPressure")]
949    pub air_pressure: Option<f32>,
950    #[serde(
951        default = "ImagingEnvironment::default_air_pressure_unit",
952        rename = "@AirPressureUnit"
953    )]
954    pub air_pressure_unit: UnitsPressure,
955    #[serde(default, rename = "@Humidity")]
956    pub humidity: Option<f32>,
957    #[serde(default, rename = "@CO2Percent")]
958    pub co_2_percent: Option<f32>,
959    #[serde(default, rename = "Map")]
960    pub map: Option<MapType>,
961}
962impl ImagingEnvironment {
963    pub fn default_temperature_unit() -> UnitsTemperature {
964        UnitsTemperature::C
965    }
966    pub fn default_air_pressure_unit() -> UnitsPressure {
967        UnitsPressure::atm
968    }
969}
970#[cfg_attr(feature = "python", derive(IntoPyObject))]
971#[derive(Clone, Debug, Serialize, Deserialize)]
972pub struct Instrument {
973    #[serde(rename = "@ID")]
974    pub id: String,
975    #[serde(default, rename = "Microscope")]
976    pub microscope: Option<Microscope>,
977    #[serde(default, rename = "LightSourceGroup")]
978    pub light_source_group: Vec<LightSourceGroup>,
979    #[serde(default, rename = "Detector")]
980    pub detector: Vec<Detector>,
981    #[serde(default, rename = "Objective")]
982    pub objective: Vec<Objective>,
983    #[serde(default, rename = "FilterSet")]
984    pub filter_set: Vec<FilterSet>,
985    #[serde(default, rename = "Filter")]
986    pub filter: Vec<Filter>,
987    #[serde(default, rename = "Dichroic")]
988    pub dichroic: Vec<Dichroic>,
989    #[serde(default, rename = "AnnotationRef")]
990    pub annotation_ref: Vec<AnnotationRef>,
991}
992#[cfg_attr(feature = "python", derive(IntoPyObject))]
993#[derive(Clone, Debug, Serialize, Deserialize)]
994pub struct Label {
995    #[serde(default, rename = "@FillColor")]
996    pub fill_color: Option<i32>,
997    #[serde(default, rename = "@FillRule")]
998    pub fill_rule: Option<ShapeFillRuleType>,
999    #[serde(default, rename = "@StrokeColor")]
1000    pub stroke_color: Option<i32>,
1001    #[serde(default, rename = "@StrokeWidth")]
1002    pub stroke_width: Option<f32>,
1003    #[serde(
1004        default = "Label::default_stroke_width_unit",
1005        rename = "@StrokeWidthUnit"
1006    )]
1007    pub stroke_width_unit: UnitsLength,
1008    #[serde(default, rename = "@StrokeDashArray")]
1009    pub stroke_dash_array: Option<String>,
1010    #[serde(default, rename = "@Text")]
1011    pub text: Option<String>,
1012    #[serde(default, rename = "@FontFamily")]
1013    pub font_family: Option<FontFamilyType>,
1014    #[serde(default, rename = "@FontSize")]
1015    pub font_size: Option<i32>,
1016    #[serde(default = "Label::default_font_size_unit", rename = "@FontSizeUnit")]
1017    pub font_size_unit: UnitsLength,
1018    #[serde(default, rename = "@FontStyle")]
1019    pub font_style: Option<ShapeFontStyleType>,
1020    #[serde(default, rename = "@Locked")]
1021    pub locked: Option<bool>,
1022    #[serde(rename = "@ID")]
1023    pub id: String,
1024    #[serde(default, rename = "@TheZ")]
1025    pub the_z: Option<i32>,
1026    #[serde(default, rename = "@TheT")]
1027    pub the_t: Option<i32>,
1028    #[serde(default, rename = "@TheC")]
1029    pub the_c: Option<i32>,
1030    #[serde(rename = "@X")]
1031    pub x: f32,
1032    #[serde(rename = "@Y")]
1033    pub y: f32,
1034    #[serde(default, rename = "Transform")]
1035    pub transform: Option<AffineTransform>,
1036    #[serde(default, rename = "AnnotationRef")]
1037    pub annotation_ref: Vec<AnnotationRef>,
1038}
1039impl Label {
1040    pub fn default_stroke_width_unit() -> UnitsLength {
1041        UnitsLength::Pixel
1042    }
1043    pub fn default_font_size_unit() -> UnitsLength {
1044        UnitsLength::Pixel
1045    }
1046}
1047#[cfg_attr(feature = "python", derive(IntoPyObject))]
1048#[derive(Clone, Debug, Serialize, Deserialize)]
1049pub struct Laser {
1050    #[serde(default, rename = "@Manufacturer")]
1051    pub manufacturer: Option<String>,
1052    #[serde(default, rename = "@Model")]
1053    pub model: Option<String>,
1054    #[serde(default, rename = "@SerialNumber")]
1055    pub serial_number: Option<String>,
1056    #[serde(default, rename = "@LotNumber")]
1057    pub lot_number: Option<String>,
1058    #[serde(rename = "@ID")]
1059    pub id: String,
1060    #[serde(default, rename = "@Power")]
1061    pub power: Option<f32>,
1062    #[serde(default = "Laser::default_power_unit", rename = "@PowerUnit")]
1063    pub power_unit: UnitsPower,
1064    #[serde(default, rename = "@Type")]
1065    pub r#type: Option<LaserType>,
1066    #[serde(default, rename = "@LaserMedium")]
1067    pub laser_medium: Option<LaserLaserMediumType>,
1068    #[serde(default, rename = "@Wavelength")]
1069    pub wavelength: Option<f32>,
1070    #[serde(default = "Laser::default_wavelength_unit", rename = "@WavelengthUnit")]
1071    pub wavelength_unit: UnitsLength,
1072    #[serde(default, rename = "@FrequencyMultiplication")]
1073    pub frequency_multiplication: Option<i32>,
1074    #[serde(default, rename = "@Tuneable")]
1075    pub tuneable: Option<bool>,
1076    #[serde(default, rename = "@Pulse")]
1077    pub pulse: Option<LaserPulseType>,
1078    #[serde(default, rename = "@PockelCell")]
1079    pub pockel_cell: Option<bool>,
1080    #[serde(default, rename = "@RepetitionRate")]
1081    pub repetition_rate: Option<f32>,
1082    #[serde(
1083        default = "Laser::default_repetition_rate_unit",
1084        rename = "@RepetitionRateUnit"
1085    )]
1086    pub repetition_rate_unit: UnitsFrequency,
1087    #[serde(default, rename = "AnnotationRef")]
1088    pub annotation_ref: Vec<AnnotationRef>,
1089    #[serde(default, rename = "Pump")]
1090    pub pump: Option<AnnotationRef>,
1091}
1092impl Laser {
1093    pub fn default_power_unit() -> UnitsPower {
1094        UnitsPower::mW
1095    }
1096    pub fn default_wavelength_unit() -> UnitsLength {
1097        UnitsLength::nm
1098    }
1099    pub fn default_repetition_rate_unit() -> UnitsFrequency {
1100        UnitsFrequency::Hz
1101    }
1102}
1103#[derive(Clone, Debug, Serialize, Deserialize)]
1104pub enum LaserLaserMediumType {
1105    #[serde(rename = "Cu")]
1106    Cu,
1107    #[serde(rename = "Ag")]
1108    Ag,
1109    #[serde(rename = "ArFl")]
1110    ArFl,
1111    #[serde(rename = "ArCl")]
1112    ArCl,
1113    #[serde(rename = "KrFl")]
1114    KrFl,
1115    #[serde(rename = "KrCl")]
1116    KrCl,
1117    #[serde(rename = "XeFl")]
1118    XeFl,
1119    #[serde(rename = "XeCl")]
1120    XeCl,
1121    #[serde(rename = "XeBr")]
1122    XeBr,
1123    #[serde(rename = "N")]
1124    N,
1125    #[serde(rename = "Ar")]
1126    Ar,
1127    #[serde(rename = "Kr")]
1128    Kr,
1129    #[serde(rename = "Xe")]
1130    Xe,
1131    #[serde(rename = "HeNe")]
1132    HeNe,
1133    #[serde(rename = "HeCd")]
1134    HeCd,
1135    #[serde(rename = "CO")]
1136    Co,
1137    #[serde(rename = "CO2")]
1138    Co2,
1139    #[serde(rename = "H2O")]
1140    H2O,
1141    #[serde(rename = "HFl")]
1142    Hfl,
1143    #[serde(rename = "NdGlass")]
1144    NdGlass,
1145    #[serde(rename = "NdYAG")]
1146    NdYag,
1147    #[serde(rename = "ErGlass")]
1148    ErGlass,
1149    #[serde(rename = "ErYAG")]
1150    ErYag,
1151    #[serde(rename = "HoYLF")]
1152    HoYlf,
1153    #[serde(rename = "HoYAG")]
1154    HoYag,
1155    #[serde(rename = "Ruby")]
1156    Ruby,
1157    #[serde(rename = "TiSapphire")]
1158    TiSapphire,
1159    #[serde(rename = "Alexandrite")]
1160    Alexandrite,
1161    #[serde(rename = "Rhodamine6G")]
1162    Rhodamine6G,
1163    #[serde(rename = "CoumarinC30")]
1164    CoumarinC30,
1165    #[serde(rename = "GaAs")]
1166    GaAs,
1167    #[serde(rename = "GaAlAs")]
1168    GaAlAs,
1169    #[serde(rename = "EMinus")]
1170    Eminus,
1171    #[serde(rename = "Other")]
1172    Other,
1173}
1174#[derive(Clone, Debug, Serialize, Deserialize)]
1175pub enum LaserPulseType {
1176    #[serde(rename = "CW")]
1177    Cw,
1178    #[serde(rename = "Single")]
1179    Single,
1180    #[serde(rename = "QSwitched")]
1181    Qswitched,
1182    #[serde(rename = "Repetitive")]
1183    Repetitive,
1184    #[serde(rename = "ModeLocked")]
1185    ModeLocked,
1186    #[serde(rename = "Other")]
1187    Other,
1188}
1189#[derive(Clone, Debug, Serialize, Deserialize)]
1190pub enum LaserType {
1191    #[serde(rename = "Excimer")]
1192    Excimer,
1193    #[serde(rename = "Gas")]
1194    Gas,
1195    #[serde(rename = "MetalVapor")]
1196    MetalVapor,
1197    #[serde(rename = "SolidState")]
1198    SolidState,
1199    #[serde(rename = "Dye")]
1200    Dye,
1201    #[serde(rename = "Semiconductor")]
1202    Semiconductor,
1203    #[serde(rename = "FreeElectron")]
1204    FreeElectron,
1205    #[serde(rename = "Other")]
1206    Other,
1207}
1208#[cfg_attr(feature = "python", derive(IntoPyObject))]
1209#[derive(Clone, Debug, Serialize, Deserialize)]
1210pub struct LightEmittingDiode {
1211    #[serde(default, rename = "@Manufacturer")]
1212    pub manufacturer: Option<String>,
1213    #[serde(default, rename = "@Model")]
1214    pub model: Option<String>,
1215    #[serde(default, rename = "@SerialNumber")]
1216    pub serial_number: Option<String>,
1217    #[serde(default, rename = "@LotNumber")]
1218    pub lot_number: Option<String>,
1219    #[serde(rename = "@ID")]
1220    pub id: String,
1221    #[serde(default, rename = "@Power")]
1222    pub power: Option<f32>,
1223    #[serde(
1224        default = "LightEmittingDiode::default_power_unit",
1225        rename = "@PowerUnit"
1226    )]
1227    pub power_unit: UnitsPower,
1228    #[serde(default, rename = "AnnotationRef")]
1229    pub annotation_ref: Vec<AnnotationRef>,
1230}
1231impl LightEmittingDiode {
1232    pub fn default_power_unit() -> UnitsPower {
1233        UnitsPower::mW
1234    }
1235}
1236#[cfg_attr(feature = "python", derive(IntoPyObject))]
1237#[derive(Clone, Debug, Serialize, Deserialize)]
1238pub struct LightPath {
1239    #[serde(default, rename = "ExcitationFilterRef")]
1240    pub excitation_filter_ref: Vec<AnnotationRef>,
1241    #[serde(default, rename = "DichroicRef")]
1242    pub dichroic_ref: Option<AnnotationRef>,
1243    #[serde(default, rename = "EmissionFilterRef")]
1244    pub emission_filter_ref: Vec<AnnotationRef>,
1245    #[serde(default, rename = "AnnotationRef")]
1246    pub annotation_ref: Vec<AnnotationRef>,
1247}
1248#[cfg_attr(feature = "python", derive(IntoPyObject))]
1249#[derive(Clone, Debug, Serialize, Deserialize)]
1250pub struct LightSourceType {
1251    #[serde(default, rename = "@Manufacturer")]
1252    pub manufacturer: Option<String>,
1253    #[serde(default, rename = "@Model")]
1254    pub model: Option<String>,
1255    #[serde(default, rename = "@SerialNumber")]
1256    pub serial_number: Option<String>,
1257    #[serde(default, rename = "@LotNumber")]
1258    pub lot_number: Option<String>,
1259    #[serde(rename = "@ID")]
1260    pub id: String,
1261    #[serde(default, rename = "@Power")]
1262    pub power: Option<f32>,
1263    #[serde(default = "LightSourceType::default_power_unit", rename = "@PowerUnit")]
1264    pub power_unit: UnitsPower,
1265    #[serde(default, rename = "AnnotationRef")]
1266    pub annotation_ref: Vec<AnnotationRef>,
1267}
1268impl LightSourceType {
1269    pub fn default_power_unit() -> UnitsPower {
1270        UnitsPower::mW
1271    }
1272}
1273#[cfg_attr(feature = "python", derive(IntoPyObject))]
1274#[derive(Clone, Debug, Serialize, Deserialize)]
1275pub enum LightSourceGroup {
1276    #[serde(rename = "Laser")]
1277    Laser(Laser),
1278    #[serde(rename = "Arc")]
1279    Arc(Arc),
1280    #[serde(rename = "Filament")]
1281    Filament(Filament),
1282    #[serde(rename = "LightEmittingDiode")]
1283    LightEmittingDiode(LightEmittingDiode),
1284    #[serde(rename = "GenericExcitationSource")]
1285    GenericExcitationSource(GenericExcitationSource),
1286}
1287#[cfg_attr(feature = "python", derive(IntoPyObject))]
1288#[derive(Clone, Debug, Serialize, Deserialize)]
1289pub struct LightSourceSettings {
1290    #[serde(rename = "@ID")]
1291    pub id: String,
1292    #[serde(default, rename = "@Attenuation")]
1293    pub attenuation: Option<f32>,
1294    #[serde(default, rename = "@Wavelength")]
1295    pub wavelength: Option<f32>,
1296    #[serde(
1297        default = "LightSourceSettings::default_wavelength_unit",
1298        rename = "@WavelengthUnit"
1299    )]
1300    pub wavelength_unit: UnitsLength,
1301}
1302impl LightSourceSettings {
1303    pub fn default_wavelength_unit() -> UnitsLength {
1304        UnitsLength::nm
1305    }
1306}
1307#[cfg_attr(feature = "python", derive(IntoPyObject))]
1308#[derive(Clone, Debug, Serialize, Deserialize)]
1309pub struct Line {
1310    #[serde(default, rename = "@FillColor")]
1311    pub fill_color: Option<i32>,
1312    #[serde(default, rename = "@FillRule")]
1313    pub fill_rule: Option<ShapeFillRuleType>,
1314    #[serde(default, rename = "@StrokeColor")]
1315    pub stroke_color: Option<i32>,
1316    #[serde(default, rename = "@StrokeWidth")]
1317    pub stroke_width: Option<f32>,
1318    #[serde(
1319        default = "Line::default_stroke_width_unit",
1320        rename = "@StrokeWidthUnit"
1321    )]
1322    pub stroke_width_unit: UnitsLength,
1323    #[serde(default, rename = "@StrokeDashArray")]
1324    pub stroke_dash_array: Option<String>,
1325    #[serde(default, rename = "@Text")]
1326    pub text: Option<String>,
1327    #[serde(default, rename = "@FontFamily")]
1328    pub font_family: Option<FontFamilyType>,
1329    #[serde(default, rename = "@FontSize")]
1330    pub font_size: Option<i32>,
1331    #[serde(default = "Line::default_font_size_unit", rename = "@FontSizeUnit")]
1332    pub font_size_unit: UnitsLength,
1333    #[serde(default, rename = "@FontStyle")]
1334    pub font_style: Option<ShapeFontStyleType>,
1335    #[serde(default, rename = "@Locked")]
1336    pub locked: Option<bool>,
1337    #[serde(rename = "@ID")]
1338    pub id: String,
1339    #[serde(default, rename = "@TheZ")]
1340    pub the_z: Option<i32>,
1341    #[serde(default, rename = "@TheT")]
1342    pub the_t: Option<i32>,
1343    #[serde(default, rename = "@TheC")]
1344    pub the_c: Option<i32>,
1345    #[serde(rename = "@X1")]
1346    pub x1: f32,
1347    #[serde(rename = "@Y1")]
1348    pub y1: f32,
1349    #[serde(rename = "@X2")]
1350    pub x2: f32,
1351    #[serde(rename = "@Y2")]
1352    pub y2: f32,
1353    #[serde(default, rename = "@MarkerStart")]
1354    pub marker_start: Option<MarkerType>,
1355    #[serde(default, rename = "@MarkerEnd")]
1356    pub marker_end: Option<MarkerType>,
1357    #[serde(default, rename = "Transform")]
1358    pub transform: Option<AffineTransform>,
1359    #[serde(default, rename = "AnnotationRef")]
1360    pub annotation_ref: Vec<AnnotationRef>,
1361}
1362impl Line {
1363    pub fn default_stroke_width_unit() -> UnitsLength {
1364        UnitsLength::Pixel
1365    }
1366    pub fn default_font_size_unit() -> UnitsLength {
1367        UnitsLength::Pixel
1368    }
1369}
1370#[cfg_attr(feature = "python", derive(IntoPyObject))]
1371#[derive(Clone, Debug, Serialize, Deserialize)]
1372pub struct LongAnnotation {
1373    #[serde(rename = "@ID")]
1374    pub id: String,
1375    #[serde(default, rename = "@Namespace")]
1376    pub namespace: Option<String>,
1377    #[serde(default, rename = "@Annotator")]
1378    pub annotator: Option<String>,
1379    #[serde(default, rename = "Description")]
1380    pub description: Option<String>,
1381    #[serde(default, rename = "AnnotationRef")]
1382    pub annotation_ref: Vec<AnnotationRef>,
1383    #[serde(rename = "Value")]
1384    pub value: i64,
1385}
1386#[cfg_attr(feature = "python", derive(IntoPyObject))]
1387#[derive(Clone, Debug, Serialize, Deserialize)]
1388pub struct MapType {
1389    #[serde(default, rename = "M")]
1390    pub m: Vec<MapM>,
1391}
1392#[cfg_attr(feature = "python", derive(IntoPyObject))]
1393#[derive(Clone, Debug, Serialize, Deserialize)]
1394pub struct MapAnnotation {
1395    #[serde(rename = "@ID")]
1396    pub id: String,
1397    #[serde(default, rename = "@Namespace")]
1398    pub namespace: Option<String>,
1399    #[serde(default, rename = "@Annotator")]
1400    pub annotator: Option<String>,
1401    #[serde(default, rename = "Description")]
1402    pub description: Option<String>,
1403    #[serde(default, rename = "AnnotationRef")]
1404    pub annotation_ref: Vec<AnnotationRef>,
1405    #[serde(rename = "Value")]
1406    pub value: MapType,
1407}
1408#[cfg_attr(feature = "python", derive(IntoPyObject))]
1409#[derive(Clone, Debug, Serialize, Deserialize)]
1410pub struct MapM {
1411    #[serde(default, rename = "@K")]
1412    pub k: Option<String>,
1413    #[serde(rename = "$text")]
1414    pub content: String,
1415}
1416#[derive(Clone, Debug, Serialize, Deserialize)]
1417pub enum MarkerType {
1418    #[serde(rename = "Arrow")]
1419    Arrow,
1420}
1421#[cfg_attr(feature = "python", derive(IntoPyObject))]
1422#[derive(Clone, Debug, Serialize, Deserialize)]
1423pub struct Mask {
1424    #[serde(default, rename = "@FillColor")]
1425    pub fill_color: Option<i32>,
1426    #[serde(default, rename = "@FillRule")]
1427    pub fill_rule: Option<ShapeFillRuleType>,
1428    #[serde(default, rename = "@StrokeColor")]
1429    pub stroke_color: Option<i32>,
1430    #[serde(default, rename = "@StrokeWidth")]
1431    pub stroke_width: Option<f32>,
1432    #[serde(
1433        default = "Mask::default_stroke_width_unit",
1434        rename = "@StrokeWidthUnit"
1435    )]
1436    pub stroke_width_unit: UnitsLength,
1437    #[serde(default, rename = "@StrokeDashArray")]
1438    pub stroke_dash_array: Option<String>,
1439    #[serde(default, rename = "@Text")]
1440    pub text: Option<String>,
1441    #[serde(default, rename = "@FontFamily")]
1442    pub font_family: Option<FontFamilyType>,
1443    #[serde(default, rename = "@FontSize")]
1444    pub font_size: Option<i32>,
1445    #[serde(default = "Mask::default_font_size_unit", rename = "@FontSizeUnit")]
1446    pub font_size_unit: UnitsLength,
1447    #[serde(default, rename = "@FontStyle")]
1448    pub font_style: Option<ShapeFontStyleType>,
1449    #[serde(default, rename = "@Locked")]
1450    pub locked: Option<bool>,
1451    #[serde(rename = "@ID")]
1452    pub id: String,
1453    #[serde(default, rename = "@TheZ")]
1454    pub the_z: Option<i32>,
1455    #[serde(default, rename = "@TheT")]
1456    pub the_t: Option<i32>,
1457    #[serde(default, rename = "@TheC")]
1458    pub the_c: Option<i32>,
1459    #[serde(rename = "@X")]
1460    pub x: f32,
1461    #[serde(rename = "@Y")]
1462    pub y: f32,
1463    #[serde(rename = "@Width")]
1464    pub width: f32,
1465    #[serde(rename = "@Height")]
1466    pub height: f32,
1467    #[serde(default, rename = "Transform")]
1468    pub transform: Option<AffineTransform>,
1469    #[serde(default, rename = "AnnotationRef")]
1470    pub annotation_ref: Vec<AnnotationRef>,
1471    #[serde(rename = "BinData")]
1472    pub bin_data: BinData,
1473}
1474impl Mask {
1475    pub fn default_stroke_width_unit() -> UnitsLength {
1476        UnitsLength::Pixel
1477    }
1478    pub fn default_font_size_unit() -> UnitsLength {
1479        UnitsLength::Pixel
1480    }
1481}
1482#[derive(Clone, Debug, Serialize, Deserialize)]
1483pub struct MetadataOnly;
1484#[cfg_attr(feature = "python", derive(IntoPyObject))]
1485#[derive(Clone, Debug, Serialize, Deserialize)]
1486pub struct MicrobeamManipulation {
1487    #[serde(rename = "@ID")]
1488    pub id: String,
1489    #[serde(default, rename = "@Type")]
1490    pub r#type: Option<MicrobeamManipulationType>,
1491    #[serde(default, rename = "Description")]
1492    pub description: Option<String>,
1493    #[serde(default, rename = "ROIRef")]
1494    pub roi_ref: Vec<AnnotationRef>,
1495    #[serde(rename = "ExperimenterRef")]
1496    pub experimenter_ref: AnnotationRef,
1497    #[serde(default, rename = "LightSourceSettings")]
1498    pub light_source_settings: Vec<LightSourceSettings>,
1499}
1500#[derive(Clone, Debug, Serialize, Deserialize)]
1501pub enum MicrobeamManipulationItemType {
1502    #[serde(rename = "FRAP")]
1503    Frap,
1504    #[serde(rename = "FLIP")]
1505    Flip,
1506    #[serde(rename = "InverseFRAP")]
1507    InverseFrap,
1508    #[serde(rename = "Photoablation")]
1509    Photoablation,
1510    #[serde(rename = "Photoactivation")]
1511    Photoactivation,
1512    #[serde(rename = "Uncaging")]
1513    Uncaging,
1514    #[serde(rename = "OpticalTrapping")]
1515    OpticalTrapping,
1516    #[serde(rename = "Other")]
1517    Other,
1518}
1519#[cfg_attr(feature = "python", derive(IntoPyObject))]
1520#[derive(Clone, Debug, Serialize, Deserialize, Default)]
1521pub struct MicrobeamManipulationType(pub Vec<MicrobeamManipulationItemType>);
1522#[cfg_attr(feature = "python", derive(IntoPyObject))]
1523#[derive(Clone, Debug, Serialize, Deserialize)]
1524pub struct Microscope {
1525    #[serde(default, rename = "@Manufacturer")]
1526    pub manufacturer: Option<String>,
1527    #[serde(default, rename = "@Model")]
1528    pub model: Option<String>,
1529    #[serde(default, rename = "@SerialNumber")]
1530    pub serial_number: Option<String>,
1531    #[serde(default, rename = "@LotNumber")]
1532    pub lot_number: Option<String>,
1533    #[serde(default, rename = "@Type")]
1534    pub r#type: Option<MicroscopeType>,
1535}
1536#[derive(Clone, Debug, Serialize, Deserialize)]
1537pub enum MicroscopeType {
1538    #[serde(rename = "Upright")]
1539    Upright,
1540    #[serde(rename = "Inverted")]
1541    Inverted,
1542    #[serde(rename = "Dissection")]
1543    Dissection,
1544    #[serde(rename = "Electrophysiology")]
1545    Electrophysiology,
1546    #[serde(rename = "Other")]
1547    Other,
1548}
1549#[derive(Clone, Debug, Serialize, Deserialize)]
1550pub enum NamingConventionType {
1551    #[serde(rename = "letter")]
1552    Letter,
1553    #[serde(rename = "number")]
1554    Number,
1555}
1556
1557/// The root of the metadata, create this by parsing an XML string.
1558/// ```
1559/// use ome_metadata::Ome;
1560///
1561/// let xml = r#"<OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd">
1562///   <Image ID="Image:0" Name="test.tif">
1563///     <AcquisitionDate>2025-01-29T14:42:42</AcquisitionDate>
1564///     <Description/>
1565///     <Pixels ID="Pixels:0" DimensionOrder="XYCZT" Type="int8" SignificantBits="8" Interleaved="false" BigEndian="false" SizeX="2" SizeY="2" SizeZ="1" SizeC="1" SizeT="1">
1566///       <Channel ID="Channel:0:0" SamplesPerPixel="1">
1567///         <LightPath/>
1568///       </Channel>
1569///       <MetadataOnly/>
1570///     </Pixels>
1571///   </Image>
1572/// </OME>"#;
1573///
1574/// let ome: Ome = xml.parse().unwrap();
1575/// let image = &ome.image.unwrap()[0];
1576/// println!("acquisition date: {:#?}", image.acquisition_date);
1577/// ```
1578#[cfg_attr(feature = "python", derive(IntoPyObject))]
1579#[derive(Clone, Debug, Serialize, Deserialize)]
1580pub struct Ome {
1581    #[serde(default, rename = "@UUID")]
1582    pub uuid: Option<String>,
1583    #[serde(default, rename = "@Creator")]
1584    pub creator: Option<String>,
1585    #[serde(rename = "Rights")]
1586    pub rights: Option<Rights>,
1587    #[serde(rename = "Project")]
1588    pub project: Option<Vec<Project>>,
1589    #[serde(rename = "Dataset")]
1590    pub dataset: Option<Vec<Dataset>>,
1591    #[serde(rename = "Folder")]
1592    pub folder: Option<Vec<Folder>>,
1593    #[serde(rename = "Experiment")]
1594    pub experiment: Option<Vec<Experiment>>,
1595    #[serde(rename = "Plate")]
1596    pub plate: Option<Vec<Plate>>,
1597    #[serde(rename = "Screen")]
1598    pub screen: Option<Vec<Screen>>,
1599    #[serde(rename = "Experimenter")]
1600    pub experimenter: Option<Vec<Experimenter>>,
1601    #[serde(rename = "ExperimenterGroup")]
1602    pub experimenter_group: Option<Vec<ExperimenterGroup>>,
1603    #[serde(rename = "Instrument")]
1604    pub instrument: Option<Vec<Instrument>>,
1605    #[serde(rename = "Image")]
1606    pub image: Option<Vec<Image>>,
1607    #[serde(rename = "StructuredAnnotations")]
1608    pub structured_annotations: Option<StructuredAnnotations>,
1609    #[serde(rename = "ROI")]
1610    pub roi: Option<Vec<Roi>>,
1611    #[serde(rename = "BinaryOnly")]
1612    pub binary_only: Option<OmeBinaryOnly>,
1613}
1614#[cfg_attr(feature = "python", derive(IntoPyObject))]
1615#[derive(Clone, Debug, Serialize, Deserialize)]
1616pub struct Objective {
1617    #[serde(default, rename = "@Manufacturer")]
1618    pub manufacturer: Option<String>,
1619    #[serde(default, rename = "@Model")]
1620    pub model: Option<String>,
1621    #[serde(default, rename = "@SerialNumber")]
1622    pub serial_number: Option<String>,
1623    #[serde(default, rename = "@LotNumber")]
1624    pub lot_number: Option<String>,
1625    #[serde(rename = "@ID")]
1626    pub id: String,
1627    #[serde(default, rename = "@Correction")]
1628    pub correction: Option<ObjectiveCorrectionType>,
1629    #[serde(default, rename = "@Immersion")]
1630    pub immersion: Option<ObjectiveImmersionType>,
1631    #[serde(default, rename = "@LensNA")]
1632    pub lens_na: Option<f32>,
1633    #[serde(default, rename = "@NominalMagnification")]
1634    pub nominal_magnification: Option<f32>,
1635    #[serde(default, rename = "@CalibratedMagnification")]
1636    pub calibrated_magnification: Option<f32>,
1637    #[serde(default, rename = "@WorkingDistance")]
1638    pub working_distance: Option<f32>,
1639    #[serde(
1640        default = "Objective::default_working_distance_unit",
1641        rename = "@WorkingDistanceUnit"
1642    )]
1643    pub working_distance_unit: UnitsLength,
1644    #[serde(default, rename = "@Iris")]
1645    pub iris: Option<bool>,
1646    #[serde(default, rename = "AnnotationRef")]
1647    pub annotation_ref: Vec<AnnotationRef>,
1648}
1649impl Objective {
1650    pub fn default_working_distance_unit() -> UnitsLength {
1651        UnitsLength::um
1652    }
1653}
1654#[derive(Clone, Debug, Serialize, Deserialize)]
1655pub enum ObjectiveCorrectionType {
1656    #[serde(rename = "UV")]
1657    Uv,
1658    #[serde(rename = "PlanApo")]
1659    PlanApo,
1660    #[serde(rename = "PlanFluor")]
1661    PlanFluor,
1662    #[serde(rename = "SuperFluor")]
1663    SuperFluor,
1664    #[serde(rename = "VioletCorrected")]
1665    VioletCorrected,
1666    #[serde(rename = "Achro")]
1667    Achro,
1668    #[serde(rename = "Achromat")]
1669    Achromat,
1670    #[serde(rename = "Fluor")]
1671    Fluor,
1672    #[serde(rename = "Fl")]
1673    Fl,
1674    #[serde(rename = "Fluar")]
1675    Fluar,
1676    #[serde(rename = "Neofluar")]
1677    Neofluar,
1678    #[serde(rename = "Fluotar")]
1679    Fluotar,
1680    #[serde(rename = "Apo")]
1681    Apo,
1682    #[serde(rename = "PlanNeofluar")]
1683    PlanNeofluar,
1684    #[serde(rename = "Other")]
1685    Other,
1686}
1687#[derive(Clone, Debug, Serialize, Deserialize)]
1688pub enum ObjectiveImmersionType {
1689    #[serde(rename = "Oil")]
1690    Oil,
1691    #[serde(rename = "Water")]
1692    Water,
1693    #[serde(rename = "WaterDipping")]
1694    WaterDipping,
1695    #[serde(rename = "Air")]
1696    Air,
1697    #[serde(rename = "Multi")]
1698    Multi,
1699    #[serde(rename = "Glycerol")]
1700    Glycerol,
1701    #[serde(rename = "Other")]
1702    Other,
1703}
1704#[cfg_attr(feature = "python", derive(IntoPyObject))]
1705#[derive(Clone, Debug, Serialize, Deserialize)]
1706pub struct ObjectiveSettings {
1707    #[serde(rename = "@ID")]
1708    pub id: String,
1709    #[serde(default, rename = "@CorrectionCollar")]
1710    pub correction_collar: Option<f32>,
1711    #[serde(default, rename = "@Medium")]
1712    pub medium: Option<ObjectiveSettingsMediumType>,
1713    #[serde(default, rename = "@RefractiveIndex")]
1714    pub refractive_index: Option<f32>,
1715}
1716#[derive(Clone, Debug, Serialize, Deserialize)]
1717pub enum ObjectiveSettingsMediumType {
1718    #[serde(rename = "Air")]
1719    Air,
1720    #[serde(rename = "Oil")]
1721    Oil,
1722    #[serde(rename = "Water")]
1723    Water,
1724    #[serde(rename = "Glycerol")]
1725    Glycerol,
1726    #[serde(rename = "Other")]
1727    Other,
1728}
1729#[cfg_attr(feature = "python", derive(IntoPyObject))]
1730#[derive(Clone, Debug, Serialize, Deserialize)]
1731pub struct OmeBinaryOnly {
1732    #[serde(rename = "@MetadataFile")]
1733    pub metadata_file: String,
1734    #[serde(rename = "@UUID")]
1735    pub uuid: String,
1736}
1737#[derive(Clone, Debug, Serialize, Deserialize)]
1738pub enum PixelType {
1739    #[serde(rename = "int8")]
1740    Int8,
1741    #[serde(rename = "int16")]
1742    Int16,
1743    #[serde(rename = "int32")]
1744    Int32,
1745    #[serde(rename = "uint8")]
1746    Uint8,
1747    #[serde(rename = "uint16")]
1748    Uint16,
1749    #[serde(rename = "uint32")]
1750    Uint32,
1751    #[serde(rename = "float")]
1752    Float,
1753    #[serde(rename = "double")]
1754    Double,
1755    #[serde(rename = "complex")]
1756    Complex,
1757    #[serde(rename = "double-complex")]
1758    DoubleComplex,
1759    #[serde(rename = "bit")]
1760    Bit,
1761}
1762#[cfg_attr(feature = "python", derive(IntoPyObject))]
1763#[derive(Clone, Debug, Serialize, Deserialize)]
1764pub struct Pixels {
1765    #[serde(rename = "@ID")]
1766    pub id: String,
1767    #[serde(rename = "@DimensionOrder")]
1768    pub dimension_order: PixelsDimensionOrderType,
1769    #[serde(rename = "@Type")]
1770    pub r#type: PixelType,
1771    #[serde(default, rename = "@SignificantBits")]
1772    pub significant_bits: Option<i32>,
1773    #[serde(default, rename = "@Interleaved")]
1774    pub interleaved: Option<bool>,
1775    #[serde(default, rename = "@BigEndian")]
1776    pub big_endian: Option<bool>,
1777    #[serde(rename = "@SizeX")]
1778    pub size_x: i32,
1779    #[serde(rename = "@SizeY")]
1780    pub size_y: i32,
1781    #[serde(rename = "@SizeZ")]
1782    pub size_z: i32,
1783    #[serde(rename = "@SizeC")]
1784    pub size_c: i32,
1785    #[serde(rename = "@SizeT")]
1786    pub size_t: i32,
1787    #[serde(default, rename = "@PhysicalSizeX")]
1788    pub physical_size_x: Option<f32>,
1789    #[serde(
1790        default = "Pixels::default_physical_size_x_unit",
1791        rename = "@PhysicalSizeXUnit"
1792    )]
1793    pub physical_size_x_unit: UnitsLength,
1794    #[serde(default, rename = "@PhysicalSizeY")]
1795    pub physical_size_y: Option<f32>,
1796    #[serde(
1797        default = "Pixels::default_physical_size_y_unit",
1798        rename = "@PhysicalSizeYUnit"
1799    )]
1800    pub physical_size_y_unit: UnitsLength,
1801    #[serde(default, rename = "@PhysicalSizeZ")]
1802    pub physical_size_z: Option<f32>,
1803    #[serde(
1804        default = "Pixels::default_physical_size_z_unit",
1805        rename = "@PhysicalSizeZUnit"
1806    )]
1807    pub physical_size_z_unit: UnitsLength,
1808    #[serde(default, rename = "@TimeIncrement")]
1809    pub time_increment: Option<f32>,
1810    #[serde(
1811        default = "Pixels::default_time_increment_unit",
1812        rename = "@TimeIncrementUnit"
1813    )]
1814    pub time_increment_unit: UnitsTime,
1815    #[serde(rename = "Channel")]
1816    pub channel: Vec<Channel>,
1817    #[serde(rename = "BinData")]
1818    pub bin_data: Option<BinData>,
1819    #[serde(rename = "TiffData")]
1820    pub tiff_data: Option<TiffData>,
1821    #[serde(rename = "MetadataOnly")]
1822    pub metadata_only: Option<MetadataOnly>,
1823    #[serde(rename = "Plane")]
1824    pub plane: Option<Vec<Plane>>,
1825}
1826impl Pixels {
1827    pub fn default_physical_size_x_unit() -> UnitsLength {
1828        UnitsLength::um
1829    }
1830    pub fn default_physical_size_y_unit() -> UnitsLength {
1831        UnitsLength::um
1832    }
1833    pub fn default_physical_size_z_unit() -> UnitsLength {
1834        UnitsLength::um
1835    }
1836    pub fn default_time_increment_unit() -> UnitsTime {
1837        UnitsTime::s
1838    }
1839}
1840#[derive(Clone, Debug, Serialize, Deserialize)]
1841pub enum PixelsDimensionOrderType {
1842    #[serde(rename = "XYZCT")]
1843    Xyzct,
1844    #[serde(rename = "XYZTC")]
1845    Xyztc,
1846    #[serde(rename = "XYCTZ")]
1847    Xyctz,
1848    #[serde(rename = "XYCZT")]
1849    Xyczt,
1850    #[serde(rename = "XYTCZ")]
1851    Xytcz,
1852    #[serde(rename = "XYTZC")]
1853    Xytzc,
1854}
1855#[cfg_attr(feature = "python", derive(IntoPyObject))]
1856#[derive(Clone, Debug, Serialize, Deserialize)]
1857pub struct Plane {
1858    #[serde(rename = "@TheZ")]
1859    pub the_z: i32,
1860    #[serde(rename = "@TheT")]
1861    pub the_t: i32,
1862    #[serde(rename = "@TheC")]
1863    pub the_c: i32,
1864    #[serde(default, rename = "@DeltaT")]
1865    pub delta_t: Option<f32>,
1866    #[serde(default = "Plane::default_delta_t_unit", rename = "@DeltaTUnit")]
1867    pub delta_t_unit: UnitsTime,
1868    #[serde(default, rename = "@ExposureTime")]
1869    pub exposure_time: Option<f32>,
1870    #[serde(
1871        default = "Plane::default_exposure_time_unit",
1872        rename = "@ExposureTimeUnit"
1873    )]
1874    pub exposure_time_unit: UnitsTime,
1875    #[serde(default, rename = "@PositionX")]
1876    pub position_x: Option<f32>,
1877    #[serde(default = "Plane::default_position_x_unit", rename = "@PositionXUnit")]
1878    pub position_x_unit: UnitsLength,
1879    #[serde(default, rename = "@PositionY")]
1880    pub position_y: Option<f32>,
1881    #[serde(default = "Plane::default_position_y_unit", rename = "@PositionYUnit")]
1882    pub position_y_unit: UnitsLength,
1883    #[serde(default, rename = "@PositionZ")]
1884    pub position_z: Option<f32>,
1885    #[serde(default = "Plane::default_position_z_unit", rename = "@PositionZUnit")]
1886    pub position_z_unit: UnitsLength,
1887    #[serde(rename = "HashSHA1")]
1888    pub hash_sha1: Option<String>,
1889    #[serde(rename = "AnnotationRef")]
1890    pub annotation_ref: Option<AnnotationRef>,
1891}
1892impl Plane {
1893    pub fn default_delta_t_unit() -> UnitsTime {
1894        UnitsTime::s
1895    }
1896    pub fn default_exposure_time_unit() -> UnitsTime {
1897        UnitsTime::s
1898    }
1899    pub fn default_position_x_unit() -> UnitsLength {
1900        UnitsLength::um
1901    }
1902    pub fn default_position_y_unit() -> UnitsLength {
1903        UnitsLength::um
1904    }
1905    pub fn default_position_z_unit() -> UnitsLength {
1906        UnitsLength::um
1907    }
1908}
1909#[cfg_attr(feature = "python", derive(IntoPyObject))]
1910#[derive(Clone, Debug, Serialize, Deserialize)]
1911pub struct Plate {
1912    #[serde(rename = "@ID")]
1913    pub id: String,
1914    #[serde(default, rename = "@Name")]
1915    pub name: Option<String>,
1916    #[serde(default, rename = "@Status")]
1917    pub status: Option<String>,
1918    #[serde(default, rename = "@ExternalIdentifier")]
1919    pub external_identifier: Option<String>,
1920    #[serde(default, rename = "@ColumnNamingConvention")]
1921    pub column_naming_convention: Option<NamingConventionType>,
1922    #[serde(default, rename = "@RowNamingConvention")]
1923    pub row_naming_convention: Option<NamingConventionType>,
1924    #[serde(default, rename = "@WellOriginX")]
1925    pub well_origin_x: Option<f32>,
1926    #[serde(
1927        default = "Plate::default_well_origin_x_unit",
1928        rename = "@WellOriginXUnit"
1929    )]
1930    pub well_origin_x_unit: UnitsLength,
1931    #[serde(default, rename = "@WellOriginY")]
1932    pub well_origin_y: Option<f32>,
1933    #[serde(
1934        default = "Plate::default_well_origin_y_unit",
1935        rename = "@WellOriginYUnit"
1936    )]
1937    pub well_origin_y_unit: UnitsLength,
1938    #[serde(default, rename = "@Rows")]
1939    pub rows: Option<i32>,
1940    #[serde(default, rename = "@Columns")]
1941    pub columns: Option<i32>,
1942    #[serde(default, rename = "@FieldIndex")]
1943    pub field_index: Option<i32>,
1944    #[serde(default, rename = "Description")]
1945    pub description: Option<String>,
1946    #[serde(default, rename = "Well")]
1947    pub well: Vec<Well>,
1948    #[serde(default, rename = "AnnotationRef")]
1949    pub annotation_ref: Vec<AnnotationRef>,
1950    #[serde(default, rename = "PlateAcquisition")]
1951    pub plate_acquisition: Vec<PlateAcquisition>,
1952}
1953impl Plate {
1954    pub fn default_well_origin_x_unit() -> UnitsLength {
1955        UnitsLength::um
1956    }
1957    pub fn default_well_origin_y_unit() -> UnitsLength {
1958        UnitsLength::um
1959    }
1960}
1961#[cfg_attr(feature = "python", derive(IntoPyObject))]
1962#[derive(Clone, Debug, Serialize, Deserialize)]
1963pub struct PlateAcquisition {
1964    #[serde(rename = "@ID")]
1965    pub id: String,
1966    #[serde(default, rename = "@Name")]
1967    pub name: Option<String>,
1968    #[serde(default, rename = "@EndTime")]
1969    pub end_time: Option<String>,
1970    #[serde(default, rename = "@StartTime")]
1971    pub start_time: Option<String>,
1972    #[serde(default, rename = "@MaximumFieldCount")]
1973    pub maximum_field_count: Option<i32>,
1974    #[serde(default, rename = "Description")]
1975    pub description: Option<String>,
1976    #[serde(default, rename = "WellSampleRef")]
1977    pub well_sample_ref: Vec<AnnotationRef>,
1978    #[serde(default, rename = "AnnotationRef")]
1979    pub annotation_ref: Vec<AnnotationRef>,
1980}
1981#[cfg_attr(feature = "python", derive(IntoPyObject))]
1982#[derive(Clone, Debug, Serialize, Deserialize)]
1983pub struct Polygon {
1984    #[serde(default, rename = "@FillColor")]
1985    pub fill_color: Option<i32>,
1986    #[serde(default, rename = "@FillRule")]
1987    pub fill_rule: Option<ShapeFillRuleType>,
1988    #[serde(default, rename = "@StrokeColor")]
1989    pub stroke_color: Option<i32>,
1990    #[serde(default, rename = "@StrokeWidth")]
1991    pub stroke_width: Option<f32>,
1992    #[serde(
1993        default = "Polygon::default_stroke_width_unit",
1994        rename = "@StrokeWidthUnit"
1995    )]
1996    pub stroke_width_unit: UnitsLength,
1997    #[serde(default, rename = "@StrokeDashArray")]
1998    pub stroke_dash_array: Option<String>,
1999    #[serde(default, rename = "@Text")]
2000    pub text: Option<String>,
2001    #[serde(default, rename = "@FontFamily")]
2002    pub font_family: Option<FontFamilyType>,
2003    #[serde(default, rename = "@FontSize")]
2004    pub font_size: Option<i32>,
2005    #[serde(default = "Polygon::default_font_size_unit", rename = "@FontSizeUnit")]
2006    pub font_size_unit: UnitsLength,
2007    #[serde(default, rename = "@FontStyle")]
2008    pub font_style: Option<ShapeFontStyleType>,
2009    #[serde(default, rename = "@Locked")]
2010    pub locked: Option<bool>,
2011    #[serde(rename = "@ID")]
2012    pub id: String,
2013    #[serde(default, rename = "@TheZ")]
2014    pub the_z: Option<i32>,
2015    #[serde(default, rename = "@TheT")]
2016    pub the_t: Option<i32>,
2017    #[serde(default, rename = "@TheC")]
2018    pub the_c: Option<i32>,
2019    #[serde(rename = "@Points")]
2020    pub points: String,
2021    #[serde(default, rename = "Transform")]
2022    pub transform: Option<AffineTransform>,
2023    #[serde(default, rename = "AnnotationRef")]
2024    pub annotation_ref: Vec<AnnotationRef>,
2025}
2026impl Polygon {
2027    pub fn default_stroke_width_unit() -> UnitsLength {
2028        UnitsLength::Pixel
2029    }
2030    pub fn default_font_size_unit() -> UnitsLength {
2031        UnitsLength::Pixel
2032    }
2033}
2034#[cfg_attr(feature = "python", derive(IntoPyObject))]
2035#[derive(Clone, Debug, Serialize, Deserialize)]
2036pub struct Polyline {
2037    #[serde(default, rename = "@FillColor")]
2038    pub fill_color: Option<i32>,
2039    #[serde(default, rename = "@FillRule")]
2040    pub fill_rule: Option<ShapeFillRuleType>,
2041    #[serde(default, rename = "@StrokeColor")]
2042    pub stroke_color: Option<i32>,
2043    #[serde(default, rename = "@StrokeWidth")]
2044    pub stroke_width: Option<f32>,
2045    #[serde(
2046        default = "Polyline::default_stroke_width_unit",
2047        rename = "@StrokeWidthUnit"
2048    )]
2049    pub stroke_width_unit: UnitsLength,
2050    #[serde(default, rename = "@StrokeDashArray")]
2051    pub stroke_dash_array: Option<String>,
2052    #[serde(default, rename = "@Text")]
2053    pub text: Option<String>,
2054    #[serde(default, rename = "@FontFamily")]
2055    pub font_family: Option<FontFamilyType>,
2056    #[serde(default, rename = "@FontSize")]
2057    pub font_size: Option<i32>,
2058    #[serde(default = "Polyline::default_font_size_unit", rename = "@FontSizeUnit")]
2059    pub font_size_unit: UnitsLength,
2060    #[serde(default, rename = "@FontStyle")]
2061    pub font_style: Option<ShapeFontStyleType>,
2062    #[serde(default, rename = "@Locked")]
2063    pub locked: Option<bool>,
2064    #[serde(rename = "@ID")]
2065    pub id: String,
2066    #[serde(default, rename = "@TheZ")]
2067    pub the_z: Option<i32>,
2068    #[serde(default, rename = "@TheT")]
2069    pub the_t: Option<i32>,
2070    #[serde(default, rename = "@TheC")]
2071    pub the_c: Option<i32>,
2072    #[serde(rename = "@Points")]
2073    pub points: String,
2074    #[serde(default, rename = "@MarkerStart")]
2075    pub marker_start: Option<MarkerType>,
2076    #[serde(default, rename = "@MarkerEnd")]
2077    pub marker_end: Option<MarkerType>,
2078    #[serde(default, rename = "Transform")]
2079    pub transform: Option<AffineTransform>,
2080    #[serde(default, rename = "AnnotationRef")]
2081    pub annotation_ref: Vec<AnnotationRef>,
2082}
2083impl Polyline {
2084    pub fn default_stroke_width_unit() -> UnitsLength {
2085        UnitsLength::Pixel
2086    }
2087    pub fn default_font_size_unit() -> UnitsLength {
2088        UnitsLength::Pixel
2089    }
2090}
2091#[cfg_attr(feature = "python", derive(IntoPyObject))]
2092#[derive(Clone, Debug, Serialize, Deserialize)]
2093pub struct Project {
2094    #[serde(default, rename = "@Name")]
2095    pub name: Option<String>,
2096    #[serde(rename = "@ID")]
2097    pub id: String,
2098    #[serde(default, rename = "Description")]
2099    pub description: Option<String>,
2100    #[serde(default, rename = "ExperimenterRef")]
2101    pub experimenter_ref: Option<AnnotationRef>,
2102    #[serde(default, rename = "ExperimenterGroupRef")]
2103    pub experimenter_group_ref: Option<AnnotationRef>,
2104    #[serde(default, rename = "DatasetRef")]
2105    pub dataset_ref: Vec<AnnotationRef>,
2106    #[serde(default, rename = "AnnotationRef")]
2107    pub annotation_ref: Vec<AnnotationRef>,
2108}
2109#[cfg_attr(feature = "python", derive(IntoPyObject))]
2110#[derive(Clone, Debug, Serialize, Deserialize)]
2111pub struct Roi {
2112    #[serde(rename = "@ID")]
2113    pub id: String,
2114    #[serde(default, rename = "@Name")]
2115    pub name: Option<String>,
2116    #[serde(rename = "Union")]
2117    pub union: Option<RoiUnion>,
2118    #[serde(rename = "AnnotationRef")]
2119    pub annotation_ref: Option<AnnotationRef>,
2120    #[serde(rename = "Description")]
2121    pub description: Option<String>,
2122}
2123#[cfg_attr(feature = "python", derive(IntoPyObject))]
2124#[derive(Clone, Debug, Serialize, Deserialize)]
2125pub struct Reagent {
2126    #[serde(rename = "@ID")]
2127    pub id: String,
2128    #[serde(default, rename = "@Name")]
2129    pub name: Option<String>,
2130    #[serde(default, rename = "@ReagentIdentifier")]
2131    pub reagent_identifier: Option<String>,
2132    #[serde(default, rename = "Description")]
2133    pub description: Option<String>,
2134    #[serde(default, rename = "AnnotationRef")]
2135    pub annotation_ref: Vec<AnnotationRef>,
2136}
2137#[cfg_attr(feature = "python", derive(IntoPyObject))]
2138#[derive(Clone, Debug, Serialize, Deserialize)]
2139pub struct Rectangle {
2140    #[serde(default, rename = "@FillColor")]
2141    pub fill_color: Option<i32>,
2142    #[serde(default, rename = "@FillRule")]
2143    pub fill_rule: Option<ShapeFillRuleType>,
2144    #[serde(default, rename = "@StrokeColor")]
2145    pub stroke_color: Option<i32>,
2146    #[serde(default, rename = "@StrokeWidth")]
2147    pub stroke_width: Option<f32>,
2148    #[serde(
2149        default = "Rectangle::default_stroke_width_unit",
2150        rename = "@StrokeWidthUnit"
2151    )]
2152    pub stroke_width_unit: UnitsLength,
2153    #[serde(default, rename = "@StrokeDashArray")]
2154    pub stroke_dash_array: Option<String>,
2155    #[serde(default, rename = "@Text")]
2156    pub text: Option<String>,
2157    #[serde(default, rename = "@FontFamily")]
2158    pub font_family: Option<FontFamilyType>,
2159    #[serde(default, rename = "@FontSize")]
2160    pub font_size: Option<i32>,
2161    #[serde(
2162        default = "Rectangle::default_font_size_unit",
2163        rename = "@FontSizeUnit"
2164    )]
2165    pub font_size_unit: UnitsLength,
2166    #[serde(default, rename = "@FontStyle")]
2167    pub font_style: Option<ShapeFontStyleType>,
2168    #[serde(default, rename = "@Locked")]
2169    pub locked: Option<bool>,
2170    #[serde(rename = "@ID")]
2171    pub id: String,
2172    #[serde(default, rename = "@TheZ")]
2173    pub the_z: Option<i32>,
2174    #[serde(default, rename = "@TheT")]
2175    pub the_t: Option<i32>,
2176    #[serde(default, rename = "@TheC")]
2177    pub the_c: Option<i32>,
2178    #[serde(rename = "@X")]
2179    pub x: f32,
2180    #[serde(rename = "@Y")]
2181    pub y: f32,
2182    #[serde(rename = "@Width")]
2183    pub width: f32,
2184    #[serde(rename = "@Height")]
2185    pub height: f32,
2186    #[serde(default, rename = "Transform")]
2187    pub transform: Option<AffineTransform>,
2188    #[serde(default, rename = "AnnotationRef")]
2189    pub annotation_ref: Vec<AnnotationRef>,
2190}
2191impl Rectangle {
2192    pub fn default_stroke_width_unit() -> UnitsLength {
2193        UnitsLength::Pixel
2194    }
2195    pub fn default_font_size_unit() -> UnitsLength {
2196        UnitsLength::Pixel
2197    }
2198}
2199#[cfg_attr(feature = "python", derive(IntoPyObject))]
2200#[derive(Clone, Debug, Serialize, Deserialize)]
2201pub struct Rights {
2202    #[serde(default, rename = "RightsHolder")]
2203    pub rights_holder: Option<String>,
2204    #[serde(default, rename = "RightsHeld")]
2205    pub rights_held: Option<String>,
2206}
2207#[cfg_attr(feature = "python", derive(IntoPyObject))]
2208#[derive(Clone, Debug, Serialize, Deserialize)]
2209pub struct RoiUnion {
2210    #[serde(default, rename = "ShapeGroup")]
2211    pub shape_group: Vec<ShapeGroup>,
2212}
2213#[cfg_attr(feature = "python", derive(IntoPyObject))]
2214#[derive(Clone, Debug, Serialize, Deserialize)]
2215pub struct Screen {
2216    #[serde(rename = "@ID")]
2217    pub id: String,
2218    #[serde(default, rename = "@Name")]
2219    pub name: Option<String>,
2220    #[serde(default, rename = "@ProtocolIdentifier")]
2221    pub protocol_identifier: Option<String>,
2222    #[serde(default, rename = "@ProtocolDescription")]
2223    pub protocol_description: Option<String>,
2224    #[serde(default, rename = "@ReagentSetDescription")]
2225    pub reagent_set_description: Option<String>,
2226    #[serde(default, rename = "@ReagentSetIdentifier")]
2227    pub reagent_set_identifier: Option<String>,
2228    #[serde(default, rename = "@Type")]
2229    pub r#type: Option<String>,
2230    #[serde(default, rename = "Description")]
2231    pub description: Option<String>,
2232    #[serde(default, rename = "Reagent")]
2233    pub reagent: Vec<Reagent>,
2234    #[serde(default, rename = "PlateRef")]
2235    pub plate_ref: Vec<AnnotationRef>,
2236    #[serde(default, rename = "AnnotationRef")]
2237    pub annotation_ref: Vec<AnnotationRef>,
2238}
2239#[cfg_attr(feature = "python", derive(IntoPyObject))]
2240#[derive(Clone, Debug, Serialize, Deserialize)]
2241pub struct ShapeType {
2242    #[serde(default, rename = "@FillColor")]
2243    pub fill_color: Option<i32>,
2244    #[serde(default, rename = "@FillRule")]
2245    pub fill_rule: Option<ShapeFillRuleType>,
2246    #[serde(default, rename = "@StrokeColor")]
2247    pub stroke_color: Option<i32>,
2248    #[serde(default, rename = "@StrokeWidth")]
2249    pub stroke_width: Option<f32>,
2250    #[serde(
2251        default = "ShapeType::default_stroke_width_unit",
2252        rename = "@StrokeWidthUnit"
2253    )]
2254    pub stroke_width_unit: UnitsLength,
2255    #[serde(default, rename = "@StrokeDashArray")]
2256    pub stroke_dash_array: Option<String>,
2257    #[serde(default, rename = "@Text")]
2258    pub text: Option<String>,
2259    #[serde(default, rename = "@FontFamily")]
2260    pub font_family: Option<FontFamilyType>,
2261    #[serde(default, rename = "@FontSize")]
2262    pub font_size: Option<i32>,
2263    #[serde(
2264        default = "ShapeType::default_font_size_unit",
2265        rename = "@FontSizeUnit"
2266    )]
2267    pub font_size_unit: UnitsLength,
2268    #[serde(default, rename = "@FontStyle")]
2269    pub font_style: Option<ShapeFontStyleType>,
2270    #[serde(default, rename = "@Locked")]
2271    pub locked: Option<bool>,
2272    #[serde(rename = "@ID")]
2273    pub id: String,
2274    #[serde(default, rename = "@TheZ")]
2275    pub the_z: Option<i32>,
2276    #[serde(default, rename = "@TheT")]
2277    pub the_t: Option<i32>,
2278    #[serde(default, rename = "@TheC")]
2279    pub the_c: Option<i32>,
2280    #[serde(default, rename = "Transform")]
2281    pub transform: Option<AffineTransform>,
2282    #[serde(default, rename = "AnnotationRef")]
2283    pub annotation_ref: Vec<AnnotationRef>,
2284}
2285impl ShapeType {
2286    pub fn default_stroke_width_unit() -> UnitsLength {
2287        UnitsLength::Pixel
2288    }
2289    pub fn default_font_size_unit() -> UnitsLength {
2290        UnitsLength::Pixel
2291    }
2292}
2293#[derive(Clone, Debug, Serialize, Deserialize)]
2294pub enum ShapeFillRuleType {
2295    #[serde(rename = "EvenOdd")]
2296    EvenOdd,
2297    #[serde(rename = "NonZero")]
2298    NonZero,
2299}
2300#[derive(Clone, Debug, Serialize, Deserialize)]
2301pub enum ShapeFontStyleType {
2302    #[serde(rename = "Bold")]
2303    Bold,
2304    #[serde(rename = "BoldItalic")]
2305    BoldItalic,
2306    #[serde(rename = "Italic")]
2307    Italic,
2308    #[serde(rename = "Normal")]
2309    Normal,
2310}
2311#[cfg_attr(feature = "python", derive(IntoPyObject))]
2312#[derive(Clone, Debug, Serialize, Deserialize)]
2313pub enum ShapeGroup {
2314    #[serde(rename = "Rectangle")]
2315    Rectangle(Rectangle),
2316    #[serde(rename = "Mask")]
2317    Mask(Mask),
2318    #[serde(rename = "Point")]
2319    Point(Label),
2320    #[serde(rename = "Ellipse")]
2321    Ellipse(Ellipse),
2322    #[serde(rename = "Line")]
2323    Line(Line),
2324    #[serde(rename = "Polyline")]
2325    Polyline(Polyline),
2326    #[serde(rename = "Polygon")]
2327    Polygon(Polygon),
2328    #[serde(rename = "Label")]
2329    Label(Label),
2330}
2331#[cfg_attr(feature = "python", derive(IntoPyObject))]
2332#[derive(Clone, Debug, Serialize, Deserialize)]
2333pub struct StageLabel {
2334    #[serde(rename = "@Name")]
2335    pub name: String,
2336    #[serde(default, rename = "@X")]
2337    pub x: Option<f32>,
2338    #[serde(default = "StageLabel::default_x_unit", rename = "@XUnit")]
2339    pub x_unit: UnitsLength,
2340    #[serde(default, rename = "@Y")]
2341    pub y: Option<f32>,
2342    #[serde(default = "StageLabel::default_y_unit", rename = "@YUnit")]
2343    pub y_unit: UnitsLength,
2344    #[serde(default, rename = "@Z")]
2345    pub z: Option<f32>,
2346    #[serde(default = "StageLabel::default_z_unit", rename = "@ZUnit")]
2347    pub z_unit: UnitsLength,
2348}
2349impl StageLabel {
2350    pub fn default_x_unit() -> UnitsLength {
2351        UnitsLength::um
2352    }
2353    pub fn default_y_unit() -> UnitsLength {
2354        UnitsLength::um
2355    }
2356    pub fn default_z_unit() -> UnitsLength {
2357        UnitsLength::um
2358    }
2359}
2360#[cfg_attr(feature = "python", derive(IntoPyObject))]
2361#[derive(Clone, Debug, Serialize, Deserialize)]
2362pub struct StructuredAnnotations {
2363    #[serde(default, rename = "$value")]
2364    pub content: Option<StructuredAnnotationsContent>,
2365}
2366#[allow(clippy::enum_variant_names)]
2367#[cfg_attr(feature = "python", derive(IntoPyObject))]
2368#[derive(Clone, Debug, Serialize, Deserialize)]
2369pub enum StructuredAnnotationsContent {
2370    #[serde(rename = "XMLAnnotation")]
2371    XmlAnnotation(XmlAnnotation),
2372    #[serde(rename = "FileAnnotation")]
2373    FileAnnotation(FileAnnotation),
2374    #[serde(rename = "ListAnnotation")]
2375    ListAnnotation(Annotation),
2376    #[serde(rename = "LongAnnotation")]
2377    LongAnnotation(LongAnnotation),
2378    #[serde(rename = "DoubleAnnotation")]
2379    DoubleAnnotation(DoubleAnnotation),
2380    #[serde(rename = "CommentAnnotation")]
2381    CommentAnnotation(CommentAnnotation),
2382    #[serde(rename = "BooleanAnnotation")]
2383    BooleanAnnotation(BooleanAnnotation),
2384    #[serde(rename = "TimestampAnnotation")]
2385    TimestampAnnotation(CommentAnnotation),
2386    #[serde(rename = "TagAnnotation")]
2387    TagAnnotation(CommentAnnotation),
2388    #[serde(rename = "TermAnnotation")]
2389    TermAnnotation(CommentAnnotation),
2390    #[serde(rename = "MapAnnotation")]
2391    MapAnnotation(MapAnnotation),
2392}
2393#[cfg_attr(feature = "python", derive(IntoPyObject))]
2394#[derive(Clone, Debug, Serialize, Deserialize)]
2395pub struct TiffData {
2396    #[serde(default = "TiffData::default_ifd", rename = "@IFD")]
2397    pub ifd: i32,
2398    #[serde(default = "TiffData::default_first_z", rename = "@FirstZ")]
2399    pub first_z: i32,
2400    #[serde(default = "TiffData::default_first_t", rename = "@FirstT")]
2401    pub first_t: i32,
2402    #[serde(default = "TiffData::default_first_c", rename = "@FirstC")]
2403    pub first_c: i32,
2404    #[serde(default, rename = "@PlaneCount")]
2405    pub plane_count: Option<i32>,
2406    #[serde(default, rename = "UUID")]
2407    pub uuid: Option<TiffDataUuid>,
2408}
2409impl TiffData {
2410    pub fn default_ifd() -> i32 {
2411        0
2412    }
2413    pub fn default_first_z() -> i32 {
2414        0
2415    }
2416    pub fn default_first_t() -> i32 {
2417        0
2418    }
2419    pub fn default_first_c() -> i32 {
2420        0
2421    }
2422}
2423#[cfg_attr(feature = "python", derive(IntoPyObject))]
2424#[derive(Clone, Debug, Serialize, Deserialize)]
2425pub struct TiffDataUuid {
2426    #[serde(default, rename = "@FileName")]
2427    pub file_name: Option<String>,
2428    #[serde(rename = "$text")]
2429    pub content: String,
2430}
2431#[cfg_attr(feature = "python", derive(IntoPyObject))]
2432#[derive(Clone, Debug, Serialize, Deserialize)]
2433pub struct TransmittanceRange {
2434    #[serde(default, rename = "@CutIn")]
2435    pub cut_in: Option<f32>,
2436    #[serde(
2437        default = "TransmittanceRange::default_cut_in_unit",
2438        rename = "@CutInUnit"
2439    )]
2440    pub cut_in_unit: UnitsLength,
2441    #[serde(default, rename = "@CutOut")]
2442    pub cut_out: Option<f32>,
2443    #[serde(
2444        default = "TransmittanceRange::default_cut_out_unit",
2445        rename = "@CutOutUnit"
2446    )]
2447    pub cut_out_unit: UnitsLength,
2448    #[serde(default, rename = "@CutInTolerance")]
2449    pub cut_in_tolerance: Option<f32>,
2450    #[serde(
2451        default = "TransmittanceRange::default_cut_in_tolerance_unit",
2452        rename = "@CutInToleranceUnit"
2453    )]
2454    pub cut_in_tolerance_unit: UnitsLength,
2455    #[serde(default, rename = "@CutOutTolerance")]
2456    pub cut_out_tolerance: Option<f32>,
2457    #[serde(
2458        default = "TransmittanceRange::default_cut_out_tolerance_unit",
2459        rename = "@CutOutToleranceUnit"
2460    )]
2461    pub cut_out_tolerance_unit: UnitsLength,
2462    #[serde(default, rename = "@Transmittance")]
2463    pub transmittance: Option<f32>,
2464}
2465impl TransmittanceRange {
2466    pub fn default_cut_in_unit() -> UnitsLength {
2467        UnitsLength::m
2468    }
2469    pub fn default_cut_out_unit() -> UnitsLength {
2470        UnitsLength::m
2471    }
2472    pub fn default_cut_in_tolerance_unit() -> UnitsLength {
2473        UnitsLength::m
2474    }
2475    pub fn default_cut_out_tolerance_unit() -> UnitsLength {
2476        UnitsLength::m
2477    }
2478}
2479#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, FromStr, IterVariants)]
2480pub enum UnitsElectricPotential {
2481    YV,
2482    ZV,
2483    EV,
2484    PV,
2485    TV,
2486    GV,
2487    MV,
2488    kV,
2489    hV,
2490    daV,
2491    V,
2492    dV,
2493    cV,
2494    mV,
2495    #[serde(rename = "µV")]
2496    uV,
2497    nV,
2498    pV,
2499    fV,
2500    aV,
2501    zV,
2502    yV,
2503}
2504#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, FromStr, IterVariants)]
2505pub enum UnitsFrequency {
2506    YHz,
2507    ZHz,
2508    EHz,
2509    PHz,
2510    THz,
2511    GHz,
2512    MHz,
2513    kHz,
2514    hHz,
2515    daHz,
2516    Hz,
2517    dHz,
2518    cHz,
2519    mHz,
2520    #[serde(rename = "µHz")]
2521    uHz,
2522    nHz,
2523    pHz,
2524    fHz,
2525    aHz,
2526    zHz,
2527    yHz,
2528}
2529#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, FromStr, IterVariants)]
2530pub enum UnitsLength {
2531    Ym,
2532    Zm,
2533    Em,
2534    Pm,
2535    Tm,
2536    Gm,
2537    Mm,
2538    km,
2539    hm,
2540    dam,
2541    m,
2542    dm,
2543    cm,
2544    mm,
2545    #[serde(rename = "µm")]
2546    um,
2547    nm,
2548    pm,
2549    fm,
2550    am,
2551    zm,
2552    ym,
2553    #[serde(rename = "Å")]
2554    A,
2555    #[serde(rename = "thou")]
2556    Thou,
2557    #[serde(rename = "li")]
2558    Li,
2559    #[serde(rename = "in")]
2560    In,
2561    #[serde(rename = "ft")]
2562    Ft,
2563    #[serde(rename = "yd")]
2564    Yd,
2565    #[serde(rename = "mi")]
2566    Mi,
2567    #[serde(rename = "ua")]
2568    Ua,
2569    #[serde(rename = "ly")]
2570    Ly,
2571    #[serde(rename = "pc")]
2572    Pc,
2573    #[serde(rename = "pt")]
2574    Pt,
2575    #[serde(rename = "pixel")]
2576    Pixel,
2577    #[serde(rename = "reference frame")]
2578    ReferenceFrame,
2579}
2580#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, FromStr, IterVariants)]
2581pub enum UnitsPower {
2582    YW,
2583    ZW,
2584    EW,
2585    PW,
2586    TW,
2587    GW,
2588    MW,
2589    kW,
2590    hW,
2591    daW,
2592    W,
2593    dW,
2594    cW,
2595    mW,
2596    #[serde(rename = "µW")]
2597    uW,
2598    nW,
2599    pW,
2600    fW,
2601    aW,
2602    zW,
2603    yW,
2604}
2605#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, FromStr, IterVariants)]
2606pub enum UnitsPressure {
2607    YPa,
2608    ZPa,
2609    EPa,
2610    PPa,
2611    TPa,
2612    GPa,
2613    MPa,
2614    kPa,
2615    hPa,
2616    daPa,
2617    Pa,
2618    dPa,
2619    cPa,
2620    mPa,
2621    #[serde(rename = "µPa")]
2622    uPa,
2623    nPa,
2624    pPa,
2625    fPa,
2626    aPa,
2627    zPa,
2628    yPa,
2629    bar,
2630    Mbar,
2631    kbar,
2632    dbar,
2633    cbar,
2634    mbar,
2635    atm,
2636    psi,
2637    Torr,
2638    mTorr,
2639    #[serde(rename = "mm Hg")]
2640    mmHg,
2641}
2642#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, FromStr, IterVariants)]
2643pub enum UnitsTemperature {
2644    #[serde(rename = "°C")]
2645    C,
2646    #[serde(rename = "°F")]
2647    F,
2648    #[serde(rename = "K")]
2649    K,
2650    #[serde(rename = "°R")]
2651    R,
2652}
2653#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, FromStr, IterVariants)]
2654pub enum UnitsTime {
2655    Ys,
2656    Zs,
2657    Es,
2658    Ps,
2659    Ts,
2660    Gs,
2661    Ms,
2662    ks,
2663    hs,
2664    das,
2665    s,
2666    ds,
2667    cs,
2668    ms,
2669    #[serde(rename = "µs")]
2670    us,
2671    ns,
2672    ps,
2673    fs,
2674    r#as,
2675    zs,
2676    ys,
2677    min,
2678    h,
2679    d,
2680}
2681#[cfg_attr(feature = "python", derive(IntoPyObject))]
2682#[derive(Clone, Debug, Serialize, Deserialize)]
2683pub struct Well {
2684    #[serde(rename = "@ID")]
2685    pub id: String,
2686    #[serde(rename = "@Column")]
2687    pub column: i32,
2688    #[serde(rename = "@Row")]
2689    pub row: i32,
2690    #[serde(default, rename = "@ExternalDescription")]
2691    pub external_description: Option<String>,
2692    #[serde(default, rename = "@ExternalIdentifier")]
2693    pub external_identifier: Option<String>,
2694    #[serde(default, rename = "@Type")]
2695    pub r#type: Option<String>,
2696    #[serde(default = "Well::default_color", rename = "@Color")]
2697    pub color: i32,
2698    #[serde(default, rename = "WellSample")]
2699    pub well_sample: Vec<WellSample>,
2700    #[serde(default, rename = "ReagentRef")]
2701    pub reagent_ref: Option<AnnotationRef>,
2702    #[serde(default, rename = "AnnotationRef")]
2703    pub annotation_ref: Vec<AnnotationRef>,
2704}
2705impl Well {
2706    pub fn default_color() -> i32 {
2707        0
2708    }
2709}
2710#[cfg_attr(feature = "python", derive(IntoPyObject))]
2711#[derive(Clone, Debug, Serialize, Deserialize)]
2712pub struct WellSample {
2713    #[serde(rename = "@ID")]
2714    pub id: String,
2715    #[serde(default, rename = "@PositionX")]
2716    pub position_x: Option<f32>,
2717    #[serde(
2718        default = "WellSample::default_position_x_unit",
2719        rename = "@PositionXUnit"
2720    )]
2721    pub position_x_unit: UnitsLength,
2722    #[serde(default, rename = "@PositionY")]
2723    pub position_y: Option<f32>,
2724    #[serde(
2725        default = "WellSample::default_position_y_unit",
2726        rename = "@PositionYUnit"
2727    )]
2728    pub position_y_unit: UnitsLength,
2729    #[serde(default, rename = "@Timepoint")]
2730    pub timepoint: Option<String>,
2731    #[serde(rename = "@Index")]
2732    pub index: i32,
2733    #[serde(default, rename = "ImageRef")]
2734    pub image_ref: Option<AnnotationRef>,
2735}
2736impl WellSample {
2737    pub fn default_position_x_unit() -> UnitsLength {
2738        UnitsLength::um
2739    }
2740    pub fn default_position_y_unit() -> UnitsLength {
2741        UnitsLength::um
2742    }
2743}
2744#[cfg_attr(feature = "python", derive(IntoPyObject))]
2745#[derive(Clone, Debug, Serialize, Deserialize)]
2746pub struct XmlAnnotation {
2747    #[serde(rename = "@ID")]
2748    pub id: String,
2749    #[serde(default, rename = "@Namespace")]
2750    pub namespace: Option<String>,
2751    #[serde(default, rename = "@Annotator")]
2752    pub annotator: Option<String>,
2753    #[serde(default, rename = "Description")]
2754    pub description: Option<String>,
2755    #[serde(default, rename = "AnnotationRef")]
2756    pub annotation_ref: Vec<AnnotationRef>,
2757    #[serde(rename = "Value")]
2758    pub value: XmlAnnotationValue,
2759}
2760#[derive(Clone, Debug, Serialize, Deserialize)]
2761pub struct XmlAnnotationValue;
2762
2763pub trait Convert: PartialEq {
2764    /// conversion factor between this and SI value
2765    fn as_si(&self) -> Result<f64>;
2766
2767    /// convert a value with this unit into another unit
2768    fn convert(&self, unit: &Self, value: f64) -> Result<f64> {
2769        if self == unit {
2770            Ok(value)
2771        } else {
2772            Ok(value * self.as_si()? / unit.as_si()?)
2773        }
2774    }
2775}
2776
2777macro_rules! impl_enum_variants {
2778    ($($t:ty $(,)?)*) => {
2779        $(
2780            impl $t {
2781                pub fn variants() -> Vec<Self> {
2782                    Self::iter().collect::<Vec<_>>()
2783                }
2784            }
2785        )*
2786    };
2787}
2788
2789impl_enum_variants!(
2790    UnitsElectricPotential,
2791    UnitsFrequency,
2792    UnitsLength,
2793    UnitsPower,
2794    UnitsPressure,
2795    UnitsTemperature,
2796    UnitsTime,
2797);
2798
2799impl Convert for UnitsElectricPotential {
2800    fn as_si(&self) -> Result<f64> {
2801        match self {
2802            UnitsElectricPotential::YV => Ok(1e24),
2803            UnitsElectricPotential::ZV => Ok(1e21),
2804            UnitsElectricPotential::EV => Ok(1e18),
2805            UnitsElectricPotential::PV => Ok(1e15),
2806            UnitsElectricPotential::TV => Ok(1e12),
2807            UnitsElectricPotential::GV => Ok(1e9),
2808            UnitsElectricPotential::MV => Ok(1e6),
2809            UnitsElectricPotential::kV => Ok(1e3),
2810            UnitsElectricPotential::hV => Ok(1e2),
2811            UnitsElectricPotential::daV => Ok(1e1),
2812            UnitsElectricPotential::V => Ok(1e0),
2813            UnitsElectricPotential::dV => Ok(1e-1),
2814            UnitsElectricPotential::cV => Ok(1e-2),
2815            UnitsElectricPotential::mV => Ok(1e-3),
2816            UnitsElectricPotential::uV => Ok(1e-6),
2817            UnitsElectricPotential::nV => Ok(1e-9),
2818            UnitsElectricPotential::pV => Ok(1e-12),
2819            UnitsElectricPotential::fV => Ok(1e-15),
2820            UnitsElectricPotential::aV => Ok(1e-18),
2821            UnitsElectricPotential::zV => Ok(1e-21),
2822            UnitsElectricPotential::yV => Ok(1e-24),
2823        }
2824    }
2825}
2826
2827impl Convert for UnitsFrequency {
2828    fn as_si(&self) -> Result<f64> {
2829        match self {
2830            UnitsFrequency::YHz => Ok(1e24),
2831            UnitsFrequency::ZHz => Ok(1e21),
2832            UnitsFrequency::EHz => Ok(1e18),
2833            UnitsFrequency::PHz => Ok(1e15),
2834            UnitsFrequency::THz => Ok(1e12),
2835            UnitsFrequency::GHz => Ok(1e9),
2836            UnitsFrequency::MHz => Ok(1e6),
2837            UnitsFrequency::kHz => Ok(1e3),
2838            UnitsFrequency::hHz => Ok(1e2),
2839            UnitsFrequency::daHz => Ok(1e1),
2840            UnitsFrequency::Hz => Ok(1e0),
2841            UnitsFrequency::dHz => Ok(1e-1),
2842            UnitsFrequency::cHz => Ok(1e-2),
2843            UnitsFrequency::mHz => Ok(1e-3),
2844            UnitsFrequency::uHz => Ok(1e-6),
2845            UnitsFrequency::nHz => Ok(1e-9),
2846            UnitsFrequency::pHz => Ok(1e-12),
2847            UnitsFrequency::fHz => Ok(1e-15),
2848            UnitsFrequency::aHz => Ok(1e-18),
2849            UnitsFrequency::zHz => Ok(1e-21),
2850            UnitsFrequency::yHz => Ok(1e-24),
2851        }
2852    }
2853}
2854
2855impl Convert for UnitsLength {
2856    fn as_si(&self) -> Result<f64> {
2857        match self {
2858            UnitsLength::Ym => Ok(1e24),
2859            UnitsLength::Zm => Ok(1e21),
2860            UnitsLength::Em => Ok(1e18),
2861            UnitsLength::Pm => Ok(1e15),
2862            UnitsLength::Tm => Ok(1e12),
2863            UnitsLength::Gm => Ok(1e9),
2864            UnitsLength::Mm => Ok(1e6),
2865            UnitsLength::km => Ok(1e3),
2866            UnitsLength::hm => Ok(1e2),
2867            UnitsLength::dam => Ok(1e1),
2868            UnitsLength::m => Ok(1e0),
2869            UnitsLength::dm => Ok(1e-1),
2870            UnitsLength::cm => Ok(1e-2),
2871            UnitsLength::mm => Ok(1e-3),
2872            UnitsLength::um => Ok(1e-6),
2873            UnitsLength::nm => Ok(1e-9),
2874            UnitsLength::pm => Ok(1e-12),
2875            UnitsLength::fm => Ok(1e-15),
2876            UnitsLength::am => Ok(1e-18),
2877            UnitsLength::zm => Ok(1e-21),
2878            UnitsLength::ym => Ok(1e-24),
2879            UnitsLength::A => Ok(1e-10),
2880            UnitsLength::Thou => Ok(2.54e-5),
2881            UnitsLength::Li => Ok(5e2),
2882            UnitsLength::In => Ok(2.54e-2),
2883            UnitsLength::Ft => Ok(3.05e-1),
2884            UnitsLength::Yd => Ok(9.14e-1),
2885            UnitsLength::Mi => Ok(1.609344e3),
2886            UnitsLength::Ua => Ok(1.496e11),
2887            UnitsLength::Ly => Ok(9.461e15),
2888            UnitsLength::Pc => Ok(3.086e16),
2889            UnitsLength::Pt => Ok(3.52778e-4),
2890            UnitsLength::Pixel => Err(anyhow!("Size of pixel is unknown")),
2891            UnitsLength::ReferenceFrame => Err(anyhow!("Size of reference frame is unknown")),
2892        }
2893    }
2894}
2895
2896impl Convert for UnitsPower {
2897    fn as_si(&self) -> Result<f64> {
2898        match self {
2899            UnitsPower::YW => Ok(1e24),
2900            UnitsPower::ZW => Ok(1e21),
2901            UnitsPower::EW => Ok(1e18),
2902            UnitsPower::PW => Ok(1e15),
2903            UnitsPower::TW => Ok(1e12),
2904            UnitsPower::GW => Ok(1e9),
2905            UnitsPower::MW => Ok(1e6),
2906            UnitsPower::kW => Ok(1e3),
2907            UnitsPower::hW => Ok(1e2),
2908            UnitsPower::daW => Ok(1e1),
2909            UnitsPower::W => Ok(1e0),
2910            UnitsPower::dW => Ok(1e-1),
2911            UnitsPower::cW => Ok(1e-2),
2912            UnitsPower::mW => Ok(1e-3),
2913            UnitsPower::uW => Ok(1e-6),
2914            UnitsPower::nW => Ok(1e-9),
2915            UnitsPower::pW => Ok(1e-12),
2916            UnitsPower::fW => Ok(1e-15),
2917            UnitsPower::aW => Ok(1e-18),
2918            UnitsPower::zW => Ok(1e-21),
2919            UnitsPower::yW => Ok(1e-24),
2920        }
2921    }
2922}
2923
2924impl Convert for UnitsPressure {
2925    fn as_si(&self) -> Result<f64> {
2926        match self {
2927            UnitsPressure::YPa => Ok(1e24),
2928            UnitsPressure::ZPa => Ok(1e21),
2929            UnitsPressure::EPa => Ok(1e18),
2930            UnitsPressure::PPa => Ok(1e15),
2931            UnitsPressure::TPa => Ok(1e12),
2932            UnitsPressure::GPa => Ok(1e9),
2933            UnitsPressure::MPa => Ok(1e6),
2934            UnitsPressure::kPa => Ok(1e3),
2935            UnitsPressure::hPa => Ok(1e2),
2936            UnitsPressure::daPa => Ok(1e1),
2937            UnitsPressure::Pa => Ok(1e0),
2938            UnitsPressure::dPa => Ok(1e-1),
2939            UnitsPressure::cPa => Ok(1e-2),
2940            UnitsPressure::mPa => Ok(1e-3),
2941            UnitsPressure::uPa => Ok(1e-6),
2942            UnitsPressure::nPa => Ok(1e-9),
2943            UnitsPressure::pPa => Ok(1e-12),
2944            UnitsPressure::fPa => Ok(1e-15),
2945            UnitsPressure::aPa => Ok(1e-18),
2946            UnitsPressure::zPa => Ok(1e-21),
2947            UnitsPressure::yPa => Ok(1e-24),
2948            UnitsPressure::bar => Ok(1e5),
2949            UnitsPressure::Mbar => Ok(1e11),
2950            UnitsPressure::kbar => Ok(1e8),
2951            UnitsPressure::dbar => Ok(1e4),
2952            UnitsPressure::cbar => Ok(1e3),
2953            UnitsPressure::mbar => Ok(1e2),
2954            UnitsPressure::atm => Ok(1.01325e5),
2955            UnitsPressure::psi => Ok(6.89476e3),
2956            UnitsPressure::Torr => Ok(1.33322e3),
2957            UnitsPressure::mTorr => Ok(1.33322),
2958            UnitsPressure::mmHg => Ok(1.33322e2),
2959        }
2960    }
2961}
2962
2963impl Convert for UnitsTemperature {
2964    fn as_si(&self) -> Result<f64> {
2965        match self {
2966            UnitsTemperature::C => Err(anyhow!("No conversion to K by multiplication only")),
2967            UnitsTemperature::F => Err(anyhow!("No conversion to K by multiplication only")),
2968            UnitsTemperature::K => Ok(1e1),
2969            UnitsTemperature::R => Ok(5f64 / 9f64),
2970        }
2971    }
2972
2973    fn convert(&self, unit: &Self, value: f64) -> Result<f64> {
2974        match (self, unit) {
2975            (UnitsTemperature::F, UnitsTemperature::C) => Ok((value - 32.) * 5. / 9.),
2976            (UnitsTemperature::K, UnitsTemperature::C) => Ok(value - 273.15),
2977            (UnitsTemperature::R, UnitsTemperature::C) => Ok((value * 5. / 9.) - 273.15),
2978            (UnitsTemperature::C, UnitsTemperature::F) => Ok((value * 9. / 5.) + 32.),
2979            (UnitsTemperature::K, UnitsTemperature::F) => Ok((value * 9. / 5.) - 459.67),
2980            (UnitsTemperature::R, UnitsTemperature::F) => Ok(value - 459.67),
2981            (UnitsTemperature::C, UnitsTemperature::K) => Ok(value + 273.15),
2982            (UnitsTemperature::F, UnitsTemperature::K) => Ok((value + 459.67) * 5. / 9.),
2983            (UnitsTemperature::R, UnitsTemperature::K) => Ok(value * 5. / 9.),
2984            (UnitsTemperature::C, UnitsTemperature::R) => Ok((value + 273.15) * 9. / 5.),
2985            (UnitsTemperature::F, UnitsTemperature::R) => Ok(value + 459.67),
2986            (UnitsTemperature::K, UnitsTemperature::R) => Ok(value * 9. / 5.),
2987            _ => Ok(value),
2988        }
2989    }
2990}
2991
2992impl Convert for UnitsTime {
2993    fn as_si(&self) -> Result<f64> {
2994        match self {
2995            UnitsTime::Ys => Ok(1e24),
2996            UnitsTime::Zs => Ok(1e21),
2997            UnitsTime::Es => Ok(1e18),
2998            UnitsTime::Ps => Ok(1e15),
2999            UnitsTime::Ts => Ok(1e12),
3000            UnitsTime::Gs => Ok(1e9),
3001            UnitsTime::Ms => Ok(1e6),
3002            UnitsTime::ks => Ok(1e3),
3003            UnitsTime::hs => Ok(1e2),
3004            UnitsTime::das => Ok(1e1),
3005            UnitsTime::s => Ok(1e0),
3006            UnitsTime::ds => Ok(1e-1),
3007            UnitsTime::cs => Ok(1e-2),
3008            UnitsTime::ms => Ok(1e-3),
3009            UnitsTime::us => Ok(1e-6),
3010            UnitsTime::ns => Ok(1e-9),
3011            UnitsTime::ps => Ok(1e-12),
3012            UnitsTime::fs => Ok(1e-15),
3013            UnitsTime::r#as => Ok(1e-18),
3014            UnitsTime::zs => Ok(1e-21),
3015            UnitsTime::ys => Ok(1e-24),
3016            UnitsTime::min => Ok(6e1),
3017            UnitsTime::h => Ok(3.6e2),
3018            UnitsTime::d => Ok(8.64e4),
3019        }
3020    }
3021}