You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Confusion matrix and F-beta lose false positives and negatives above 2**24 voxels #9270
get_confusion_matrix and get_f_beta_score cast tp, tn and p to float32 before they compute fn = p - tp and fp = n - tn. float32 holds integers exactly only up to 2**24 (16,777,216). In a sample with more voxels per channel, n and tn round to the float32 step, so fp and fn round too.
This is a follow-up to #7186. #7187 moved the sums to integers, but the counts are still cast to float32 before the subtractions.
To Reproduce
Synthetic masks, one CT-sized sample (512 x 512 x 300 = 78,643,200 voxels):
fp is 1 and precision is 50/51 = 0.9804. In this volume fp can only be 0 or a multiple of 8 (the float32 step between 226 and 227). With 0 to 6 real false positives, dev reports 0, 8, 8, 8, 8, 8, 8.
This affects ConfusionMatrixMetric (all metric names) and FBetaScore for samples above 2**24 voxels, for example whole-body CT and large 2D pathology tiles (4096 x 4098 is already above the limit).
Environment
MONAI dev at 846ae34, torch 2.15.0, Python 3.11.6, macOS 15.6.1 arm64 (CPU).
Additional context
I have a fix with tests and will open a PR that links this issue.
AI disclosure: this issue was found and written with Claude Code (an AI coding tool).
Activity