代码(helloFeatureClass.py):
import numpy
import SimpleITK as sitk
import six
from radiomics import firstorder, getTestCase, glcm, glrlm, glszm, imageoperations, shape
# testBinWidth = 25 this is the default bin size
# testResampledPixelSpacing = [3,3,3] no resampling for now.
# Get some test data
# Download the test case to temporary files and return it's location. If already downloaded, it is not downloaded again,
# but it's location is still returned.
imageName, maskName = 'brain1_image.nrrd','brain1_label.nrrd'#getTestCase('brain1')
if imageName is None or maskName is None: # Something went wrong, in this case PyRadiomics will also log an error
print('Error getting testcase!')
exit()
image = sitk.ReadImage(imageName)
mask = sitk.ReadImage(maskName)
applyLog = False
applyWavelet = False
# Setting for the feature calculation.
# Currently, resampling is disabled.
# Can be enabled by setting 'resampledPixelSpacing' to a list of 3 floats (new voxel size in mm for x, y and z)
settings = {'binWidth': 25,
'interpolator': sitk.sitkBSpline,
'resampledPixelSpacing': None}
#
# If enabled, resample image (resampled image is automatically cropped.
#
interpolator = settings.get('interpolator')
resampledPixelSpacing = settings.get('resampledPixelSpacing')
if interpolator is not None and resampledPixelSpacing is not None:
image, mask = imageoperations.resampleImage(image, mask, **settings)
bb, correctedMask = imageoperations.checkMask(image, mask)
if correctedMask is not None:
mask = correctedMask
image, mask = imageoperations.cropToTumorMask(image, mask, bb)
#
# Show the first order feature calculations
#
firstOrderFeatures = firstorder.RadiomicsFirstOrder(image, mask, **settings)
firstOrderFeatures.enableFeatureByName('Mean', True)
# firstOrderFeatures.enableAllFeatures()
print('Will calculate the following first order features: ')
for f in firstOrderFeatures.enabledFeatures.keys():
print(' ', f)
print(getattr(firstOrderFeatures, 'get%sFeatureValue' % f).__doc__)
print('Calculating first order features...')
results = firstOrderFeatures.execute()
print('done')
print('Calculated first order features: ')
for (key, val) in six.iteritems(results):
print(' ', key, ':', val)
#
# Show Shape features
#
shapeFeatures = shape.RadiomicsShape(image, mask, **settings)
shapeFeatures.enableAllFeatures()
print('Will calculate the following Shape features: ')
for f in shapeFeatures.enabledFeatures.keys():
print(' ', f)
print(getattr(shapeFeatures, 'get%sFeatureValue' % f).__doc__)
print('Calculating Shape features...')
results = shapeFeatures.execute()
print('done')
print('Calculated Shape features: ')
for (key, val) in six.iteritems(results):
print(' ', key, ':', val)
#
# Show GLCM features
#
glcmFeatures = glcm.RadiomicsGLCM(image, mask, **settings)
glcmFeatures.enableAllFeatures()
print('Will calculate the following GLCM features: ')
for f in glcmFeatures.enabledFeatures.keys():
print(' ', f)
print(getattr(glcmFeatures, 'get%sFeatureValue' % f).__doc__)
print('Calculating GLCM features...')
results = glcmFeatures.execute()
print('done')
print('Calculated GLCM features: ')
for (key, val) in six.iteritems(results):
print(' ', key, ':', val)
#
# Show GLRLM features
#
glrlmFeatures = glrlm.RadiomicsGLRLM(image, mask, **settings)
glrlmFeatures.enableAllFeatures()
print('Will calculate the following GLRLM features: ')
for f in glrlmFeatures.enabledFeatures.keys():
print(' ', f)
print(getattr(glrlmFeatures, 'get%sFeatureValue' % f).__doc__)
print('Calculating GLRLM features...')
results = glrlmFeatures.execute()
print('done')
print('Calculated GLRLM features: ')
for (key, val) in six.iteritems(results):
print(' ', key, ':', val)
#
# Show GLSZM features
#
glszmFeatures = glszm.RadiomicsGLSZM(image, mask, **settings)
glszmFeatures.enableAllFeatures()
print('Will calculate the following GLSZM features: ')
for f in glszmFeatures.enabledFeatures.keys():
print(' ', f)
print(getattr(glszmFeatures, 'get%sFeatureValue' % f).__doc__)
print('Calculating GLSZM features...')
results = glszmFeatures.execute()
print('done')
print('Calculated GLSZM features: ')
for (key, val) in six.iteritems(results):
print(' ', key, ':', val)
#
# Show FirstOrder features, calculated on a LoG filtered image
#
if applyLog:
sigmaValues = numpy.arange(5., 0., -.5)[::1]
for logImage, imageTypeName, inputKwargs in imageoperations.getLoGImage(image, mask, sigma=sigmaValues):
logFirstorderFeatures = firstorder.RadiomicsFirstOrder(logImage, mask, **inputKwargs)
logFirstorderFeatures.enableAllFeatures()
results = logFirstorderFeatures.execute()
for (key, val) in six.iteritems(results):
laplacianFeatureName = '%s_%s' % (imageTypeName, key)
print(' ', laplacianFeatureName, ':', val)
#
# Show FirstOrder features, calculated on a wavelet filtered image
#
if applyWavelet:
for decompositionImage, decompositionName, inputKwargs in imageoperations.getWaveletImage(image, mask):
waveletFirstOrderFeaturs = firstorder.RadiomicsFirstOrder(decompositionImage, mask, **inputKwargs)
waveletFirstOrderFeaturs.enableAllFeatures()
results = waveletFirstOrderFeaturs.execute()
print('Calculated firstorder features with wavelet ', decompositionName)
for (key, val) in six.iteritems(results):
waveletFeatureName = '%s_%s' % (str(decompositionName), key)
print(' ', waveletFeatureName, ':', val)
输出结果:
Will calculate the following first order features:
Mean
**8. Mean**
.. math::
\textit{mean} = \frac{1}{N_p}\displaystyle\sum^{N_p}_{i=1}{\textbf{X}(i)}
The average gray level intensity within the ROI.
Calculating first order features...
done
Calculated first order features:
Mean : 825.2354363065023
Will calculate the following Shape features:
Elongation
**16. Elongation**
Elongation shows the relationship between the two largest principal components in the ROI shape.
For computational reasons, this feature is defined as the inverse of true elongation.
.. math::
\textit{elongation} = \sqrt{\frac{\lambda_{minor}}{\lambda_{major}}}
Here, :math:`\lambda_{\text{major}}` and :math:`\lambda_{\text{minor}}` are the lengths of the largest and second
largest principal component axes. The values range between 1 (where the cross section through the first and second
largest principal moments is circle-like (non-elongated)) and 0 (where the object is a maximally elongated: i.e. a 1
dimensional line).
The principal component analysis is performed using the physical coordinates of the voxel centers defining the ROI.
It therefore takes spacing into account, but does not make use of the shape mesh.
Flatness
**17. Flatness**
Flatness shows the relationship between the largest and smallest principal components in the ROI shape.
For computational reasons, this feature is defined as the inverse of true flatness.
.. math::
\textit{flatness} = \sqrt{\frac{\lambda_{least}}{\lambda_{major}}}
Here, :math:`\lambda_{\text{major}}` and :math:`\lambda_{\text{least}}` are the lengths of the largest and smallest
principal component axes. The values range between 1 (non-flat, sphere-like) and 0 (a flat object, or single-slice
segmentation).
The principal component analysis is performed using the physical coordinates of the voxel centers defining the ROI.
It therefore takes spacing into account, but does not make use of the shape mesh.
LeastAxisLength
**15. Least Axis Length**
.. math::
\textit{least axis} = 4 \sqrt{\lambda_{least}}
This feature yield the smallest axis length of the ROI-enclosing ellipsoid and is calculated using the largest
principal component :math:`\lambda_{least}`. In case of a 2D segmentation, this value will be 0.
The principal component analysis is performed using the physical coordinates of the voxel centers defining the ROI.
It therefore takes spacing into account, but does not make use of the shape mesh.
MajorAxisLength
**13. Major Axis Length**
.. math::
\textit{major axis} = 4 \sqrt{\lambda_{major}}
This feature yield the largest axis length of the ROI-enclosing ellipsoid and is calculated using the largest
principal component :math:`\lambda_{major}`.
The principal component analysis is performed using the physical coordinates of the voxel centers defining the ROI.
It therefore takes spacing into account, but does not make use of the shape mesh.
Maximum2DDiameterColumn
**11. Maximum 2D diameter (Column)**
Maximum 2D diameter (Column) is defined as the largest pairwise Euclidean distance between tumor surface mesh
vertices in the row-slice (usually the coronal) plane.
Maximum2DDiameterRow
**12. Maximum 2D diameter (Row)**
Maximum 2D diameter (Row) is defined as the largest pairwise Euclidean distance between tumor surface mesh
vertices in the column-slice (usually the sagittal) plane.
Maximum2DDiameterSlice
**10. Maximum 2D diameter (Slice)**
Maximum 2D diameter (Slice) is defined as the largest pairwise Euclidean distance between tumor surface mesh
vertices in the row-column (generally the axial) plane.
Maximum3DDiameter
**9. Maximum 3D diameter**
Maximum 3D diameter is defined as the largest pairwise Euclidean distance between tumor surface mesh
vertices.
Also known as Feret Diameter.
MeshVolume
**1. Mesh Volume**
.. math::
V_i = \displaystyle\frac{Oa_i \cdot (Ob_i \times Oc_i)}{6} \text{ (1)}
V = \displaystyle\sum^{N_f}_{i=1}{V_i} \text{ (2)}
The volume of the ROI :math:`V` is calculated from the triangle mesh of the ROI.
For each face :math:`i` in the mesh, defined by points :math:`a_i, b_i` and :math:`c_i`, the (signed) volume
:math:`V_f` of the tetrahedron defined by that face and the origin of the image (:math:`O`) is calculated. (1)
The sign of the volume is determined by the sign of the normal, which must be consistently defined as either facing
outward or inward of the ROI.
Then taking the sum of all :math:`V_i`, the total volume of the ROI is obtained (2)
.. note::
For more extensive documentation on how the volume is obtained using the surface mesh, see the IBSI document,
where this feature is defined as ``Volume``.
MinorAxisLength
**14. Minor Axis Length**
.. math::
\textit{minor axis} = 4 \sqrt{\lambda_{minor}}
This feature yield the second-largest axis length of the ROI-enclosing ellipsoid and is calculated using the largest
principal component :math:`\lambda_{minor}`.
The principal component analysis is performed using the physical coordinates of the voxel centers defining the ROI.
It therefore takes spacing into account, but does not make use of the shape mesh.
Sphericity
**5. Sphericity**
.. math::
\textit{sphericity} = \frac{\sqrt[3]{36 \pi V^2}}{A}
Sphericity is a measure of the roundness of the shape of the tumor region relative to a sphere. It is a
dimensionless measure, independent of scale and orientation. The value range is :math:`0 < sphericity \leq 1`, where
a value of 1 indicates a perfect sphere (a sphere has the smallest possible surface area for a given volume,
compared to other solids).
.. note::
This feature is correlated to Compactness 1, Compactness 2 and Spherical Disproportion. In the default
parameter file provided in the ``pyradiomics/examples/exampleSettings`` folder, Compactness 1 and Compactness 2
are therefore disabled.
SurfaceArea
**3. Surface Area**
.. math::
A_i = \frac{1}{2}|\text{a}_i\text{b}_i \times \text{a}_i\text{c}_i| \text{ (1)}
A = \displaystyle\sum^{N_f}_{i=1}{A_i} \text{ (2)}
where:
:math:`\text{a}_i\text{b}_i` and :math:`\text{a}_i\text{c}_i` are edges of the :math:`i^{\text{th}}` triangle in the
mesh, formed by vertices :math:`\text{a}_i`, :math:`\text{b}_i` and :math:`\text{c}_i`.
To calculate the surface area, first the surface area :math:`A_i` of each triangle in the mesh is calculated (1).
The total surface area is then obtained by taking the sum of all calculated sub-areas (2).
.. note::
Defined in IBSI as ``Surface Area``.
SurfaceVolumeRatio
**4. Surface Area to Volume ratio**
.. math::
\textit{surface to volume ratio} = \frac{A}{V}
Here, a lower value indicates a more compact (sphere-like) shape. This feature is not dimensionless, and is
therefore (partly) dependent on the volume of the ROI.
VoxelVolume
**2. Voxel Volume**
.. math::
V_{voxel} = \displaystyle\sum^{N_v}_{k=1}{V_k}
The volume of the ROI :math:`V_{voxel}` is approximated by multiplying the number of voxels in the ROI by the volume
of a single voxel :math:`V_k`. This is a less precise approximation of the volume and is not used in subsequent
features. This feature does not make use of the mesh and is not used in calculation of other shape features.
.. note::
Defined in IBSI as ``Approximate Volume``.
Calculating Shape features...
done
Calculated Shape features:
Elongation : 0.5621171627174117
Flatness : 0.4610597534658259
LeastAxisLength : 28.584423185376494
MajorAxisLength : 61.99722046980878
Maximum2DDiameterColumn : 49.490854979101925
Maximum2DDiameterRow : 65.88905951721043
Maximum2DDiameterSlice : 53.59397776919529
Maximum3DDiameter : 69.60099030590368
MeshVolume : 16147.51180013021
MinorAxisLength : 34.84970166685475
Sphericity : 0.4798234536231475
SurfaceArea : 6438.821603779402
SurfaceVolumeRatio : 0.3987500788652454
VoxelVolume : 16412.658691406243
Will calculate the following GLCM features:
Autocorrelation
**1. Autocorrelation**
.. math::
\textit{autocorrelation} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1}{p(i,j)ij}
Autocorrelation is a measure of the magnitude of the fineness and coarseness of texture.
ClusterProminence
**3. Cluster Prominence**
.. math::
\textit{cluster prominence} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1}
{\big( i+j-\mu_x-\mu_y\big)^4p(i,j)}
Cluster Prominence is a measure of the skewness and asymmetry of the GLCM. A higher values implies more asymmetry
about the mean while a lower value indicates a peak near the mean value and less variation about the mean.
ClusterShade
**4. Cluster Shade**
.. math::
\textit{cluster shade} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1}
{\big(i+j-\mu_x-\mu_y\big)^3p(i,j)}
Cluster Shade is a measure of the skewness and uniformity of the GLCM.
A higher cluster shade implies greater asymmetry about the mean.
ClusterTendency
**5. Cluster Tendency**
.. math::
\textit{cluster tendency} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1}
{\big(i+j-\mu_x-\mu_y\big)^2p(i,j)}
Cluster Tendency is a measure of groupings of voxels with similar gray-level values.
Contrast
**6. Contrast**
.. math::
\textit{contrast} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1}{(i-j)^2p(i,j)}
Contrast is a measure of the local intensity variation, favoring values away from the diagonal :math:`(i = j)`. A
larger value correlates with a greater disparity in intensity values among neighboring voxels.
Correlation
**7. Correlation**
.. math::
\textit{correlation} = \frac{\sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p(i,j)ij-\mu_x\mu_y}}{\sigma_x(i)\sigma_y(j)}
Correlation is a value between 0 (uncorrelated) and 1 (perfectly correlated) showing the
linear dependency of gray level values to their respective voxels in the GLCM.
.. note::
When there is only 1 discrete gray value in the ROI (flat region), :math:`\sigma_x` and :math:`\sigma_y` will be
0. In this case, an arbitrary value of 1 is returned instead. This is assessed on a per-angle basis.
DifferenceAverage
**8. Difference Average**
.. math::
\textit{difference average} = \displaystyle\sum^{N_g-1}_{k=0}{kp_{x-y}(k)}
Difference Average measures the relationship between occurrences of pairs
with similar intensity values and occurrences of pairs with differing intensity
values.
DifferenceEntropy
**9. Difference Entropy**
.. math::
\textit{difference entropy} = \displaystyle\sum^{N_g-1}_{k=0}{p_{x-y}(k)\log_2\big(p_{x-y}(k)+\epsilon\big)}
Difference Entropy is a measure of the randomness/variability
in neighborhood intensity value differences.
DifferenceVariance
**10. Difference Variance**
.. math::
\textit{difference variance} = \displaystyle\sum^{N_g-1}_{k=0}{(k-DA)^2p_{x-y}(k)}
Difference Variance is a measure of heterogeneity that places higher weights on
differing intensity level pairs that deviate more from the mean.
Id
**18. Inverse Difference (ID)**
.. math::
\textit{ID} = \displaystyle\sum^{N_g-1}_{k=0}{\frac{p_{x-y}(k)}{1+k}}
ID (a.k.a. Homogeneity 1) is another measure of the local homogeneity of an image.
With more uniform gray levels, the denominator will remain low, resulting in a higher overall value.
Idm
**15. Inverse Difference Moment (IDM)**
.. math::
\textit{IDM} = \displaystyle\sum^{N_g-1}_{k=0}{\frac{p_{x-y}(k)}{1+k^2}}
IDM (a.k.a Homogeneity 2) is a measure of the local
homogeneity of an image. IDM weights are the inverse of the Contrast
weights (decreasing exponentially from the diagonal i=j in the GLCM).
Idmn
**17. Inverse Difference Moment Normalized (IDMN)**
.. math::
\textit{IDMN} = \displaystyle\sum^{N_g-1}_{k=0}{ \frac{p_{x-y}(k)}{1+\left(\frac{k^2}{N_g^2}\right)} }
IDMN (inverse difference moment normalized) is a measure of the local
homogeneity of an image. IDMN weights are the inverse of the Contrast
weights (decreasing exponentially from the diagonal :math:`i=j` in the GLCM).
Unlike Homogeneity2, IDMN normalizes the square of the difference between
neighboring intensity values by dividing over the square of the total
number of discrete intensity values.
Idn
**19. Inverse Difference Normalized (IDN)**
.. math::
\textit{IDN} = \displaystyle\sum^{N_g-1}_{k=0}{ \frac{p_{x-y}(k)}{1+\left(\frac{k}{N_g}\right)} }
IDN (inverse difference normalized) is another measure of the local
homogeneity of an image. Unlike Homogeneity1, IDN normalizes the difference
between the neighboring intensity values by dividing over the total number
of discrete intensity values.
Imc1
**13. Informational Measure of Correlation (IMC) 1**
.. math::
\textit{IMC 1} = \displaystyle\frac{HXY-HXY1}{\max\{HX,HY\}}
IMC1 assesses the correlation between the probability distributions of :math:`i` and :math:`j` (quantifying the
complexity of the texture), using mutual information I(x, y):
.. math::
I(i, j) = \sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p(i,j)\log_2\big(\frac{p(i,j)}{p_x(i)p_y(j)}\big)}
= \sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p(i,j)\big(\log_2 (p(i,j)) - \log_2 (p_x(i)p_y(j))\big)}
= \sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p(i,j)\log_2 \big(p(i,j)\big)} -
\sum^{N_g}_{i=1}\sum^{N_g}_{j=1}{p(i,j)\log_2 \big(p_x(i)p_y(j)\big)}
= -HXY + HXY1
However, in this formula, the numerator is defined as HXY - HXY1 (i.e. :math:`-I(x, y)`), and is
therefore :math:`\leq 0`. This reflects how this feature is defined in the original Haralick paper.
In the case where the distributions are independent, there is no mutual information and the result will therefore be
0. In the case of uniform distribution with complete dependence, mutual information will be equal to
:math:`\log_2(N_g)`.
Finally, :math:`HXY - HXY1` is divided by the maximum of the 2 marginal entropies, where in the latter case of
complete dependence (not necessarily uniform; low complexity) it will result in :math:`IMC1 = -1`, as
:math:`HX = HY = I(i, j)`.
.. note::
In the case where both HX and HY are 0 (as is the case in a flat region), an arbitrary value of 0 is returned to
prevent a division by 0. This is done on a per-angle basis (i.e. prior to any averaging).
Imc2
**14. Informational Measure of Correlation (IMC) 2**
.. math::
\textit{IMC 2} = \displaystyle\sqrt{1-e^{-2(HXY2-HXY)}}
IMC2 also assesses the correlation between the probability distributions of :math:`i` and :math:`j` (quantifying the
complexity of the texture). Of interest is to note that :math:`HXY1 = HXY2` and that :math:`HXY2 - HXY \geq 0`
represents the mutual information of the 2 distributions. Therefore, the range of IMC2 = [0, 1), with 0 representing
the case of 2 independent distributions (no mutual information) and the maximum value representing the case of 2
fully dependent and uniform distributions (maximal mutual information, equal to :math:`\log_2(N_g)`). In this latter
case, the maximum value is then equal to :math:`\displaystyle\sqrt{1-e^{-2\log_2(N_g)}}`, approaching 1.
.. note::
Due to machine precision errors, it is possble that HXY > HXY2, which would result in returning complex numbers.
In these cases, a value of 0 is returned for IMC2. This is done on a per-angle basis (i.e. prior to any
averaging).
InverseVariance
**20. Inverse Variance**
.. math::
\textit{inverse variance} = \displaystyle\sum^{N_g-1}_{k=1}{\frac{p_{x-y}(k)}{k^2}}
Note that :math:`k=0` is skipped, as this would result in a division by 0.
JointAverage
**2. Joint Average**
.. math::
\textit{joint average} = \mu_x = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1}{p(i,j)i}
Returns the mean gray level intensity of the :math:`i` distribution.
.. warning::
As this formula represents the average of the distribution of :math:`i`, it is independent from the
distribution of :math:`j`. Therefore, only use this formula if the GLCM is symmetrical, where
:math:`p_x(i) = p_y(j) \text{, where } i = j`.
JointEnergy
**11. Joint Energy**
.. math::
\textit{joint energy} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1}{\big(p(i,j)\big)^2}
Energy is a measure of homogeneous patterns
in the image. A greater Energy implies that there are more instances
of intensity value pairs in the image that neighbor each other at
higher frequencies.
.. note::
Defined by IBSI as Angular Second Moment.
JointEntropy
**12. Joint Entropy**
.. math::
\textit{joint entropy} = -\displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1}
{p(i,j)\log_2\big(p(i,j)+\epsilon\big)}
Joint entropy is a measure of the randomness/variability in neighborhood intensity values.
.. note::
Defined by IBSI as Joint entropy
MCC
**16. Maximal Correlation Coefficient (MCC)**
.. math::
\textit{MCC} = \sqrt{\text{second largest eigenvalue of Q}}
Q(i, j) = \displaystyle\sum^{N_g}_{k=0}{\frac{p(i,k)p(j, k)}{p_x(i)p_y(k)}}
The Maximal Correlation Coefficient is a measure of complexity of the texture and :math:`0 \leq MCC \leq 1`.
In case of a flat region, each GLCM matrix has shape (1, 1), resulting in just 1 eigenvalue. In this case, an
arbitrary value of 1 is returned.
MaximumProbability
**21. Maximum Probability**
.. math::
\textit{maximum probability} = \max\big(p(i,j)\big)
Maximum Probability is occurrences of the most predominant pair of
neighboring intensity values.
.. note::
Defined by IBSI as Joint maximum
SumAverage
**22. Sum Average**
.. math::
\textit{sum average} = \displaystyle\sum^{2N_g}_{k=2}{p_{x+y}(k)k}
Sum Average measures the relationship between occurrences of pairs
with lower intensity values and occurrences of pairs with higher intensity
values.
.. warning::
When GLCM is symmetrical, :math:`\mu_x = \mu_y`, and therefore :math:`\text{Sum Average} = \mu_x + \mu_y =
2 \mu_x = 2 * Joint Average`. See formulas (4.), (5.) and (6.) defined
:ref:`here <radiomics-excluded-sumvariance-label>` for the proof that :math:`\text{Sum Average} = \mu_x + \mu_y`.
In the default parameter files provided in the ``examples/exampleSettings``, this feature has been disabled.
SumEntropy
**23. Sum Entropy**
.. math::
\textit{sum entropy} = \displaystyle\sum^{2N_g}_{k=2}{p_{x+y}(k)\log_2\big(p_{x+y}(k)+\epsilon\big)}
Sum Entropy is a sum of neighborhood intensity value differences.
SumSquares
**24. Sum of Squares**
.. math::
\textit{sum squares} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_g}_{j=1}{(i-\mu_x)^2p(i,j)}
Sum of Squares or Variance is a measure in the distribution of neigboring intensity level pairs
about the mean intensity level in the GLCM.
.. warning::
This formula represents the variance of the distribution of :math:`i` and is independent from the distribution
of :math:`j`. Therefore, only use this formula if the GLCM is symmetrical, where
:math:`p_x(i) = p_y(j) \text{, where } i = j`
.. note::
Defined by IBSI as Joint Variance
Calculating GLCM features...
GLCM is symmetrical, therefore Sum Average = 2 * Joint Average, only 1 needs to be calculated
done
Calculated GLCM features:
Autocorrelation : 289.5436994017259
ClusterProminence : 27995.937591943148
ClusterShade : 19.605083427286676
ClusterTendency : 108.73139325453903
Contrast : 47.492125114429776
Correlation : 0.3917522006696661
DifferenceAverage : 5.284468789866316
DifferenceEntropy : 3.74406097806642
DifferenceVariance : 16.65563705027098
Id : 0.28722572382985156
Idm : 0.20022255640475703
Idmn : 0.961402169623227
Idn : 0.8726052157397169
Imc1 : -0.09438938808738298
Imc2 : 0.6942249020670357
InverseVariance : 0.19881884197093194
JointAverage : 16.55380772442751
JointEnergy : 0.002893149242988865
JointEntropy : 8.799696270248813
MCC : 0.4990404679585558
MaximumProbability : 0.007352392266290182
SumAverage : 33.10761544885502
SumEntropy : 5.354241321485615
SumSquares : 39.05587959224222
Will calculate the following GLRLM features:
GrayLevelNonUniformity
**3. Gray Level Non-Uniformity (GLN)**
.. math::
\textit{GLN} = \frac{\sum^{N_g}_{i=1}\left(\sum^{N_r}_{j=1}{\textbf{P}(i,j|\theta)}\right)^2}{N_r(\theta)}
GLN measures the similarity of gray-level intensity values in the image, where a lower GLN value correlates with a
greater similarity in intensity values.
GrayLevelNonUniformityNormalized
**4. Gray Level Non-Uniformity Normalized (GLNN)**
.. math::
\textit{GLNN} = \frac{\sum^{N_g}_{i=1}\left(\sum^{N_r}_{j=1}{\textbf{P}(i,j|\theta)}\right)^2}{N_r(\theta)^2}
GLNN measures the similarity of gray-level intensity values in the image, where a lower GLNN value correlates with a
greater similarity in intensity values. This is the normalized version of the GLN formula.
GrayLevelVariance
**8. Gray Level Variance (GLV)**
.. math::
\textit{GLV} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_r}_{j=1}{p(i,j|\theta)(i - \mu)^2}
Here, :math:`\mu = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_r}_{j=1}{p(i,j|\theta)i}`
GLV measures the variance in gray level intensity for the runs.
HighGrayLevelRunEmphasis
**12. High Gray Level Run Emphasis (HGLRE)**
.. math::
\textit{HGLRE} = \frac{\sum^{N_g}_{i=1}\sum^{N_r}_{j=1}{\textbf{P}(i,j|\theta)i^2}}{N_r(\theta)}
HGLRE measures the distribution of the higher gray-level values, with a higher value indicating a greater
concentration of high gray-level values in the image.
LongRunEmphasis
**2. Long Run Emphasis (LRE)**
.. math::
\textit{LRE} = \frac{\sum^{N_g}_{i=1}\sum^{N_r}_{j=1}{\textbf{P}(i,j|\theta)j^2}}{N_r(\theta)}
LRE is a measure of the distribution of long run lengths, with a greater value indicative of longer run lengths and
more coarse structural textures.
LongRunHighGrayLevelEmphasis
**16. Long Run High Gray Level Emphasis (LRHGLE)**
.. math::
\textit{LRHGLRE} = \frac{\sum^{N_g}_{i=1}\sum^{N_r}_{j=1}{\textbf{P}(i,j|\theta)i^2j^2}}{N_r(\theta)}
LRHGLRE measures the joint distribution of long run lengths with higher gray-level values.
LongRunLowGrayLevelEmphasis
**15. Long Run Low Gray Level Emphasis (LRLGLE)**
.. math::
\textit{LRLGLRE} = \frac{\sum^{N_g}_{i=1}\sum^{N_r}_{j=1}{\frac{\textbf{P}(i,j|\theta)j^2}{i^2}}}{N_r(\theta)}
LRLGLRE measures the joint distribution of long run lengths with lower gray-level values.
LowGrayLevelRunEmphasis
**11. Low Gray Level Run Emphasis (LGLRE)**
.. math::
\textit{LGLRE} = \frac{\sum^{N_g}_{i=1}\sum^{N_r}_{j=1}{\frac{\textbf{P}(i,j|\theta)}{i^2}}}{N_r(\theta)}
LGLRE measures the distribution of low gray-level values, with a higher value indicating a greater concentration of
low gray-level values in the image.
RunEntropy
**10. Run Entropy (RE)**
.. math::
\textit{RE} = -\displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_r}_{j=1}
{p(i,j|\theta)\log_{2}(p(i,j|\theta)+\epsilon)}
Here, :math:`\epsilon` is an arbitrarily small positive number (:math:`\approx 2.2\times10^{-16}`).
RE measures the uncertainty/randomness in the distribution of run lengths and gray levels. A higher value indicates
more heterogeneity in the texture patterns.
RunLengthNonUniformity
**5. Run Length Non-Uniformity (RLN)**
.. math::
\textit{RLN} = \frac{\sum^{N_r}_{j=1}\left(\sum^{N_g}_{i=1}{\textbf{P}(i,j|\theta)}\right)^2}{N_r(\theta)}
RLN measures the similarity of run lengths throughout the image, with a lower value indicating more homogeneity
among run lengths in the image.
RunLengthNonUniformityNormalized
**6. Run Length Non-Uniformity Normalized (RLNN)**
.. math::
\textit{RLNN} = \frac{\sum^{N_r}_{j=1}\left(\sum^{N_g}_{i=1}{\textbf{P}(i,j|\theta)}\right)^2}{N_r(\theta)^2}
RLNN measures the similarity of run lengths throughout the image, with a lower value indicating more homogeneity
among run lengths in the image. This is the normalized version of the RLN formula.
RunPercentage
**7. Run Percentage (RP)**
.. math::
\textit{RP} = {\frac{N_r(\theta)}{N_p}}
RP measures the coarseness of the texture by taking the ratio of number of runs and number of voxels in the ROI.
Values are in range :math:`\frac{1}{N_p} \leq RP \leq 1`, with higher values indicating a larger portion of the ROI
consists of short runs (indicates a more fine texture).
.. note::
Note that when weighting is applied and matrices are merged before calculation, :math:`N_p` is multiplied by
:math:`n` number of matrices merged to ensure correct normalization (as each voxel is considered :math:`n` times)
RunVariance
**9. Run Variance (RV)**
.. math::
\textit{RV} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_r}_{j=1}{p(i,j|\theta)(j - \mu)^2}
Here, :math:`\mu = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_r}_{j=1}{p(i,j|\theta)j}`
RV is a measure of the variance in runs for the run lengths.
ShortRunEmphasis
**1. Short Run Emphasis (SRE)**
.. math::
\textit{SRE} = \frac{\sum^{N_g}_{i=1}\sum^{N_r}_{j=1}{\frac{\textbf{P}(i,j|\theta)}{j^2}}}{N_r(\theta)}
SRE is a measure of the distribution of short run lengths, with a greater value indicative of shorter run lengths
and more fine textural textures.
ShortRunHighGrayLevelEmphasis
**14. Short Run High Gray Level Emphasis (SRHGLE)**
.. math::
\textit{SRHGLE} = \frac{\sum^{N_g}_{i=1}\sum^{N_r}_{j=1}{\frac{\textbf{P}(i,j|\theta)i^2}{j^2}}}{N_r(\theta)}
SRHGLE measures the joint distribution of shorter run lengths with higher gray-level values.
ShortRunLowGrayLevelEmphasis
**13. Short Run Low Gray Level Emphasis (SRLGLE)**
.. math::
\textit{SRLGLE} = \frac{\sum^{N_g}_{i=1}\sum^{N_r}_{j=1}{\frac{\textbf{P}(i,j|\theta)}{i^2j^2}}}{N_r(\theta)}
SRLGLE measures the joint distribution of shorter run lengths with lower gray-level values.
Calculating GLRLM features...
done
Calculated GLRLM features:
GrayLevelNonUniformity : 175.6351923150419
GrayLevelNonUniformityNormalized : 0.04514123814981055
GrayLevelVariance : 39.118151021979244
HighGrayLevelRunEmphasis : 281.066493908972
LongRunEmphasis : 1.2268440382584342
LongRunHighGrayLevelEmphasis : 341.2865790983503
LongRunLowGrayLevelEmphasis : 0.010601170478748765
LowGrayLevelRunEmphasis : 0.008600397891661503
RunEntropy : 4.915038003159503
RunLengthNonUniformity : 3500.0432315746298
RunLengthNonUniformityNormalized : 0.8950494659480998
RunPercentage : 0.9404064632491029
RunVariance : 0.08479457789590625
ShortRunEmphasis : 0.9559391731405504
ShortRunHighGrayLevelEmphasis : 268.9741798411307
ShortRunLowGrayLevelEmphasis : 0.008229766244155428
Will calculate the following GLSZM features:
GrayLevelNonUniformity
**3. Gray Level Non-Uniformity (GLN)**
.. math::
\textit{GLN} = \frac{\sum^{N_g}_{i=1}\left(\sum^{N_s}_{j=1}{\textbf{P}(i,j)}\right)^2}{N_z}
GLN measures the variability of gray-level intensity values in the image, with a lower value indicating more
homogeneity in intensity values.
GrayLevelNonUniformityNormalized
**4. Gray Level Non-Uniformity Normalized (GLNN)**
.. math::
\textit{GLNN} = \frac{\sum^{N_g}_{i=1}\left(\sum^{N_s}_{j=1}{\textbf{P}(i,j)}\right)^2}{N_z^2}
GLNN measures the variability of gray-level intensity values in the image, with a lower value indicating a greater
similarity in intensity values. This is the normalized version of the GLN formula.
GrayLevelVariance
**8. Gray Level Variance (GLV)**
.. math::
\textit{GLV} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_s}_{j=1}{p(i,j)(i - \mu)^2}
Here, :math:`\mu = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_s}_{j=1}{p(i,j)i}`
GLV measures the variance in gray level intensities for the zones.
HighGrayLevelZoneEmphasis
**12. High Gray Level Zone Emphasis (HGLZE)**
.. math::
\textit{HGLZE} = \frac{\sum^{N_g}_{i=1}\sum^{N_s}_{j=1}{\textbf{P}(i,j)i^2}}{N_z}
HGLZE measures the distribution of the higher gray-level values, with a higher value indicating a greater proportion
of higher gray-level values and size zones in the image.
LargeAreaEmphasis
**2. Large Area Emphasis (LAE)**
.. math::
\textit{LAE} = \frac{\sum^{N_g}_{i=1}\sum^{N_s}_{j=1}{\textbf{P}(i,j)j^2}}{N_z}
LAE is a measure of the distribution of large area size zones, with a greater value indicative of more larger size
zones and more coarse textures.
LargeAreaHighGrayLevelEmphasis
**16. Large Area High Gray Level Emphasis (LAHGLE)**
.. math::
\textit{LAHGLE} = \frac{\sum^{N_g}_{i=1}\sum^{N_s}_{j=1}{\textbf{P}(i,j)i^2j^2}}{N_z}
LAHGLE measures the proportion in the image of the joint distribution of larger size zones with higher gray-level
values.
LargeAreaLowGrayLevelEmphasis
**15. Large Area Low Gray Level Emphasis (LALGLE)**
.. math::
\textit{LALGLE} = \frac{\sum^{N_g}_{i=1}\sum^{N_s}_{j=1}{\frac{\textbf{P}(i,j)j^2}{i^2}}}{N_z}
LALGLE measures the proportion in the image of the joint distribution of larger size zones with lower gray-level
values.
LowGrayLevelZoneEmphasis
**11. Low Gray Level Zone Emphasis (LGLZE)**
.. math::
\textit{LGLZE} = \frac{\sum^{N_g}_{i=1}\sum^{N_s}_{j=1}{\frac{\textbf{P}(i,j)}{i^2}}}{N_z}
LGLZE measures the distribution of lower gray-level size zones, with a higher value indicating a greater proportion
of lower gray-level values and size zones in the image.
SizeZoneNonUniformity
**5. Size-Zone Non-Uniformity (SZN)**
.. math::
\textit{SZN} = \frac{\sum^{N_s}_{j=1}\left(\sum^{N_g}_{i=1}{\textbf{P}(i,j)}\right)^2}{N_z}
SZN measures the variability of size zone volumes in the image, with a lower value indicating more homogeneity in
size zone volumes.
SizeZoneNonUniformityNormalized
**6. Size-Zone Non-Uniformity Normalized (SZNN)**
.. math::
\textit{SZNN} = \frac{\sum^{N_s}_{j=1}\left(\sum^{N_g}_{i=1}{\textbf{P}(i,j)}\right)^2}{N_z^2}
SZNN measures the variability of size zone volumes throughout the image, with a lower value indicating more
homogeneity among zone size volumes in the image. This is the normalized version of the SZN formula.
SmallAreaEmphasis
**1. Small Area Emphasis (SAE)**
.. math::
\textit{SAE} = \frac{\sum^{N_g}_{i=1}\sum^{N_s}_{j=1}{\frac{\textbf{P}(i,j)}{j^2}}}{N_z}
SAE is a measure of the distribution of small size zones, with a greater value indicative of more smaller size zones
and more fine textures.
SmallAreaHighGrayLevelEmphasis
**14. Small Area High Gray Level Emphasis (SAHGLE)**
.. math::
\textit{SAHGLE} = \frac{\sum^{N_g}_{i=1}\sum^{N_s}_{j=1}{\frac{\textbf{P}(i,j)i^2}{j^2}}}{N_z}
SAHGLE measures the proportion in the image of the joint distribution of smaller size zones with higher gray-level
values.
SmallAreaLowGrayLevelEmphasis
**13. Small Area Low Gray Level Emphasis (SALGLE)**
.. math::
\textit{SALGLE} = \frac{\sum^{N_g}_{i=1}\sum^{N_s}_{j=1}{\frac{\textbf{P}(i,j)}{i^2j^2}}}{N_z}
SALGLE measures the proportion in the image of the joint distribution of smaller size zones with lower gray-level
values.
ZoneEntropy
**10. Zone Entropy (ZE)**
.. math::
\textit{ZE} = -\displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_s}_{j=1}{p(i,j)\log_{2}(p(i,j)+\epsilon)}
Here, :math:`\epsilon` is an arbitrarily small positive number (:math:`\approx 2.2\times10^{-16}`).
ZE measures the uncertainty/randomness in the distribution of zone sizes and gray levels. A higher value indicates
more heterogeneneity in the texture patterns.
ZonePercentage
**7. Zone Percentage (ZP)**
.. math::
\textit{ZP} = \frac{N_z}{N_p}
ZP measures the coarseness of the texture by taking the ratio of number of zones and number of voxels in the ROI.
Values are in range :math:`\frac{1}{N_p} \leq ZP \leq 1`, with higher values indicating a larger portion of the ROI
consists of small zones (indicates a more fine texture).
ZoneVariance
**9. Zone Variance (ZV)**
.. math::
\textit{ZV} = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_s}_{j=1}{p(i,j)(j - \mu)^2}
Here, :math:`\mu = \displaystyle\sum^{N_g}_{i=1}\displaystyle\sum^{N_s}_{j=1}{p(i,j)j}`
ZV measures the variance in zone size volumes for the zones.
Calculating GLSZM features...
done
Calculated GLSZM features:
GrayLevelNonUniformity : 82.38716577540107
GrayLevelNonUniformityNormalized : 0.044057307901283996
GrayLevelVariance : 40.60313992393263
HighGrayLevelZoneEmphasis : 288.6235294117647
LargeAreaEmphasis : 13.615508021390374
LargeAreaHighGrayLevelEmphasis : 3514.7614973262034
LargeAreaLowGrayLevelEmphasis : 0.12723841553344326
LowGrayLevelZoneEmphasis : 0.009100942027706215
SizeZoneNonUniformity : 747.5967914438503
SizeZoneNonUniformityNormalized : 0.3997843804512568
SmallAreaEmphasis : 0.6564478999587141
SmallAreaHighGrayLevelEmphasis : 193.438051925864
SmallAreaLowGrayLevelEmphasis : 0.006416982055097711
ZoneEntropy : 6.5082149861981895
ZonePercentage : 0.4520183708000967
ZoneVariance : 8.721239097486347
完整代码下载地址:https://firc.lanzn.com/iUEDf264g2ef
更多测试案例参考:https://github.com/AIM-Harvard/pyradiomics/tree/master/examples