Hello Feature Class example: using the feature classes to calculate features

This example shows how to use the Radiomics package to directly instantiate the feature classes for feature extraction. Note that this is not the intended standard use. For an example on the standard use with feature extractor, see the helloRadiomics example.


In [26]:
from __future__ import print_function
import os
import collections
import SimpleITK as sitk
import numpy
import six
import radiomics
from radiomics import firstorder, glcm, imageoperations, shape, glrlm, glszm

Getting the test case

Test cases can be downloaded to temporary files. This is handled by the radiomics.getTestCase() function, which checks if the requested test case is available and if not, downloads it. It returns a tuple with the location of the image and mask of the requested test case, or (None, None) if it fails.

Alternatively, if the data is available somewhere locally, this directory can be passed as a second argument to radiomics.getTestCase(). If that directory does not exist or does not contain the testcase, functionality reverts to default and tries to download the test data.

If getting the test case fails, PyRadiomics will log an error explaining the cause.


In [27]:
imageName, maskName = radiomics.getTestCase('brain1')

if imageName is None or maskName is None:  # Something went wrong, in this case PyRadiomics will also log an error
    raise Exception('Error getting testcase!')  # Raise exception to prevent cells below from running in case of "run all"

In [28]:
image = sitk.ReadImage(imageName)
mask = sitk.ReadImage(maskName)

Preprocess the image

Extraction Settings


In [29]:
settings = {}
settings['binWidth'] = 25
settings['resampledPixelSpacing'] = None
# settings['resampledPixelSpacing'] = [3, 3, 3]  # This is an example for defining resampling (voxels with size 3x3x3mm)
settings['interpolator'] = 'sitkBSpline'
settings['verbose'] = True

If enabled, resample the image


In [30]:
# Resample if necessary
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)

Calculate features using original image


In [31]:
# Crop the image
# bb is the bounding box, upon which the image and mask are cropped
bb, correctedMask = imageoperations.checkMask(image, mask, label=1)
if correctedMask is not None:
    mask = correctedMask
croppedImage, croppedMask = imageoperations.cropToTumorMask(image, mask, bb)

Calculate Firstorder features


In [32]:
firstOrderFeatures = firstorder.RadiomicsFirstOrder(croppedImage, croppedMask, **settings)

# Set the features to be calculated
firstOrderFeatures.enableFeatureByName('Mean', True)
# firstOrderFeatures.enableAllFeatures()

In [33]:
# Print out the docstrings of the enabled features
print('Will calculate the following first order features: ')
for f in firstOrderFeatures.enabledFeatures.keys():
  print(f)
  print(getattr(firstOrderFeatures, 'get%sFeatureValue' % f).__doc__)


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.
    

In [34]:
# Calculate the features and print(out result)
print('Calculating first order features...',)
result = firstOrderFeatures.execute()
print('done')

print('Calculated first order features: ')
for (key, val) in six.iteritems(result):
  print('  ', key, ':', val)


Calculating first order features...
done
Calculated first order features: 
   Mean : 825.2354363065023

Calculate Shape Features


In [35]:
shapeFeatures = shape.RadiomicsShape(croppedImage, croppedMask, **settings)

# Set the features to be calculated
# shapeFeatures.enableFeatureByName('Volume', True)
shapeFeatures.enableAllFeatures()

In [36]:
# Print out the docstrings of the enabled features
print('Will calculate the following shape features: ')
for f in shapeFeatures.enabledFeatures.keys():
  print(f)
  print(getattr(shapeFeatures, 'get%sFeatureValue' % f).__doc__)


Will calculate the following shape features: 
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.
    
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``.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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``.
    
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.
    
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.
    
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``.
    

In [37]:
# Calculate the features and print(out result)
print('Calculating shape features...',)
result = shapeFeatures.execute()
print('done')

print('Calculated shape features: ')
for (key, val) in six.iteritems(result):
  print('  ', key, ':', val)


Calculating shape features...
done
Calculated shape features: 
   VoxelVolume : 16412.658691406243
   Maximum3DDiameter : 69.60099030590368
   MeshVolume : 16147.51180013021
   MajorAxisLength : 61.99722046980879
   Sphericity : 0.4798234536231475
   LeastAxisLength : 28.584423185376522
   Elongation : 0.5621171627174109
   SurfaceVolumeRatio : 0.3987500788652454
   Maximum2DDiameterSlice : 53.59397776919529
   Flatness : 0.46105975346582634
   SurfaceArea : 6438.821603779402
   MinorAxisLength : 34.849701666854706
   Maximum2DDiameterColumn : 49.490854979101925
   Maximum2DDiameterRow : 65.88905951721043

Calculate GLCM Features


In [38]:
glcmFeatures = glcm.RadiomicsGLCM(croppedImage, croppedMask, **settings)

# Set the features to be calculated
# glcmFeatures.enableFeatureByName('SumEntropy', True)
glcmFeatures.enableAllFeatures()

In [39]:
# Print out the docstrings of the enabled features
print('Will calculate the following GLCM features: ')
for f in glcmFeatures.enabledFeatures.keys():
  print(f)
  print(getattr(glcmFeatures, 'get%sFeatureValue' % f).__doc__)


Will calculate the following GLCM features: 
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`.
    
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.
    
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
    
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.
    
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
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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).
    
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 discreet 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.
    
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.
    
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.
    
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.
    
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
    
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.
    
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).
    
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).
    
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.
    
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.
    
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.
    

In [40]:
# Calculate the features and print(out result)
print('Calculating GLCM features...',)
result = glcmFeatures.execute()
print('done')

print('Calculated GLCM features: ')
for (key, val) in six.iteritems(result):
  print('  ', key, ':', val)


GLCM is symmetrical, therefore Sum Average = 2 * Joint Average, only 1 needs to be calculated
Calculating GLCM features...
done
Calculated GLCM features: 
   JointAverage : 16.55380772442751
   SumAverage : 33.10761544885502
   JointEntropy : 8.799696270248813
   ClusterShade : 19.605083427286676
   MaximumProbability : 0.007352392266290182
   Idmn : 0.961402169623227
   JointEnergy : 0.002893149242988865
   Contrast : 47.492125114429776
   DifferenceEntropy : 3.74406097806642
   InverseVariance : 0.19881884197093194
   DifferenceVariance : 16.65563705027098
   Idn : 0.8726052157397169
   Idm : 0.20022255640475703
   Correlation : 0.3917522006696661
   Autocorrelation : 289.5436994017259
   SumEntropy : 5.354241321485615
   MCC : 0.49904046795855606
   SumSquares : 39.05587959224222
   ClusterProminence : 27995.937591943148
   Imc2 : 0.6942249020670357
   Imc1 : -0.09438938808738298
   DifferenceAverage : 5.284468789866316
   Id : 0.28722572382985156
   ClusterTendency : 108.73139325453903

Calculate GLRLM Features


In [41]:
glrlmFeatures = glrlm.RadiomicsGLRLM(croppedImage, croppedMask, **settings)

# Set the features to be calculated
# glrlmFeatures.enableFeatureByName('ShortRunEmphasis', True)
glrlmFeatures.enableAllFeatures()

In [42]:
# Print out the docstrings of the enabled features
print('Will calculate the following GLRLM features: ')
for f in glrlmFeatures.enabledFeatures.keys():
  print(f)
  print(getattr(glrlmFeatures, 'get%sFeatureValue' % f).__doc__)


Will calculate the following GLRLM features: 
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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)
    
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.
    
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.
    
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.
    
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.
    

In [43]:
# Calculate the features and print(out result)
print('Calculating GLRLM features...',)
result = glrlmFeatures.execute()
print('done')

print('Calculated GLRLM features: ')
for (key, val) in six.iteritems(result):
  print('  ', key, ':', val)


Calculating GLRLM features...
done
Calculated GLRLM features: 
   ShortRunLowGrayLevelEmphasis : 0.008229766244155428
   GrayLevelVariance : 39.118151021979244
   LowGrayLevelRunEmphasis : 0.008600397891661503
   GrayLevelNonUniformityNormalized : 0.04514123814981055
   RunVariance : 0.08479457789590625
   GrayLevelNonUniformity : 175.6351923150419
   LongRunEmphasis : 1.2268440382584342
   ShortRunHighGrayLevelEmphasis : 268.9741798411307
   RunLengthNonUniformity : 3500.0432315746298
   ShortRunEmphasis : 0.9559391731405504
   LongRunHighGrayLevelEmphasis : 341.2865790983503
   RunPercentage : 0.9404064632491029
   LongRunLowGrayLevelEmphasis : 0.010601170478748765
   RunEntropy : 4.915038003159503
   HighGrayLevelRunEmphasis : 281.066493908972
   RunLengthNonUniformityNormalized : 0.8950494659480998

Calculate GLSZM Features


In [44]:
glszmFeatures = glszm.RadiomicsGLSZM(croppedImage, croppedMask, **settings)

# Set the features to be calculated
# glszmFeatures.enableFeatureByName('LargeAreaEmphasis', True)
glszmFeatures.enableAllFeatures()

In [45]:
# Print out the docstrings of the enabled features
print('Will calculate the following GLSZM features: ')
for f in glszmFeatures.enabledFeatures.keys():
  print(f)
  print(getattr(glszmFeatures, 'get%sFeatureValue' % f).__doc__)


Will calculate the following GLSZM features: 
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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).
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    
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.
    

In [46]:
# Calculate the features and print(out result)
print('Calculating GLSZM features...',)
result = glszmFeatures.execute()
print('done')

print('Calculated GLSZM features: ')
for (key, val) in six.iteritems(result):
  print('  ', key, ':', val)


Calculating GLSZM features...
done
Calculated GLSZM features: 
   GrayLevelVariance : 40.60313992393263
   ZoneVariance : 8.721239097486347
   GrayLevelNonUniformityNormalized : 0.044057307901283996
   SizeZoneNonUniformityNormalized : 0.3997843804512568
   SizeZoneNonUniformity : 747.5967914438503
   GrayLevelNonUniformity : 82.38716577540107
   LargeAreaEmphasis : 13.615508021390374
   SmallAreaHighGrayLevelEmphasis : 193.438051925864
   ZonePercentage : 0.4520183708000967
   LargeAreaLowGrayLevelEmphasis : 0.12723841553344326
   LargeAreaHighGrayLevelEmphasis : 3514.7614973262034
   HighGrayLevelZoneEmphasis : 288.6235294117647
   SmallAreaEmphasis : 0.6564478999587141
   LowGrayLevelZoneEmphasis : 0.009100942027706215
   ZoneEntropy : 6.50821498619819
   SmallAreaLowGrayLevelEmphasis : 0.006416982055097711

Calculate Features using Laplacian of Gaussian Filter

Calculating features on filtered images is very similar to calculating features on the original image. All filters in PyRadiomics have the same input and output signature, and there is even one for applying no filter. This enables to loop over a list of requested filters and apply them in the same piece of code. It is applied like this in the execute function in feature extractor. The input for the filters is the image, with additional keywords. If no additional keywords are supplied, the filter uses default values where applicable. It returns a generator object, allowing to define the generators to be applied before the filters functions are actually called.

Calculate Firstorder on LoG filtered images


In [47]:
logFeatures = {}
sigmaValues = [1.0, 3.0, 5.0]
for logImage, imageTypename, inputSettings in imageoperations.getLoGImage(image, mask, sigma=sigmaValues):
  logImage, croppedMask = imageoperations.cropToTumorMask(logImage, mask, bb)
  logFirstorderFeatures = firstorder.RadiomicsFirstOrder(logImage, croppedMask, **inputSettings)
  logFirstorderFeatures.enableAllFeatures()
  logFeatures[imageTypename] = logFirstorderFeatures.execute()

In [48]:
# Show result
for sigma, features in six.iteritems(logFeatures):
  for (key, val) in six.iteritems(features):
    laplacianFeatureName = '%s_%s' % (str(sigma), key)
    print('  ', laplacianFeatureName, ':', val)


   log-sigma-3-0-mm-3D_InterquartileRange : 103.15813827514648
   log-sigma-3-0-mm-3D_Skewness : -0.49838634399478493
   log-sigma-3-0-mm-3D_Uniformity : 0.09064784923477494
   log-sigma-3-0-mm-3D_Median : -73.3129653930664
   log-sigma-3-0-mm-3D_Energy : 56119386.49315185
   log-sigma-3-0-mm-3D_RobustMeanAbsoluteDeviation : 43.37792439842861
   log-sigma-3-0-mm-3D_MeanAbsoluteDeviation : 64.33120246325181
   log-sigma-3-0-mm-3D_TotalEnergy : 222641609.01213792
   log-sigma-3-0-mm-3D_Maximum : 114.29669189453125
   log-sigma-3-0-mm-3D_RootMeanSquared : 116.46989846118638
   log-sigma-3-0-mm-3D_90Percentile : 13.917341041564946
   log-sigma-3-0-mm-3D_Minimum : -354.3352355957031
   log-sigma-3-0-mm-3D_Entropy : 3.72121444058449
   log-sigma-3-0-mm-3D_Range : 468.6319274902344
   log-sigma-3-0-mm-3D_Variance : 6720.0665187057575
   log-sigma-3-0-mm-3D_10Percentile : -197.0173400878906
   log-sigma-3-0-mm-3D_Kurtosis : 3.1833658319698688
   log-sigma-3-0-mm-3D_Mean : -82.73554694841455
   log-sigma-1-0-mm-3D_InterquartileRange : 81.87671852111816
   log-sigma-1-0-mm-3D_Skewness : -0.22090525170411396
   log-sigma-1-0-mm-3D_Uniformity : 0.11423531337174343
   log-sigma-1-0-mm-3D_Median : -18.91979217529297
   log-sigma-1-0-mm-3D_Energy : 18272859.744011104
   log-sigma-1-0-mm-3D_RobustMeanAbsoluteDeviation : 34.30945152372748
   log-sigma-1-0-mm-3D_MeanAbsoluteDeviation : 49.664661651136576
   log-sigma-1-0-mm-3D_TotalEnergy : 72493645.22465338
   log-sigma-1-0-mm-3D_Maximum : 164.7267608642578
   log-sigma-1-0-mm-3D_RootMeanSquared : 66.46002494100189
   log-sigma-1-0-mm-3D_90Percentile : 54.79034423828125
   log-sigma-1-0-mm-3D_Minimum : -255.25962829589844
   log-sigma-1-0-mm-3D_Entropy : 3.3700495507795636
   log-sigma-1-0-mm-3D_Range : 419.98638916015625
   log-sigma-1-0-mm-3D_Variance : 3930.907589131821
   log-sigma-1-0-mm-3D_10Percentile : -104.93405303955078
   log-sigma-1-0-mm-3D_Kurtosis : 3.0718243807249306
   log-sigma-1-0-mm-3D_Mean : -22.046027443210075
   log-sigma-5-0-mm-3D_InterquartileRange : 106.34271621704102
   log-sigma-5-0-mm-3D_Skewness : -0.30549686903008444
   log-sigma-5-0-mm-3D_Uniformity : 0.09026759286087939
   log-sigma-5-0-mm-3D_Median : -99.11744689941406
   log-sigma-5-0-mm-3D_Energy : 72664939.72523072
   log-sigma-5-0-mm-3D_RobustMeanAbsoluteDeviation : 43.25629577830131
   log-sigma-5-0-mm-3D_MeanAbsoluteDeviation : 63.43642644575672
   log-sigma-5-0-mm-3D_TotalEnergy : 288282536.7517086
   log-sigma-5-0-mm-3D_Maximum : 117.41451263427734
   log-sigma-5-0-mm-3D_RootMeanSquared : 132.5316785234327
   log-sigma-5-0-mm-3D_90Percentile : -10.697756195068333
   log-sigma-5-0-mm-3D_Minimum : -347.3450012207031
   log-sigma-5-0-mm-3D_Entropy : 3.713363914131388
   log-sigma-5-0-mm-3D_Range : 464.75951385498047
   log-sigma-5-0-mm-3D_Variance : 6483.793919012423
   log-sigma-5-0-mm-3D_10Percentile : -211.97431640625
   log-sigma-5-0-mm-3D_Kurtosis : 3.114891608730306
   log-sigma-5-0-mm-3D_Mean : -105.26562541127133

Calculate Features using Wavelet filter

Calculate Firstorder on filtered images


In [49]:
waveletFeatures = {}
for decompositionImage, decompositionName, inputSettings in imageoperations.getWaveletImage(image, mask):
  decompositionImage, croppedMask = imageoperations.cropToTumorMask(decompositionImage, mask, bb)
  waveletFirstOrderFeaturs = firstorder.RadiomicsFirstOrder(decompositionImage, croppedMask, **inputSettings)
  waveletFirstOrderFeaturs.enableAllFeatures()

  print('Calculate firstorder features with ', decompositionName)
  waveletFeatures[decompositionName] = waveletFirstOrderFeaturs.execute()


Calculate firstorder features with  wavelet-HLL
Calculate firstorder features with  wavelet-LHL
Calculate firstorder features with  wavelet-LHH
Calculate firstorder features with  wavelet-LLH
Calculate firstorder features with  wavelet-HLH
Calculate firstorder features with  wavelet-HHH
Calculate firstorder features with  wavelet-HHL
Calculate firstorder features with  wavelet-LLL

In [50]:
# Show result
for decompositionName, features in six.iteritems(waveletFeatures):
  for (key, val) in six.iteritems(features):
    waveletFeatureName = '%s_%s' % (str(decompositionName), key)
    print('  ', waveletFeatureName, ':', val)


   wavelet-LLL_InterquartileRange : 550.5942674265389
   wavelet-LLL_Skewness : 0.22884642646488648
   wavelet-LLL_Uniformity : 0.019907776727807427
   wavelet-LLL_Median : 2244.886736086164
   wavelet-LLL_Energy : 21547005906.071228
   wavelet-LLL_RobustMeanAbsoluteDeviation : 220.73969717214538
   wavelet-LLL_MeanAbsoluteDeviation : 293.1439959437339
   wavelet-LLL_TotalEnergy : 85483116692.78741
   wavelet-LLL_Maximum : 3180.639186772004
   wavelet-LLL_RootMeanSquared : 2282.184255507612
   wavelet-LLL_90Percentile : 2739.69052111044
   wavelet-LLL_Minimum : 1468.0772410291193
   wavelet-LLL_Entropy : 5.783004890516309
   wavelet-LLL_Range : 1712.5619457428847
   wavelet-LLL_Variance : 122620.56279600722
   wavelet-LLL_10Percentile : 1812.6847348869353
   wavelet-LLL_Kurtosis : 2.2736564306682845
   wavelet-LLL_Mean : 2255.1595095005646
   wavelet-HHH_InterquartileRange : 20.31927464217497
   wavelet-HHH_Skewness : -0.06881127372370828
   wavelet-HHH_Uniformity : 0.38291997981392567
   wavelet-HHH_Median : 0.10911729278904754
   wavelet-HHH_Energy : 1241014.7870147303
   wavelet-HHH_RobustMeanAbsoluteDeviation : 8.5302745069224
   wavelet-HHH_MeanAbsoluteDeviation : 13.075975686184734
   wavelet-HHH_TotalEnergy : 4923459.543210291
   wavelet-HHH_Maximum : 76.40996501874992
   wavelet-HHH_RootMeanSquared : 17.319913459004184
   wavelet-HHH_90Percentile : 20.923843334408843
   wavelet-HHH_Minimum : -74.75569866887916
   wavelet-HHH_Entropy : 1.6278116747544993
   wavelet-HHH_Range : 151.1656636876291
   wavelet-HHH_Variance : 299.95221801349567
   wavelet-HHH_10Percentile : -21.03831302561452
   wavelet-HHH_Kurtosis : 4.324555498144832
   wavelet-HHH_Mean : 0.1648763594289033
   wavelet-LLH_InterquartileRange : 352.67245821032066
   wavelet-LLH_Skewness : -0.5257738152870547
   wavelet-LLH_Uniformity : 0.030439966791254963
   wavelet-LLH_Median : 62.7368130338552
   wavelet-LLH_Energy : 263973676.50526202
   wavelet-LLH_RobustMeanAbsoluteDeviation : 146.79059076010634
   wavelet-LLH_MeanAbsoluteDeviation : 205.42276939216512
   wavelet-LLH_TotalEnergy : 1047258848.4400647
   wavelet-LLH_Maximum : 733.8505082763058
   wavelet-LLH_RootMeanSquared : 252.60244513407108
   wavelet-LLH_90Percentile : 297.9116104034167
   wavelet-LLH_Minimum : -783.0088926440542
   wavelet-LLH_Entropy : 5.278889240243901
   wavelet-LLH_Range : 1516.85940092036
   wavelet-LLH_Variance : 63709.17000171525
   wavelet-LLH_10Percentile : -370.14521874186516
   wavelet-LLH_Kurtosis : 2.6967489992126996
   wavelet-LLH_Mean : 9.941090785026738
   wavelet-HHL_InterquartileRange : 22.380593815902103
   wavelet-HHL_Skewness : 0.12189025030374873
   wavelet-HHL_Uniformity : 0.35870148174363325
   wavelet-HHL_Median : 0.08293864416523505
   wavelet-HHL_Energy : 1537525.5233746145
   wavelet-HHL_RobustMeanAbsoluteDeviation : 9.300989159319672
   wavelet-HHL_MeanAbsoluteDeviation : 14.408696180462384
   wavelet-HHL_TotalEnergy : 6099802.186239617
   wavelet-HHL_Maximum : 96.92755982135392
   wavelet-HHL_RootMeanSquared : 19.278285450581333
   wavelet-HHL_90Percentile : 23.036122247740195
   wavelet-HHL_Minimum : -100.72323160995246
   wavelet-HHL_Entropy : 1.7542276049711516
   wavelet-HHL_Range : 197.6507914313064
   wavelet-HHL_Variance : 371.536288126144
   wavelet-HHL_10Percentile : -22.006202043327146
   wavelet-HHL_Kurtosis : 4.713021547716666
   wavelet-HHL_Mean : 0.3405903521121076
   wavelet-HLL_InterquartileRange : 53.672122004380526
   wavelet-HLL_Skewness : -0.5141660448024011
   wavelet-HLL_Uniformity : 0.16358742557378367
   wavelet-HLL_Median : -2.8172003576358726
   wavelet-HLL_Energy : 9738068.52047006
   wavelet-HLL_RobustMeanAbsoluteDeviation : 22.749753908060928
   wavelet-HLL_MeanAbsoluteDeviation : 35.75394215262929
   wavelet-HLL_TotalEnergy : 38633694.69180624
   wavelet-HLL_Maximum : 186.24612312778368
   wavelet-HLL_RootMeanSquared : 48.51696801898685
   wavelet-HLL_90Percentile : 50.858801790987414
   wavelet-HLL_Minimum : -291.543962260902
   wavelet-HLL_Entropy : 2.9557322085734774
   wavelet-HLL_Range : 477.79008538868567
   wavelet-HLL_Variance : 2328.1166596593844
   wavelet-HLL_10Percentile : -62.825323624959886
   wavelet-HLL_Kurtosis : 5.0993261305473405
   wavelet-HLL_Mean : -5.077354241729555
   wavelet-HLH_InterquartileRange : 44.116682262690155
   wavelet-HLH_Skewness : -0.10963421584646277
   wavelet-HLH_Uniformity : 0.19296918351629522
   wavelet-HLH_Median : -0.7888938095239306
   wavelet-HLH_Energy : 7500010.616793914
   wavelet-HLH_RobustMeanAbsoluteDeviation : 18.832879840663065
   wavelet-HLH_MeanAbsoluteDeviation : 30.641998266064906
   wavelet-HLH_TotalEnergy : 29754680.79172388
   wavelet-HLH_Maximum : 195.25285126676468
   wavelet-HLH_RootMeanSquared : 42.57828637440775
   wavelet-HLH_90Percentile : 48.83999610405644
   wavelet-HLH_Minimum : -254.0726963338062
   wavelet-HLH_Entropy : 2.7550183352722333
   wavelet-HLH_Range : 449.32554760057087
   wavelet-HLH_Variance : 1812.8975907682616
   wavelet-HLH_10Percentile : -48.79736522405574
   wavelet-HLH_Kurtosis : 5.962640061054699
   wavelet-HLH_Mean : -0.1134892629941303
   wavelet-LHL_InterquartileRange : 71.49977707015142
   wavelet-LHL_Skewness : -0.3695385954220589
   wavelet-LHL_Uniformity : 0.12136669796711834
   wavelet-LHL_Median : -4.097211683834559
   wavelet-LHL_Energy : 18447257.204823643
   wavelet-LHL_RobustMeanAbsoluteDeviation : 30.645212155320817
   wavelet-LHL_MeanAbsoluteDeviation : 48.96288225290898
   wavelet-LHL_TotalEnergy : 73185529.68222265
   wavelet-LHL_Maximum : 286.5712199871117
   wavelet-LHL_RootMeanSquared : 66.77642138647703
   wavelet-LHL_90Percentile : 71.57965322911353
   wavelet-LHL_Minimum : -354.8947330376593
   wavelet-LHL_Entropy : 3.404077391894062
   wavelet-LHL_Range : 641.465953024771
   wavelet-LHL_Variance : 4432.098160235003
   wavelet-LHL_10Percentile : -85.64089631106806
   wavelet-LHL_Kurtosis : 4.820466352606455
   wavelet-LHL_Mean : -5.195410758481324
   wavelet-LHH_InterquartileRange : 61.71745143230112
   wavelet-LHH_Skewness : 0.19738213136266408
   wavelet-LHH_Uniformity : 0.1408097883179142
   wavelet-LHH_Median : -1.9400920999742608
   wavelet-LHH_Energy : 13202719.569231834
   wavelet-LHH_RobustMeanAbsoluteDeviation : 26.47232854294366
   wavelet-LHH_MeanAbsoluteDeviation : 41.63688459313146
   wavelet-LHH_TotalEnergy : 52378953.36914481
   wavelet-LHH_Maximum : 279.35038075641216
   wavelet-LHH_RootMeanSquared : 56.49225866143942
   wavelet-LHH_90Percentile : 63.21517068267353
   wavelet-LHH_Minimum : -324.7034536822992
   wavelet-LHH_Entropy : 3.1791866447134405
   wavelet-LHH_Range : 604.0538344387114
   wavelet-LHH_Variance : 3189.2471471516797
   wavelet-LHH_10Percentile : -69.12526990814825
   wavelet-LHH_Kurtosis : 5.104386781839099
   wavelet-LHH_Mean : -1.458815107989458