use openreadout_core::FileInfo;
use openreadout_core::assurance::{
self as a, AssuranceProfile, Basis, CalibrationStatus, FeatureKind as K, Observations, Scope,
Validated,
};
use openreadout_core::provenance::Confidence;
pub(crate) static PLEXON: AssuranceProfile = AssuranceProfile {
format_id: "plexon",
observe,
validated: PLEXON_VALIDATED,
confidence: PLEXON_CONFIDENCE,
basis: Basis::PriorArt,
};
fn observe(info: &FileInfo) -> Observations {
let mut o = Observations::default();
if let Some(v) = &info.format_version {
o.feature(
K::FormatVersion,
v,
&[Scope::Metadata, Scope::Traces, Scope::Tables],
);
}
let apps = a::extra_values(info, "application");
for app in &apps {
o.context(K::Writer, a::writer_name_only(app));
}
if apps.is_empty() && info.format_version.as_deref() == Some("PL2") {
o.context(K::Writer, "unnamed (offline)");
}
if !info.traces.is_empty() {
let container = if info.format_version.as_deref() == Some("PL2") {
"PL2"
} else {
"PLX"
};
o.feature(
K::Record,
format!("{container} continuous"),
&[Scope::Traces],
);
}
if !info.traces.is_empty() {
o.calibration(
"ADC counts to volts",
CalibrationStatus::Applied,
&[Scope::Traces, Scope::Tables],
"continuous samples and waveforms are scaled with the header's gains and maximum voltages",
);
}
if let Some(n) = a::note_with(info, "continuous channel header(s) without data blocks") {
o.undecoded("empty continuous channels", &[], n.to_string());
}
if let Some(n) = a::note_with(info, "structural problems found") {
o.undecoded(
"damaged data blocks",
&[Scope::Traces, Scope::Tables],
n.to_string(),
);
}
o
}
const PLEXON_CONFIDENCE: Confidence = Confidence::Medium;
#[rustfmt::skip]
const PLEXON_VALIDATED: &[Validated] = &[
a::row(K::Field, "experiment.acquisition.started_at", 4, 1, 11),
a::row(K::FormatVersion, "PL2", 0, 0, 2),
a::row(K::FormatVersion, "PLX 101", 2, 1, 2),
a::row(K::FormatVersion, "PLX 103", 1, 1, 1),
a::row(K::FormatVersion, "PLX 105", 1, 1, 1),
a::row(K::FormatVersion, "PLX 106", 2, 1, 3),
a::row(K::FormatVersion, "PLX 107", 1, 1, 2),
a::row(K::Record, "PL2 continuous", 0, 0, 2),
a::row(K::Record, "PLX continuous", 5, 1, 6),
a::row(K::Writer, "OmniPlex", 1, 1, 3),
a::row(K::Writer, "SC", 0, 0, 1),
];