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.2.1.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.2.1-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ngimager-1.2.1.tar.gz
Algorithm Hash digest
SHA256 c858c07bbc45e3f2c9475175509521589dbd6c332bfe85e240bc7988fcbcb47c
MD5 45652d085d575f18b787b268a8cc32f1
BLAKE2b-256 7cf14ea64ead2b0a54fbda6cf2b9bd3e0da74a70b6ab135b4e54311fe0de0933

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ngimager-1.2.1-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.12.5

File hashes

Hashes for ngimager-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80b2eebc3b30086b32a1bcabe21cbb83eb19556ae5cc5b314f3aed3f28710b48
MD5 2ddbb32c6b73bc89e16c62a96e14ad88
BLAKE2b-256 3ebe84196a0d06c0800f4f09b523713f82aa4bf7a004714dd92c23ac10d9a133

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