med64 0.0.2

Headless MED64 electrophysiology toolkit: .modat I/O, spike/burst analysis, assays, spike-rate maps, and CSV/HTML/SVG/HDF5 export
Documentation
use std::path::Path;

use crate::analysis::AnalysisReport;
#[cfg(not(feature = "hdf5"))]
use crate::error::Med64Error;
use crate::error::Result;

#[cfg(feature = "hdf5")]
pub use crate::export_hdf5::{write_spike_hdf5, SpikeHdf5Options};

#[cfg(feature = "hdf5")]
pub fn write_spike_timestamps_hdf5(report: &AnalysisReport, path: impl AsRef<Path>) -> Result<()> {
    // Default HDF5 export uses SIS-compatible layout (hdf5-no-c).
    write_spike_hdf5(report, path, &SpikeHdf5Options::default())
}

#[cfg(not(feature = "hdf5"))]
pub fn write_spike_timestamps_hdf5(_report: &AnalysisReport, path: impl AsRef<Path>) -> Result<()> {
    Err(Med64Error::InvalidWrite {
        message: format!(
            "HDF5 export requires the `hdf5` feature; rebuild with `--features hdf5` (requested {})",
            path.as_ref().display()
        ),
    })
}

#[cfg(not(feature = "hdf5"))]
pub fn write_spike_hdf5(
    _report: &AnalysisReport,
    path: impl AsRef<Path>,
    _options: &SpikeHdf5Options,
) -> Result<()> {
    Err(Med64Error::InvalidWrite {
        message: format!(
            "HDF5 export requires the `hdf5` feature (requested {})",
            path.as_ref().display()
        ),
    })
}

#[cfg(not(feature = "hdf5"))]
#[derive(Debug, Clone)]
pub struct SpikeHdf5Options {
    pub include_timestamps: bool,
    pub include_filtered: bool,
    pub include_raw: bool,
    pub include_med64_sidecar: bool,
    pub merge_traces: bool,
    pub default_trace: u32,
    pub zero_based_channel_ids: bool,
    pub timestamp_decimals: u32,
}

#[cfg(not(feature = "hdf5"))]
impl Default for SpikeHdf5Options {
    fn default() -> Self {
        Self {
            include_timestamps: true,
            include_filtered: true,
            include_raw: false,
            include_med64_sidecar: true,
            merge_traces: true,
            default_trace: 1,
            zero_based_channel_ids: true,
            timestamp_decimals: 3,
        }
    }
}