def __init__(self, *args, **kwargs):
        self.logger = logging.getLogger(__name__)

        self.featureClasses = getFeatureClasses()
        self.inputImages = getInputImageTypes()

        self.kwargs = {}
        self.inputImages = {}
        self.enabledFeatures = {}

        if len(args) == 1 and isinstance(args[0], six.string_types):
            self.loadParams(args[0])
        else:
            # Set default settings and update with and changed settings contained in kwargs
            self.kwargs = {
                'normalize': False,
                'normalizeScale': 1,
                'removeOutliers': None,
                'resampledPixelSpacing': None,  # No resampling by default
                'interpolator': sitk.sitkBSpline,
                'padDistance': 5,
                'label': 1,
                'verbose': False,
                'enableCExtensions': True,
                'additionalInfo': True
            }
            self.kwargs.update(kwargs)

            self.inputImages = {'Original': {}}

            self.enabledFeatures = {}
            for featureClassName in self.getFeatureClassNames():
                self.enabledFeatures[featureClassName] = []
Exemple #2
0
 def enableAllInputImages(self):
     """
 Enable all possible input images without any custom settings.
 """
     self.logger.debug('Enabling all input image types')
     for imageType in getInputImageTypes():
         self.inputImages[imageType] = {}
     self.logger.debug('Enabled input images types: %s', self.inputImages)
Exemple #3
0
    def enableInputImageByName(self,
                               inputImage,
                               enabled=True,
                               customArgs=None):
        r"""
    Enable or disable specified input image. If enabling input image, optional custom settings can be specified in
    customArgs.

    Current possible input images 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.

    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` and
    :py:func:`~radiomics.imageoperations.getExponentialImage`,
    respectively).
    """
        if inputImage not in getInputImageTypes():
            self.logger.warning('Input image type %s is not recognized',
                                inputImage)
            return

        if enabled:
            if customArgs is None:
                customArgs = {}
                self.logger.debug(
                    'Enabling input image type %s (no additional custom settings)',
                    inputImage)
            else:
                self.logger.debug(
                    'Enabling input image type %s (additional custom settings: %s)',
                    inputImage, customArgs)
            self.inputImages[inputImage] = customArgs
        elif inputImage in self.inputImages:
            self.logger.debug('Disabling input image type %s', inputImage)
            del self.inputImages[inputImage]
        self.logger.debug('Enabled input images types: %s', self.inputImages)