Skip to content

Headless, research-grade Python toolkit for Raman and FTIR spectroscopy in food science.

License

Notifications You must be signed in to change notification settings

chandrasekarnarayana/foodspec

FoodSpec

FoodSpec logo

Tests Python License

FoodSpec is a protocol-driven spectroscopy framework for food matrices (Raman, FTIR, NIR). It prioritizes reproducibility, quality control, and trustworthy outputs for scientific workflows.

Goals

  • 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

Non-goals

  • Not a general deep learning framework
  • Not a vendor replacement tool
  • Not claiming clinical or regulatory approval

Features (mindmap-aligned)

  • Data objects: Spectrum, SpectraSet, SpectralDataset for 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.

Quickstart (Python)

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")

Quickstart (CLI)

# 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

Documentation

Development

pip install -e '.[dev]'
pytest
ruff check src/ tests/
mkdocs build

Citation

See CITATION.cff for citation metadata.