Skip to content

nefi Neural-Field Inversion · CAB Lab, Princeton University

Physics-faithful inverse problems, solved from a single measurement.

nefi recovers hidden fields such as spin densities, conductivities, sound speeds and thermal diffusivities from one measurement and a differentiable model of the instrument. No training data is needed. The unknown is represented by a coordinate neural field, the physics is enforced as a hard constraint, and an adaptive coarse-to-fine schedule fits the field to the data while built-in diagnostics report how far the result can be trusted.

$ pip install nefi
Four inverse problems: NV noise spectra to spin sources, a sparse-view sinogram to an attenuation map, an NV stray-field image to a sheet current, acoustic traces to a sound-speed map
Four of the registered problems, each showing the simulated measurement on the left and the reconstruction on the right. Every system runs on a CPU in under 15 s.
Physics dipolar noise spectra, heat diffusion, elliptic PDEs, acoustic waves, scattering, angular-spectrum optics, reaction–diffusion, …
Representations neural fields, grids, hash grids, level sets, Gaussian splats, layered media, star shapes, …
Papers NeTMY on NV-center sensing, NeFTY on thermal tomography, …

The recipe

One workflow for many instruments

Every problem in nefi is built from the same seven pieces. Change any one of them, such as the representation, the physics, a loss or the schedule, and the rest keeps working: the command line, the benchmark protocol, the diagnostics and the figures.

The nefi recipe: coordinates, annealed Fourier encoding, field and heads (the representation, i.e. the prior), a differentiable operator (the physics, a hard constraint), losses against the measurement and a multiscale solver (the fit), and diagnostics (the trust). The gradient flows back to the field parameters for this one measurement, without labels. The nefi recipe (dark theme)

import nefi
from nefi.instances.toy1d import make_problem

problem, gt, meas = make_problem(n=128, seed=0)   # 1-D deblurring: runs in seconds on a CPU
result = nefi.invert(problem)                     # neural field + two-stage annealed curriculum
print(nefi.metrics.psnr(result.fields["x"], gt["x"]))
nefi run toy1d --plot                   # generate → invert → evaluate → runs/toy1d-<hash>/
nefi bench toy1d --methods neural,grid --n 4 --seeds 0,1
nefi diagnose toy1d                     # sensitivity, iter-0 gradient, filter rows, spectrum
import nefi

def forward(x):                         # any differentiable PyTorch function of the unknown
    return my_instrument(x)

problem = nefi.from_forward(forward, y, shape=(128, 128),
                            prior="nonnegative + piecewise_constant")
result = nefi.invert(problem)
print(nefi.quick_report(result, problem))   # did the fit reach the noise floor?

What's inside

Everything a per-measurement inversion needs

  • Physics as a hard constraint


    Every candidate field passes through a differentiable forward operator: FFT convolutions, PDE solvers with exact adjoints, wave propagation, scattering, optics. The physics is never a soft residual — except in the PINN baseline, on purpose.

    Anatomy of a problem

  • Representations as geometric priors


    Neural fields, grids, hash grids, level sets, layered media, star shapes, warps. A parameterized update is the raw gradient filtered by \(G_\theta = J_\theta J_\theta^\top\), so choosing the representation is choosing the prior — and the measurement can choose.

    Geometric representations

  • Bring your own problem in 20 lines


    nefi.from_forward wraps any differentiable PyTorch function. Representation, initialization, noise level, loss weights, learning rate and curriculum are chosen automatically, logged, and overridable by a keyword.

    Bring your own problem

  • A physics zoo, 1-D to 3-D


    Registered problems so far: NV magnetometry, thermography, CT, microscopy, EIT, Darcy flow, full-waveform inversion, diffraction tomography, holography, reaction–diffusion, diffuse optics and photoacoustics, each runnable with nefi run <name> --smoke.

    Instance catalogue

  • Diagnostics that explain


    Sensitivity maps, iter-0 gradients and center bias, filter-kernel rows \(G_\theta e_i\), singular-value spectra, energy barriers and the data-fit paradox: the papers' explanations, as functions that work on any problem.

    Diagnostics

  • Benchmarks with an inverse-crime guard


    Paired samples × seeds, Student-t 95 % confidence intervals, runtime and memory columns, cumulative ablations and sweeps. Data come from an independent, finer simulator unless you explicitly — and visibly — opt out.

    Benchmarking

  • Auto-tuning


    Detects gauges the data cannot see, budgets that stop short of the noise floor and mis-weighted priors; fixes what the data can fix, and reports what only a better acquisition could.

    Auto-tuning

  • Edge refinement


    A short second stage turns soft reconstructions into crisp interfaces under the same physics and data — and refuses, with the reason, when the data fit would degrade.

    Edge refinement

  • Interactive 3-D


    Drag-to-rotate isosurfaces, voxels and slices of ground truth against reconstruction, with IoU and Dice computed in the browser — one self-contained HTML file, no libraries, no CDN.

    3-D showcase

  • Fast where it matters


    Batched multi-measurement solving under vmap, whole-step torch.compile, a 7-kernel heat stencil with Chebyshev sweeps, and discrete adjoints at trajectory-sized memory.

    Performance

  • A command line for everything


    nefi run · bench · diagnose · autotune · ablate · sweep on any registered instance or YAML config, with sharded benchmark campaigns and SLURM templates for GPU clusters.

    Command line

  • Reproducible by design


    Every paper number is a config field; every run writes its effective config, metrics and history; seeds are deterministic. Paper-scale configs and a server runbook are included.

    Reproducing the papers

Gallery

A growing catalogue of systems

Reconstructions from single simulated measurements. The data always come from an independent, finer simulator than the one being inverted. Open a tile for the physics, the measurement and the numbers.

Open the gallery 3-D showcase

Interactive

Rotate a reconstruction

Photoacoustic tomography of a vessel network from a planar sensor array: ground truth, the smooth neural-field reconstruction and its edge-refined version, on one camera. Drag to rotate, scroll to zoom; levels, IoU and Dice are recomputed in your browser.

photoacoustic3d · 20×20×14 voxels · smoke preset, CPU run Open full page ↗

Who it is for

Built for people with a forward model and no training set

Imaging scientists

You have an instrument such as a quantum sensor, a thermal camera, a CT scanner, a microscope or a sensor array, and a model of how it measures. Write the model in PyTorch, declare what you know about the unknown, and get a reconstruction together with a report on how well it explains your data. Bring your own problem →

Method developers

Compare representations, priors, schedules and optimizers on every registered problem under one fair protocol: shared objectives, paired seeds, confidence intervals, an inverse-crime guard, and diagnostics that explain why a method wins. Benchmarking →

Academic labs

Adopt one inversion toolkit for every instrument in your group: each setup becomes a registered problem with its own configuration, results stay reproducible from run to run, and the benchmark protocol yields publication-ready comparisons. New members start with eight tutorials, from a five-second toy to paper-scale runs on GPU servers, and a line-by-line map from the papers' equations to the code. Start the tutorials →

Research

The research behind nefi

nefi grew out of research on neural-field inversion at the CAB Lab, Princeton University: a series of papers that apply one idea to very different instruments. Two are published so far, NeTMY and NeFTY, and both ship as instances with paper-scale configurations. The recipe is written so that the papers that follow slot in the same way.

NeTMY — Neural Fields for NV-Center Inverse Sensing

Zhao, Zhong, Hu, de Leon, Allen-Blanchette · arXiv:2605.13988

Sparse spin sources and their Larmor field from the magnetic-noise spectra of a widefield NV-center array, through a tensor power-summed dipolar operator; explains the center collapse of free-density solvers with the filtering view of a parameterized update. Instance: nv_relaxometry →

BibTeX
@article{zhao2026netmy,
  title   = {Neural Fields for {NV}-Center Inverse Sensing},
  author  = {Zhao, Zhixuan and Zhong, Tao and Hu, Yixun and de Leon, Nathalie P. and
             Allen-Blanchette, Christine},
  journal = {arXiv preprint arXiv:2605.13988},
  year    = {2026}
}

NeFTY — Neural Field Thermal Tomography

Zhong, Hu, Zheng, Sood, Allen-Blanchette · arXiv:2603.11045

Volumetric thermal diffusivity from pulsed-thermography surface frames, through a differentiable implicit-Euler heat solver with harmonic-mean interfaces and a discrete adjoint; explains why soft-constrained PINNs fit the data but not the interior. Instance: thermal_tomography →

BibTeX
@article{zhong2026nefty,
  title   = {Neural Field Thermal Tomography: A Differentiable Physics Framework for
             Non-Destructive Evaluation},
  author  = {Zhong, Tao and Hu, Yixun and Zheng, Dongzhe and Sood, Aditya and
             Allen-Blanchette, Christine},
  journal = {arXiv preprint arXiv:2603.11045},
  year    = {2026}
}

Install

Up and running in a minute

pip install nefi                  # torch, numpy, scipy, pyyaml, tqdm
pip install "nefi[viz]"           # + matplotlib for figures (--plot)
nefi list instances               # the registered problems
nefi run toy1d --smoke            # a few seconds on a CPU
pip install git+https://github.com/CAB-Lab-Princeton/NEFI.git
git clone https://github.com/CAB-Lab-Princeton/NEFI.git && cd NEFI
pip install -e ".[dev]"            # + pytest, ruff, matplotlib, typer, rich, scikit-image
make test                          # fast CPU suite
git clone https://github.com/CAB-Lab-Princeton/NEFI.git && cd NEFI
conda env create -f environment.yml && conda activate nefi   # python 3.11, torch, nefi[dev]
nefi run configs/nv_relaxometry_paper.yaml --device cuda      # NeTMY at paper scale

Python ≥ 3.10 and PyTorch ≥ 2.1; CPU is enough for every tutorial and smoke run, CUDA for paper scale. Next: install notes and a first run · the quickstart tutorial · how to cite.