Skip to main content

Event-cone imaging (neutron & gamma ray) with fastmode and list-mode pipelines.

Project description

ng-imager

CI Docs GitHub Pages PyPI

ng-imager is a modular Python toolkit for imaging neutrons and gamma rays in the NOVO detector system.

It turns detector-level hit data into images via a clean, restartable pipeline:

hits → events → cones → images

and is designed to replace a monolithic legacy script with:

  • Explicit separation of physics, geometry, imaging, configuration, and I/O
  • Flexible energy strategies (ELUT, ToF, fixed–energy, direct Edep)
  • Unified neutron and gamma imaging, including proton vs carbon recoil handling
  • Structured hit / event / cone filters with detailed counters
  • Self-describing HDF5 output suitable for long-term analysis and archiving

Repository vs Python Package Name

  • Repository name: ng-imager
  • Python package (import name): ngimager
  • PyPI package: ngimager

After installing from source, you import the package as:

import ngimager

and use the CLI entry points:

  • ng-run – main imaging pipeline
  • ng-viz – visualization / re-rendering of summed images
  • ng-inspect – inspect a single cone and its pixel footprint (optional tool)

Install

From PyPI (recommended)

pip install ngimager

Check that the package and CLI are available:

python -c "import ngimager; print(ngimager.__file__)"
ng-run --help
ng-viz --help

From Source (development install)

git clone https://github.com/Lindt8/ng-imager.git
cd ng-imager

python -m venv .venv
source .venv/bin/activate      # on Windows: .venv\Scripts\activate

pip install -e ".[dev]"

This installs ngimager in editable mode along with development dependencies (tests, docs, etc.). For a minimal runtime install, you can also use:

pip install -e .

First Run: Example PHITS Config

The repository includes a simple PHITS usrdef example:

  • Config: examples/configs/phits_usrdef_simple.toml
  • Input: examples/imaging_datasets/PHITS_simple_ng_source/usrdef.out

Run the unified pipeline with:

ng-run examples/configs/phits_usrdef_simple.toml

or equivalently:

python -m ngimager.pipelines.core examples/configs/phits_usrdef_simple.toml

This will:

  1. Read PHITS usrdef events via the adapter.

  2. Construct hits and apply hit-level filters.

  3. Shape and type events (neutron 2-hit, gamma 3-hit).

  4. Apply event- and cone-level filters (ToF windows, light thresholds, Δθ, incident energy).

  5. Build neutron and gamma cones (with proton vs carbon recoil handling for neutrons).

  6. Reconstruct a simple back-projection (SBP) image on the configured plane.

  7. Write an HDF5 file containing:

    • /images/summed/n, /images/summed/g, and /images/summed/all (where available)
    • /cones/... with per-cone geometry, species, recoil code, and incident energy
    • /lm/... with per-event and per-hit physics and optional list-mode cone pixel indices
    • /meta/counters/... summarizing all filters and pipeline stages
    • A snapshot of the TOML config used for the run

You can then use ng-viz to re-render images from that HDF5 file:

ng-viz summed results/example.h5

Documentation

Full documentation is hosted at:

Key sections:

  • Quickstart – run the example config and inspect the results.
  • Configuration – complete TOML reference (docs/config.md).
  • HDF5 Layout – how to interpret the output file (docs/hdf5.md).
  • Architecture – design overview and long-term roadmap (docs/architecture.md).
  • API Reference – auto-generated documentation from Python docstrings (docs/api/index.md).

Status

  • Neutron imaging: functional and validated against the legacy NOVO imaging code.
  • Gamma imaging: functional and validated on legacy-formatted model data.
  • Proton vs carbon recoil hypotheses: implemented, selected via priors, and stored in HDF5.
  • Hit / event / cone filters: implemented with counters and HDF5 export.
  • Fast and list modes: wired through configuration and I/O.

The codebase is under active development, but the core architecture and HDF5 layout are intended to be stable enough for experimental usage and future extension.


Contributing

Contributions are very welcome. Useful areas include:

  • New I/O adapters (additional simulation formats, experimental data).
  • Alternative imaging algorithms / uncertainty models.
  • Improved tests, examples, and documentation.

If you’d like to help:

  1. File an issue describing your idea or bug.
  2. Open a pull request from a feature branch.
  3. Use the existing example config and tests to validate your changes.

Repository:

https://github.com/Lindt8/ng-imager

The aim is to keep ng-imager physically transparent, modular, and pleasant to work with for both simulation and experimental campaigns.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ngimager-1.1.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ngimager-1.1.0-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file ngimager-1.1.0.tar.gz.

File metadata

  • Download URL: ngimager-1.1.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for ngimager-1.1.0.tar.gz
Algorithm Hash digest
SHA256 50d2c5e20cd27ecbcf4c648c400d2b64d728050f8301cf2350ff34c552b14df7
MD5 679ec76d3c44b148ea45d224bfffa224
BLAKE2b-256 949e6da614abd2259b6c7d15d0600029a609a84d73d21c1c5d4e3d06f59a26e8

See more details on using hashes here.

File details

Details for the file ngimager-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ngimager-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for ngimager-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eff583524df812b0bb93a320388dbe7b4e39cf23b45c5316bef2600f94dea6d8
MD5 8fc78bca3613a90b2c84a679617b7203
BLAKE2b-256 c67f5c4d623a83d42a43c8b85ad17d47b216d29854ba43dbb549d0febe9ff8d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page