Skip to content

Dual energy plugin (Python): tigre.plugins.dual_energy - #991

Merged
AnderBiguri merged 1 commit into
plugins/de-matlabfrom
plugins/de-python
Nov 28, 2026
Merged

AnderBiguri merged 1 commit into
plugins/de-matlabfrom
plugins/de-python

Conversation

@AnderBiguri

Copy link
Copy Markdown
Member

Part 2 of 2 for #522, stacked on #990 (MATLAB move and fixes). Closes #522.

What changes

  • tigre.plugins.dual_energy: DeDecompose and MakeVMproj, the same functions, options, defaults, warnings and errors as MATLAB after Dual energy plugin (MATLAB): move to Plugins/DualEnergy and fix bugs #990. Projections are (angle, v, u). Angle matching is the fixed one (wrapped angles, tolerance in radians, default half the low-kV step). Spline: scipy.interpolate.CubicSpline (not-a-knot, as MATLAB spline). Pure Python: always installed, nothing to build.
  • Data: the single copy stays in Common/data (MATLAB reads it there). setup.py copies the two JSON files into tigre/plugins/dual_energy/data/ (git-ignored, in package-data), and MANIFEST.in puts Common/data/*.json in the sdist. In an unbuilt checkout the code falls back to Common/data.
  • Demo Python/demos/d23_DualEnergy.py (mirrors the MATLAB one; needs your own Varian scans, so it is in NOT_RUN for the website).
  • Docs: new user-guide page dual-energy.md (method, Python/MATLAB example, angle matching, calibration and how to add one), row in the plugins table, both API reference pages, demos catalogue.
  • TIGRE-DE entry added to the Python TIGRE.bib; the MATLAB entry was missing its year and closing brace.
  • Changelog.

Testing

  • New Python/tests/test_dual_energy_plugin.py, CPU-only, same numbers as test_DualEnergy_plugin.m: passes in the sandbox against the source tree. This PR's CI (tests.yml) installs TIGRE and runs it against the installed package, which also checks the JSON files are packaged.
  • Extra manual checks: errors for unknown kV pair, scanner, material and interpolation; linear interpolation across 0/2pi; float32 in, float32 out; MakeVMproj at 60 keV = 0.075t1 + 0.0228*t2.
  • Sphinx build: no warnings.
  • Not run: the demo on real dual-energy data (none available).

Written by an AI agent (Claude), reviewed by Ander.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L6n1VHyq4uNorM3CAiBUPo

…keVMproj)

Same functions and options as MATLAB/Plugins/DualEnergy, with the same
angle matching (wrapped angles, tolerance in radians) and the same errors.
Projections are (angle, v, u). The calibration and NIST tables stay in
Common/data (one copy); setup.py copies them into the package, and the
sdist includes them. Falls back to Common/data in an unbuilt checkout.

Also: demo d23_DualEnergy.py, one CPU test with the same numbers as the
MATLAB test, user-guide page, API reference, plugins table, changelog,
and the TIGRE-DE entry in the Python TIGRE.bib (closing brace and year
added to the MATLAB one).

Closes #522

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6n1VHyq4uNorM3CAiBUPo
@AnderBiguri
AnderBiguri added this pull request to stack #992 November 28, 2026 23:23
@AnderBiguri
AnderBiguri marked this pull request as ready for review November 28, 2026 23:23
@AnderBiguri
AnderBiguri merged commit 1b3fdeb into master Nov 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python version of Dual Energy codes

2 participants