Esempio n. 1
0
    def enableImageTypeByName(self, imageType, enabled=True, customArgs=None):
        r"""
    Enable or disable specified image type. If enabling image type, optional custom settings can be specified in
    customArgs.

    Current possible image types are:

    - Original: No filter applied
    - Wavelet: Wavelet filtering, yields 8 decompositions per level (all possible combinations of applying either
      a High or a Low pass filter in each of the three dimensions.
      See also :py:func:`~radiomics.imageoperations.getWaveletImage`
    - LoG: Laplacian of Gaussian filter, edge enhancement filter. Emphasizes areas of gray level change, where sigma
      defines how coarse the emphasised texture should be. A low sigma emphasis on fine textures (change over a
      short distance), where a high sigma value emphasises coarse textures (gray level change over a large distance).
      See also :py:func:`~radiomics.imageoperations.getLoGImage`
    - Square: Takes the square of the image intensities and linearly scales them back to the original range.
      Negative values in the original image will be made negative again after application of filter.
    - SquareRoot: Takes the square root of the absolute image intensities and scales them back to original range.
      Negative values in the original image will be made negative again after application of filter.
    - Logarithm: Takes the logarithm of the absolute intensity + 1. Values are scaled to original range and
      negative original values are made negative again after application of filter.
    - Exponential: Takes the the exponential, where filtered intensity is e^(absolute intensity). Values are
      scaled to original range and negative original values are made negative again after application of filter.
    - Gradient: Returns the gradient magnitude.
    - LBP2D: Calculates and returns a local binary pattern applied in 2D.
    - LBP3D: Calculates and returns local binary pattern maps applied in 3D using spherical harmonics. Last returned
      image is the corresponding kurtosis map.

    For the mathmetical formulas of square, squareroot, logarithm and exponential, see their respective functions in
    :ref:`imageoperations<radiomics-imageoperations-label>`
    (:py:func:`~radiomics.imageoperations.getSquareImage`,
    :py:func:`~radiomics.imageoperations.getSquareRootImage`,
    :py:func:`~radiomics.imageoperations.getLogarithmImage`,
    :py:func:`~radiomics.imageoperations.getExponentialImage`,
    :py:func:`~radiomics.imageoperations.getGradientImage`,
    :py:func:`~radiomics.imageoperations.getLBP2DImage` and
    :py:func:`~radiomics.imageoperations.getLBP3DImage`,
    respectively).
    """
        global logger

        if imageType not in getImageTypes():
            logger.warning('Image type %s is not recognized', imageType)
            return

        if enabled:
            if customArgs is None:
                customArgs = {}
                logger.debug(
                    'Enabling image type %s (no additional custom settings)',
                    imageType)
            else:
                logger.debug(
                    'Enabling image type %s (additional custom settings: %s)',
                    imageType, customArgs)
            self.enabledImagetypes[imageType] = customArgs
        elif imageType in self.enabledImagetypes:
            logger.debug('Disabling image type %s', imageType)
            del self.enabledImagetypes[imageType]
        logger.debug('Enabled images types: %s', self.enabledImagetypes)
Esempio n. 2
0
 def enableAllImageTypes(self):
     """
 Enable all possible image types without any custom settings.
 """
     self.logger.debug('Enabling all image types')
     for imageType in getImageTypes():
         self._enabledImagetypes[imageType] = {}
     self.logger.debug('Enabled images types: %s', self._enabledImagetypes)
import pywt
import six

from radiomics import getFeatureClasses, getImageTypes

featureClasses = getFeatureClasses()
imageTypes = getImageTypes()


def checkWavelet(value, rule_obj, path):
    if not isinstance(value, six.string_types):
        raise TypeError('Wavelet not expected type (str)')
    wavelist = pywt.wavelist()
    if value not in wavelist:
        raise ValueError('Wavelet "%s" not available in pyWavelets %s' %
                         (value, wavelist))
    return True


def checkInterpolator(value, rule_obj, path):
    if value is None:
        return True
    if isinstance(value, six.string_types):
        enum = {
            'sitkNearestNeighbor', 'sitkLinear', 'sitkBSpline', 'sitkGaussian',
            'sitkLabelGaussian', 'sitkHammingWindowedSinc',
            'sitkCosineWindowedSinc', 'sitkWelchWindowedSinc',
            'sitkLanczosWindowedSinc', 'sitkBlackmanWindowedSinc'
        }
        if value not in enum:
            raise ValueError(