Skip to content

fix(glszm): grow 2D zones through all eight neighbours - #553

Open
darkclad wants to merge 1 commit into
PolusAI:mainfrom
darkclad:main-glszm-zone-connectivity
Open

darkclad wants to merge 1 commit into
PolusAI:mainfrom
darkclad:main-glszm-zone-connectivity

Conversation

@darkclad

Copy link
Copy Markdown

Summary

A GLSZM zone is 8-connected, as IBSI, PyRadiomics and MIRP define it. The 2D zone walk in GLSZMFeature::calculate stepped only east, south-east, south and south-west from a pixel already in the zone. A zone that turned back west, north-west, north or north-east was split into several smaller zones, and every 2D GLSZM feature changed.

Nazanin Donyapour found this while comparing Nyxus with PyRadiomics on her datasets.

On the 5 x 5 example of the PyRadiomics GLSZM documentation, Nyxus found 13 zones where PyRadiomics finds 11:

zones GLSZM_ZP GLSZM_SAE
PyRadiomics 11 0.44 0.5912
Nyxus before 13 0.52 0.6596
Nyxus after 11 0.44 0.5912

The walk now steps to all eight neighbours.

  • Out-of-core: it calls the same calculate().
  • GPU: it sums features from the zone list the CPU builds.
  • 3D GLSZM: already 26-connected, so not affected.

Why the existing oracle tests passed

The 2D GLSZM MIRP and IBSI tests run on the IBSI digital phantom. None of its zones turns back up or to the left, so the old walk and 8-connectivity find the same zones there. The docs listed the split as a known issue on the GLSZM page.

Tests

tests/test_2d_glszm_pyradiomics.h checks all 16 features against PyRadiomics 3.0.1 (binWidth=1, force2D) on four fixtures, in IBSI mode. Fifteen features are checked to an absolute 1e-9. GLSZM_ZE is checked to a relative 4e-3 because of the fast_log10 approximation.

fixture zones (8-connected) zones under the old walk role
2 x 3 image from the GLSZM docs page 2 3 needs a west step
PyRadiomics documentation 5 x 5 11 13 real-world shape
6 x 6 hook 5 6 needs a north-east step, then north
3 x 7 image with a gap and a masked-out column 8 8 negative: zones must not merge
  • The three positive fixtures fail when the old walk is restored.
  • The negative fixture fails when the walk is given a two-pixel reach.
  • tests/vetting/oracles/gen_glszm_pyradiomics.py regenerates and re-verifies every pin. It also fails if a positive fixture stops discriminating the old walk.

Results:

  • Full gtest suite: 1340 passed.
  • pytest tests/python/: 346 passed.
  • ASan+UBSan on Linux: 1279 gtest cases and tests/python (327 passed), 0 sanitizer diagnostics.
  • The existing 2D GLSZM MIRP, IBSI and regression goldens are unchanged.

Docs

  • GLSZM page:
    • The connectivity section describes 8-connectivity.
    • The split-zone known issue is removed.
    • The validation section describes the PyRadiomics fixtures.
    • The background-as-grey-level-1 example quotes recomputed values: one of its zones, the 4s along the bottom, was split as well (12 zones before, 11 now).
  • Other pages: conventions, validation, the 3D GLSZM page and the feature list description are updated to match.

A GLSZM zone is 8-connected, as IBSI, PyRadiomics and MIRP define it. The
2D zone walk stepped only east, south-east, south and south-west from a pixel
already in the zone, so a zone that turned back west or north was split into
several smaller zones and every 2D GLSZM feature moved. On the 5 x 5 example
of the PyRadiomics GLSZM documentation it found 13 zones where PyRadiomics
finds 11. The walk now steps to all eight neighbours. The out-of-core path
calls the same calculate(), and 3D GLSZM was already 26-connected.

test_2d_glszm_pyradiomics.h checks all sixteen features against PyRadiomics
3.0.1 on four fixtures: three whose zones turn back west, north or north-east
(they fail on the old walk) and a negative one whose same-level pixels touch
only across a gap or through a pixel outside the mask, which must stay
separate zones. gen_glszm_pyradiomics.py regenerates and re-verifies the pins.

Docs: the GLSZM page describes 8-connectivity, drops the split-zone known
issue, and its background-as-grey-level-1 example quotes the recomputed values
(one of its zones was split as well). Conventions, validation, the 3D GLSZM
page and the feature list follow.

@vjaganat90 vjaganat90 left a comment

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.

LGTM. I built the head and its base and compared 2D GLSZM in IBSI mode with PyRadiomics 3.0.1 (binWidth 1, force2D) on 8 random L-shaped ROIs of 3 to 8 levels: the head matches all 128 values (ZE within 4e-3), the base none. 3D GLSZM gives exactly the base values.

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