numpyradiomics.glszm#
- numpyradiomics.glszm(image, mask, binWidth=25, levels=None, connectivity=None)[source]#
Compute 16 Pyradiomics-style GLSZM (Gray Level Size Zone Matrix) features.
GLSZM quantifies gray level zones in an image. A gray level zone is defined as a number of connected voxels that share the same gray level intensity.
- 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.
levels (int, optional) – Number of levels for discretization. If None, calculated from binWidth.
connectivity (int, optional) – Connectivity kernel (e.g., 6, 18, 26 for 3D). Default is None (26-connected in 3D, 8-connected in 2D).
- Returns:
- Dictionary containing the 16 GLSZM features:
SmallAreaEmphasis: Measures the distribution of small zones.
LargeAreaEmphasis: Measures the distribution of large zone sizes.
GrayLevelNonUniformity: Measures the variability of gray-level values in the image.
GrayLevelNonUniformityNormalized: Normalized version of GLN.
ZoneSizeNonUniformity: Measures the variability of zone size values.
ZoneSizeNonUniformityNormalized: Normalized version of ZSN.
ZonePercentage: Measures the coarseness of the texture.
LowGrayLevelZoneEmphasis: Measures the distribution of lower gray-level values.
HighGrayLevelZoneEmphasis: Measures the distribution of higher gray-level values.
SmallAreaLowGrayLevelEmphasis: Emphasis on small zones with low gray levels.
SmallAreaHighGrayLevelEmphasis: Emphasis on small zones with high gray levels.
LargeAreaLowGrayLevelEmphasis: Emphasis on large zones with low gray levels.
LargeAreaHighGrayLevelEmphasis: Emphasis on large zones with high gray levels.
GrayLevelVariance: Variance of gray level intensities in the zones.
ZoneSizeVariance: Variance of zone size volumes.
ZoneEntropy: Uncertainty/Randomness in the distribution of zone sizes and gray levels.
- Return type:
Example
>>> import numpyradiomics as npr >>> # Generate a noisy ellipsoid >>> img, mask = npr.dro.noisy_ellipsoid(radii_mm=(15, 15, 15), intensity_range=(0, 100)) >>> >>> # Compute GLSZM features >>> feats = npr.glszm(img, mask, binWidth=10) >>> >>> print(f"ZonePercentage: {feats['ZonePercentage']:.4f}") ZonePercentage: 0.8912