Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

engiNIR

engiNIR

DOI Documentation PyPI Python

engiNIR turns near-infrared spectra and hyperspectral images into validated calibration models and property predictions, with every step recorded. It is built for pharmaceutical process analytics: tablets on a tray, scanned by a push-broom camera, measured against target values.

Workflow

  1. Import EVK EIFF, ENVI, HDF5, CSV/Excel, SPC, SPA and JCAMP-DX data. Several scans form one project; references can come from separate files, frames of the same scan or another scan.
  2. Correct raw counts to reflectance or absorbance with dark and white references or detector levels.
  3. Draw regions (ROIs) on the samples, one by one or as a grid over a tray, and assign target values.
  4. Preprocess with recipes: Savitzky-Golay smoothing and derivatives, SNV, MSC, EMSC, detrending, AsLS baseline correction and band selection.
  5. Model with PLS or PCR, cross-validated by ROI so that no sample's pixels are split across folds. The number of components can be chosen automatically (one-SE, Q² and F-test rules with a noise guard).
  6. Review figures of merit, scores and loadings, VIP and selectivity ratio, Hotelling's T² and the distance to the model (DModX).
  7. Predict new scans: a prediction map with the distance to the model and a 95 % prediction interval per pixel, and per-tablet results for marked prediction ROIs.

Guarantees

  • Calibration and prediction run through the same reference correction and preprocessing pipeline; fitted MSC/EMSC states are stored with the model.
  • Pixels are the data points of the fit, ROIs the reporting unit: cross-validation, reported metrics and stateful preprocessing respect the ROI.
  • Prediction is refused when a scan does not match the model's instrument format, number of bands, reference correction or signal unit.
  • Every pixel prediction says whether it is inside the model (DModXPS and T²PS against their 0.99 limits) and how precise it is (leverage-based interval); outside the model it gets no interval.
  • One project file links data, references, ROIs, recipes and models by stable ids; stored objects are never silently overwritten. Predictions are kept in memory and logged with their provenance.

Usage

engiNIR needs Python 3.12 or newer. Add it to a uv project:

uv add enginir

To work on engiNIR itself, clone the repository and run uv sync --all-extras.

The viewer on Windows, without Python knowledge: paste this line into PowerShell, then start engiNIR Viewer from the Start menu (details in the installation guide):

powershell -ExecutionPolicy ByPass -c "irm https://github.com/TUstudents/engiNIR/releases/latest/download/install-enginir-for-windows.ps1 | iex"

Viewer

The desktop viewer runs the whole workflow interactively:

  • Explore: images and spectra of the project's scans, ROIs and ROI grids.
  • Model: target values, fitting and refitting, and the diagnostics pages Fit, Spectral (coefficients, loadings, VIP), Components and Distance (DModX and T²).
  • Predict: prediction ROIs and maps with diagnostic and uncertainty layers, per-ROI results in the ROI table.

Every plot exports PNG, SVG and CSV.

uv run enginir-viewer                                  # welcome screen
uv run enginir-viewer scan.eiff --dark dark.eiff --white white.eiff
uv run enginir-viewer project.h5

Library

The library can be used in two ways.

Project mode records every step in a project file, so each result is reproducible and traceable to its data. Recommended unless you know exactly which steps you need:

from enginir import PreprocessingRecipe, Project

project = Project.create("tablets.h5")
scan = project.add_dataset("scan.eiff", dark="dark.eiff", white="white.eiff")
project.add_target("API content", unit="% w/w")
scan.add_roi("tablet 1", frames=(0, 4), rows=(0, 9), values={"API content": 1.0})
# ... more ROIs, and ROIs marked job="prediction" for the tablets to predict
model = project.fit("API content", recipe=PreprocessingRecipe(snv=True),
                    n_components="auto")
model.metrics["rmsecv"]

prediction = model.predict("new_scan.eiff")
prediction.map                  # one value per pixel
prediction.dmodx_map            # distance to the model
prediction.interval_map()       # ± half-width of the 95 % prediction interval

result = model.predict_rois()   # per tablet: mean, SD, interval, RMSEP

Function mode uses the readers, preprocessing steps, models and validation functions directly on arrays, as scikit-learn estimators:

from sklearn.pipeline import make_pipeline
from enginir.models import PLSRegression
from enginir.preprocessing import SNV
from enginir.validation import cross_validate

model = make_pipeline(SNV(), PLSRegression(n_components=4))
cv = cross_validate(model, X, y, cv="logo", groups=samples)   # cv["rmsecv"], cv["y_pred"]

Documentation

The documentation is at https://enginir.readthedocs.io: a workflow guide, the user guide for each step and the viewer, the API reference, and the file formats. To build it locally:

uv sync --extra docs
uv run python -m sphinx -b html docs docs/_build/html

Citation

If you use engiNIR in your work, please cite:

Johannes Poms. (2026). TUstudents/engiNIR: A universal engineering tool for near-infrared spectra and hyperspectral imaging. Zenodo. https://doi.org/10.5281/zenodo.23235907

License

engiNIR © 2026 Johannes Poms and contributors, licensed under CC BY 4.0.

Metadata

Release files for enginir 1.6.0rc3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enginir 1.6.0rc3
File Size Uploaded Provenance Actions
enginir-1.6.0rc3.tar.gz 499.6 kB With provenance Details for enginir-1.6.0rc3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for enginir 1.6.0rc3
File Interpreter ABI Platform Actions
enginir-1.6.0rc3-py3-none-any.whl Python 3 none any Details for enginir-1.6.0rc3-py3-none-any.whl

Total release size: 1.1 MB

Release files / enginir-1.6.0rc3.tar.gz

Download URL enginir-1.6.0rc3.tar.gz
Size 499.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f182954ccf9513fb8c5c7afb294e32ec7458a244ec3b8a9a81f62708bfa02f43
BLAKE2b-256 checksum
How to use checksums
363f2335bad89bde2c187dcabfb320200d0650b910ca4137172777cefeeefc16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / enginir-1.6.0rc3-py3-none-any.whl

Download URL enginir-1.6.0rc3-py3-none-any.whl
Size 566.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08314996a9e1d6fa984919e4de6d107632f4f668e2ae8e581cc038ca93c269c1
BLAKE2b-256 checksum
How to use checksums
06ea78ea8c653d4065e4c661a044cd2ce313cc4e97700eb8b0f7f69e3020eaeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for enginir 1.6.0rc3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for enginir-1.6.0rc3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page