Skip to content

fix(python): set realistic default photon count and clamp in CTnoise (#780) - #789

Closed
Cid-oe wants to merge 1 commit into
CERN:masterfrom
Cid-oe:fix/780-ctnoise-default-poisson
Closed

Cid-oe wants to merge 1 commit into
CERN:masterfrom
Cid-oe:fix/780-ctnoise-default-poisson

Conversation

@Cid-oe

@Cid-oe Cid-oe commented Sep 24, 2026

Copy link
Copy Markdown

Closes #780

Description

Brings the Python CTnoise.add defaults into alignment with the MATLAB addCTnoise.m reference, preventing the function from returning NaN when simulating noise.

  • Replaced the nextpow2 expression (which gave an exponent instead of a photon count) with a default of 60,000 photons (or max(proj)/5 for projections exceeding that).
  • Added a projections <= 0 clamp to 1e-6 before taking the logarithm to ensure negative values produced by Gaussian noise do not result in NaN outputs.

…ERN#780)

Replaces the erroneous `nextpow2` Poisson exponent with a photon count of 60000
(or `max(proj)/5` for very bright projections), matching the MATLAB `addCTnoise.m`
reference.

Also adds a clamp to 1e-6 before the `log` step to prevent `NaN` outputs when
simulated noise pushes the projection to zero or below.

Closes CERN#780
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.

CTnoise.add with default Poisson returns NaN and noise as large as the signal

2 participants