Skip to content

fix(gldm): exclude background from the dependence matrix#354

Open
darkclad wants to merge 4 commits into
PolusAI:mainfrom
darkclad:main-gldm-background
Open

fix(gldm): exclude background from the dependence matrix#354
darkclad wants to merge 4 commits into
PolusAI:mainfrom
darkclad:main-gldm-background

Conversation

@darkclad

@darkclad darkclad commented Jul 1, 2026

Copy link
Copy Markdown

The MATLAB grey-binning path maps off-ROI background (0) to level 1, so the GLDM zone loop's pi == 0 guard (which tests the BINNED value) never rejected background pixels inside the bounding box. They were counted both as zones and as dependent neighbours, inflating Nz (154 -> 234 on the canonical ROI) and every count/dependence feature.

Skip background by the ORIGINAL intensity (imR / raw cloud value == 0) and require a neighbour to be an ROI pixel before counting it as a dependency, in both the trivial and out-of-core paths. Mirrors the GLCM background fix.

Adds tests/python/test_feature_bugs.py::test_gldm_background_not_counted, checking LDE/GLN/DN against the PyRadiomics reference on the canonical ROI.

The MATLAB grey-binning path maps off-ROI background (0) to level 1, so the
GLDM zone loop's `pi == 0` guard (which tests the BINNED value) never rejected
background pixels inside the bounding box. They were counted both as zones and
as dependent neighbours, inflating Nz (154 -> 234 on the canonical ROI) and
every count/dependence feature.

Skip background by the ORIGINAL intensity (imR / raw cloud value == 0) and
require a neighbour to be an ROI pixel before counting it as a dependency, in
both the trivial and out-of-core paths. Mirrors the GLCM background fix.

Adds tests/python/test_feature_bugs.py::test_gldm_background_not_counted,
checking LDE/GLN/DN against the PyRadiomics reference on the canonical ROI.
Comment thread tests/python/test_feature_bugs.py Outdated
Comment on lines +1 to +5
"""Regression / bug-exposure tests for 2D feature defects found during oracle validation
(2026-06). These exercise the PRODUCTION featurize() path on ROIs *with background* and at
the DEFAULT settings - the conditions the C++ unit tests miss.

This module covers the GLDM background-pollution defect (bug #14b).

@sameeul sameeul Jul 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment and the file name need to be updated to reflect the test. Saying it test_feature_bugs.py will become misleading in the long run. Also, do we have an equivalent GTest?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Demian Vladi added 3 commits July 1, 2026 11:49
…guard

Address PR PolusAI#354 review: the generic test_feature_bugs.py name/comment would
become misleading, and there was no C++ equivalent.

- Rename tests/python/test_feature_bugs.py -> test_gldm_bugs.py and scope the
  docstring to the GLDM background-pollution defect (bug #14b).
- Add tests/test_gldm_bugs.h::test_gldm_bug_background_excluded, a GTest on a
  concave 3x3-ring ROI whose bounding box contains a background hole - the
  condition the fully-masked test_gldm.h phantoms cannot reproduce. Asserts the
  exact hand-computed GLDM matrix (Nz=8, GLN=8, DN=4, DNN=0.5, LDE=17); the
  pre-fix background pollution gave GLN 7.22 / DN 3.67 / LDE 15.22.
- Register the new test in test_all.cc.
Drop the _bugs suffix from the GLDM regression guards, renaming
test_gldm_bugs.{h,py} -> test_gldm_oracle.{h,py} to reflect their
origin in the PyRadiomics oracle-validation effort. Updates the
test_all.cc include and the cross-reference comments in both files.
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.

2 participants