#![forbid(unsafe_code)]
#![warn(missing_docs)]
mod assurance;
#[doc(hidden)]
pub mod atf;
#[doc(hidden)]
pub mod command;
#[doc(hidden)]
pub mod dataset;
#[doc(hidden)]
pub mod file;
use std::path::Path;
use openreadout_core::Result;
use openreadout_core::model::{DetectConfidence, FormatDescriptor};
use openreadout_core::reader::{Dataset, Detection, FormatReader, has_extension};
use openreadout_core::source::Input;
pub use atf::{ATF_FORMAT_ID, AtfReader};
#[doc(hidden)]
pub use atf::{
AtfColumn, AtfDataset, MAX_ATF_LEN, MAX_COLUMNS, MAX_HEADER_RECORDS, looks_like_atf,
};
#[doc(hidden)]
pub use command::{CommandPlan, command_plan, command_sweep};
#[doc(hidden)]
pub use dataset::{AbfDataset, MAX_READ_SAMPLES, command_trace_info, trace_info};
#[doc(hidden)]
pub use file::{
ABF1_BASIC_LEN, ABF1_EXTENDED_LEN, AbfFile, AcquisitionMode, BLOCK_LEN, DigitalEpoch, Epoch,
EpochKind, Generation, InputChannel, MAX_RECORDS, MAX_STRINGS_LEN, OutputChannel,
SECTION_ENTRY_LEN, SECTION_MAP_OFFSET, SECTION_NAMES, SampleFormat, SectionEntry, Sweep, Tag,
Telegraph, channel_scaling, guid_text, iso_datetime, parse_string_table, usable_factor,
};
pub const FORMAT_ID: &str = "abf";
#[derive(Debug, Default, Clone, Copy)]
pub struct AbfReader;
impl FormatReader for AbfReader {
fn assurance(&self) -> Option<&'static openreadout_core::assurance::AssuranceProfile> {
Some(&assurance::ABF)
}
fn descriptor(&self) -> FormatDescriptor {
FormatDescriptor {
id: FORMAT_ID.into(),
name: "Axon Binary Format (ABF)".into(),
vendor: "Molecular Devices (Axon Instruments) pCLAMP".into(),
extensions: vec!["abf".into()],
family: "electrophysiology".into(),
can_read: true,
can_write: false,
confidence: assurance::ABF.confidence,
known_gaps: vec![
"Command (DAC) waveforms are synthesized (trace 1) for ABF 2 episodic files with step, ramp and pulse-train epochs only; stimulus files, user lists, alternating outputs, conditioning trains, triangle/cosine/biphasic epochs and ABF 1 files keep the epoch table only".into(),
"User lists, statistics, math, scope and voice-tag sections are listed but not decoded".into(),
"Pre-1.6 ABF 1 files: telegraph, protocol path and 20-entry epoch tables are not in the header and are not reported".into(),
"Old pCLAMP/Axotape files without an `ABF ` signature (CLPX, FTCX) are not read".into(),
],
}
}
fn sniff(&self, head: &[u8], path: &Path) -> Option<Detection> {
match head.get(..4) {
Some(b"ABF2") => Some(Detection {
format_id: FORMAT_ID,
confidence: DetectConfidence::Definite,
note: None,
}),
Some(b"ABF ") => Some(Detection {
format_id: FORMAT_ID,
confidence: DetectConfidence::Definite,
note: None,
}),
_ if has_extension(path, &["abf"]) => Some(Detection {
format_id: FORMAT_ID,
confidence: DetectConfidence::ExtensionOnly,
note: Some("ABF extension but no `ABF ` or `ABF2` signature at byte 0".into()),
}),
_ => None,
}
}
fn open(&self, path: &Path) -> Result<Box<dyn Dataset>> {
Ok(Box::new(AbfDataset::open(path)?))
}
fn open_input(&self, input: &Input) -> Result<Box<dyn Dataset>> {
Ok(Box::new(AbfDataset::open_input(input)?))
}
fn reads_any_source(&self) -> bool {
true
}
}