numpyradiomics.ngtdm#

numpyradiomics.ngtdm(image, mask, binWidth=25, distance=1)[source]#

Compute 5 Pyradiomics-style NGTDM (Neighborhood Gray Tone Difference Matrix) features.

The NGTDM quantifies the difference between a gray value and the average gray value of its neighbors within a defined distance.

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.

  • distance (int, optional) – The distance (radius) of the neighborhood kernel. Default is 1.

Returns:

Dictionary containing the 5 NGTDM features:
  • Coarseness: Measures the average difference between the center voxel and its neighborhood.

    Higher values indicate a lower spatial change rate and locally more uniform texture.

  • Contrast: Measures the spatial intensity change rate.

    Higher values indicate large changes in intensity between neighboring areas.

  • Busyness: Measures the rapid changes of intensity between pixels and their neighborhood.

    High values indicate a “busy” image (rapid changes).

  • Complexity: Measures the information content of the image.

    High values indicate non-uniform and rapid changes in gray levels.

  • Strength: Measures the distinctness of the primitives in the image.

    High values indicate easily definable and visible structures.

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 NGTDM features
>>> feats = npr.ngtdm(img, mask, binWidth=10, distance=1)
>>>
>>> print(f"Coarseness: {feats['Coarseness']:.6f}")
Coarseness: 0.001234