numpyradiomics.gldm#

numpyradiomics.gldm(image, mask, binWidth=25, alpha=0, levels=None)[source]#

Compute 15 Pyradiomics-style GLDM (Gray Level Dependence Matrix) features.

The GLDM quantifies gray level dependencies in an image. A gray level dependency is defined as the number of connected voxels within distance $delta=1$ that are dependent on the center voxel. A neighboring voxel is dependent if the absolute difference in gray level is $le lpha$.

Parameters:
  • image (np.ndarray) – 3D image array containing voxel intensities.

  • mask (np.ndarray) – 3D mask array (same shape as image), where non-zero values indicate the ROI.

  • binWidth (float, optional) – Width of bins for discretization. Default is 25.

  • alpha (int, optional) – Cutoff for dependence. Neighbors are “dependent” if |val - center| <= alpha. Default is 0 (exact match).

  • levels (int, optional) – Number of levels for discretization. If None, calculated from binWidth.

Returns:

Dictionary containing the 15 GLDM features:
  • SmallDependenceEmphasis: Distribution of small dependencies.

  • LargeDependenceEmphasis: Distribution of large dependencies.

  • GrayLevelNonUniformity: Variability of gray-level values in the image.

  • DependenceNonUniformity: Variability of dependence counts.

  • DependenceNonUniformityNormalized: Normalized version of DN.

  • GrayLevelNonUniformityNormalized: Normalized version of GLN.

  • LowGrayLevelEmphasis: Distribution of low gray-level values.

  • HighGrayLevelEmphasis: Distribution of high gray-level values.

  • SmallDependenceLowGrayLevelEmphasis: Joint distribution of small dependence and low gray levels.

  • SmallDependenceHighGrayLevelEmphasis: Joint distribution of small dependence and high gray levels.

  • LargeDependenceLowGrayLevelEmphasis: Joint distribution of large dependence and low gray levels.

  • LargeDependenceHighGrayLevelEmphasis: Joint distribution of large dependence and high gray levels.

  • GrayLevelVariance: Variance of gray levels.

  • DependenceVariance: Variance of dependence counts.

  • DependenceEntropy: Randomness/variability in dependence counts.

Return type:

dict

Example

>>> import numpyradiomics as npr
>>> # Generate a noisy ellipsoid
>>> img, mask = npr.dro.noisy_ellipsoid(radii_mm=(12, 12, 12), intensity_range=(0, 100))
>>>
>>> # Compute GLDM features (alpha=0 implies exact match dependency)
>>> feats = npr.gldm(img, mask, binWidth=10, alpha=0)
>>>
>>> print(f"DependenceEntropy: {feats['DependenceEntropy']:.4f}")
DependenceEntropy: 2.1543