engiNIR
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. It comes as a Python library and as a desktop viewer that guides you through the whole workflow.
Try it
Install the viewer (see Installation), start it and choose Open Example Project. The example is a synthetic tablet study: four calibration scans with five tablets each, one scan to predict, and a fitted PLS model, so every step of the workflow has something to show.
Workflow
The viewer's workflow strip, Data → ROIs → Values → Model → Predict, follows the steps of a calibration. A tick marks a finished step, and the Checks tab says what a step still needs, with a button that fixes it.
- Data. Import EVK EIFF, ENVI, HDF5, CSV/Excel, SPC, SPA and JCAMP-DX data. Several scans form one project. Raw counts are corrected to reflectance or absorbance with dark and white references (from separate files, frames of the same scan or another scan) or detector levels.
- ROIs. Draw regions of interest on the samples, one by one or as a grid over a tray.
- Values. Define targets with units and enter the reference value of each ROI.
- Model. Preprocess with Savitzky-Golay smoothing and derivatives, SNV, MSC, EMSC, detrending, AsLS baseline correction and band selection, and fit 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). Review the figures of merit, scores and loadings, VIP and selectivity ratio, Hotelling's T² and the distance to the model (DModX); a verdict sums up whether the model is fit for use.
- Predict. Apply the model to 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.
| Data | Model: spectral diagnostics | Predict |
|---|---|---|
| A scan with its ROIs, sensor frame and profiles | Coefficients, loadings, VIP, selectivity ratio | Prediction map, per-tablet results |
Every plot exports PNG, SVG and CSV.
Guiding principles
Sound by construction. Calibration and prediction run through one pipeline. Models are validated by sample, not by pixel: ROIs are the unit of cross-validation and of every reported metric. A scan that does not match the model is refused, and every predicted pixel states whether it lies inside the model and how precise it is.
Traceable for regulated work. One project file links data, references, ROIs, recipes and models by stable ids; stored objects are never overwritten, and a refit is a new model. engiNIR supplies the evidence that ICH Q2(R2), Q12 and Q14, USP <1039> and <1119> and the FDA PAT guidance ask for; see the regulatory context for what it covers and what it does not.
Installation
engiNIR needs Python 3.12 or newer and runs on Windows, macOS and Linux.
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"
The viewer on macOS and Linux: install uv, then the viewer as a tool, and start it from a terminal:
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install enginir
enginir-viewer
In a Python project, with uv or pip:
uv add enginir
pip install enginir
Then start the viewer:
uv run enginir-viewer # welcome screen
uv run enginir-viewer project.h5 # open a project
uv run enginir-viewer scan.eiff --dark dark.eiff --white white.eiff
enginir-viewer-console is the same viewer with a console window, for
messages and --help.
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, and the file opens in the viewer. 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"]
model.verdict() # is the model fit for use, and why
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.io import load_spectra
from enginir.models import PLSRegression
from enginir.preprocessing import SNV
from enginir.validation import cross_validate
X = load_spectra("spectra.csv").X # (n_samples, n_bands)
# y: reference values, samples: one label per spectrum
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. Changes are listed in the changelog and the releases.
Development
Clone the repository, then:
uv sync --all-extras
uv run pytest
uv run python -m sphinx -W -E -b html docs docs/_build/html
Questions and bug reports go to the issue tracker.
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.7.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| enginir-1.7.4.tar.gz | 541.8 kB | With provenance | Details for enginir-1.7.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| enginir-1.7.4-py3-none-any.whl | Python 3 | none | any | Details for enginir-1.7.4-py3-none-any.whl |
Total release size: 1.2 MB
Release files / enginir-1.7.4.tar.gz
| Download URL | enginir-1.7.4.tar.gz |
|---|---|
| Size | 541.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17e8486b61b998599348c64a8ad9ee0909d264eb8ab1a6846803541d32866eb1
|
|
BLAKE2b-256 checksum How to use checksums |
46fcad054082575595d8134d616a46ff7d08ef60a862a1c5a1e94bba9c1144a5
|
| 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 22, 2026.
Transparency logRelease files / enginir-1.7.4-py3-none-any.whl
| Download URL | enginir-1.7.4-py3-none-any.whl |
|---|---|
| Size | 609.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
115ee5a7f5f8c86a0388e7da88d06c0bb74ec0e2c24d21f0959dd6c50b11ca3c
|
|
BLAKE2b-256 checksum How to use checksums |
91883973e1eb65a36815bcb77616ecdd0af16527e69b59176b7ce04d10dfd882
|
| 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 22, 2026.
Transparency logSecurity for enginir 1.7.4
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.
Attestation for enginir-1.7.4.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 22, 2026.
Transparency logA 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.