FoodSpec is a protocol-driven spectroscopy framework for food matrices (Raman, FTIR, NIR). It prioritizes reproducibility, quality control, and trustworthy outputs for scientific workflows.
- Protocol-driven spectroscopy workflows
- Reproducibility by default
- Trust and uncertainty as first-class outputs
- QC is mandatory, not optional
- Designed for food matrices with complex backgrounds
- Not a general deep learning framework
- Not a vendor replacement tool
- Not claiming clinical or regulatory approval
- Data objects:
Spectrum,SpectraSet,SpectralDatasetfor consistent data and metadata handling. - Data extraction: CSV, JCAMP, SPC, OPUS loaders and vendor adapters.
- Programming engine: preprocessing steps (baseline, smoothing, normalization) with reusable pipelines.
- QC system: spectral QC, dataset QC, leakage detection, drift monitoring.
- Feature engineering: peak ratios, chemometrics (PCA/PLS), minimal marker panels.
- Modeling & validation: classical ML, nested CV, confidence/metrics reporting.
- Trust & uncertainty: calibration, conformal prediction, reliability metrics.
- Visualization & reporting: HTML/PDF reports, figures, reproducibility packs.
from foodspec.data_objects import SpectraSet
from foodspec.engine.preprocessing import baseline_als, smooth_savgol, normalize_vector
import numpy as np
# Example spectra
spectra = np.random.rand(5, 100)
wn = np.linspace(400, 1800, 100)
fs = SpectraSet(x=spectra, wavenumbers=wn, metadata=None, modality="raman")
# Preprocess
spectra = baseline_als(spectra)
spectra = smooth_savgol(spectra, window_length=9, polyorder=3)
spectra = normalize_vector(spectra, norm="l2")# Validate input
foodspec io validate data/oils.csv
# Spectral QC
foodspec qc spectral data/oils.csv --run-dir runs/qc
# Run protocol preprocessing
foodspec preprocess run --protocol examples/configs/oil_auth_quickstart.yml --input data/oils.csv- Design philosophy:
docs/concepts/design_philosophy.md - Full docs: https://chandrasekarnarayana.github.io/foodspec/
pip install -e '.[dev]'
pytest
ruff check src/ tests/
mkdocs buildSee CITATION.cff for citation metadata.
