Skip to content

Commit c4c1b06

Browse files
committed
STYL: Rename signature for available input image types
Functions to yield original and derived images are now found by checking for the signature ("get...Image") in `imageoperations`, where ... is replaced by "Original" or by the filter name (e.g. Wavelet). This more accurately reflects what these functions return (as "Original" isn't a filtered image) and is more similar to the signature used for dynamic enumeration of individual features in each feature class.
1 parent a19fe2b commit c4c1b06

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

radiomics/featureextractor.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ def __init__(self, *args, **kwargs):
9090

9191
def addProvenance(self, provenance_on=True):
9292
"""
93-
Enable or disable reporting of settings used for calculated filters.
94-
By default, settings used are added to the dictionary of calculated features as {"settings_<filter>":<settings>}
93+
Enable or disable reporting of additional information on the extraction. This information includes toolbox version,
94+
enabled input images and applied settings. Furthermore, additional information on the image and region of interest
95+
(ROI) is also provided, including original image spacing, total number of voxels in the ROI and total number of
96+
fully connected volumes in the ROI.
97+
9598
To disable this, call ``addProvenance(False)``
9699
"""
97100
self.provenance_on = provenance_on
@@ -184,16 +187,16 @@ def enableInputImageByName(self, inputImage, enabled=True, customArgs=None):
184187
Enable or disable specified input image. If enabling input image, optional custom settings can be specified in
185188
customArgs.
186189
187-
Current possible filters are:
190+
Current possible input images are:
188191
189192
- Original: No filter applied
190193
- Wavelet: Wavelet filtering, yields 8 decompositions per level (all possible combinations of applying either
191194
a High or a Low pass filter in each of the three dimensions.
192-
See also :py:func:`~radiomics.imageoperations.applyFilterWavelet`
195+
See also :py:func:`~radiomics.imageoperations.getWaveletImage`
193196
- LoG: Laplacian of Gaussian filter, edge enhancement filter. Emphasizes areas of gray level change, where sigma
194197
defines how coarse the emphasised texture should be. A low sigma emphasis on fine textures (change over a
195198
short distance), where a high sigma value emphasises coarse textures (gray level change over a large distance).
196-
See also :py:func:`~radiomics.imageoperations.applyFilterLoG`
199+
See also :py:func:`~radiomics.imageoperations.getLoGImage`
197200
- Square: Takes the square of the image intensities and linearly scales them back to the original range.
198201
Negative values in the original image will be made negative again after application of filter.
199202
- SquareRoot: Takes the square root of the absolute image intensities and scales them back to original range.
@@ -205,10 +208,10 @@ def enableInputImageByName(self, inputImage, enabled=True, customArgs=None):
205208
206209
For the mathmetical formulas of square, squareroot, logarithm and exponential, see their respective functions in
207210
:ref:`imageoperations<radiomics-imageoperations-label>`
208-
(:py:func:`~radiomics.imageoperations.applyFilterSquare`,
209-
:py:func:`~radiomics.imageoperations.applyFilterSquareRoot`,
210-
:py:func:`~radiomics.imageoperations.applyFilterLogarithm` and
211-
:py:func:`~radiomics.imageoperations.applyFilterExponential`,
211+
(:py:func:`~radiomics.imageoperations.getSquareImage`,
212+
:py:func:`~radiomics.imageoperations.getSquareRootImage`,
213+
:py:func:`~radiomics.imageoperations.getLogarithmImage` and
214+
:py:func:`~radiomics.imageoperations.getExponentialImage`,
212215
respectively).
213216
"""
214217
if enabled:
@@ -275,9 +278,9 @@ def execute(self, imageFilepath, maskFilepath, label=None):
275278
Compute radiomics signature for provide image and mask combination.
276279
First, image and mask are loaded and resampled if necessary. Second, if enabled, provenance information is
277280
calculated and stored as part of the result. Next, shape features are calculated on a cropped (no padding) version
278-
of the original image. Then other featureclasses are calculated using all specified filters in inputImages. Images
279-
are cropped to tumor mask (no padding) after application of filter and before being passed to the feature class.
280-
Finally, the dictionary containing all calculated features is returned.
281+
of the original image. Then other featureclasses are calculated using all specified input images in ``inputImages``.
282+
Images are cropped to tumor mask (no padding) after application of any filter and before being passed to the feature
283+
class. Finally, the dictionary containing all calculated features is returned.
281284
282285
:param imageFilepath: SimpleITK Image, or string pointing to image file location
283286
:param maskFilepath: SimpleITK Image, or string pointing to labelmap file location
@@ -324,7 +327,7 @@ def execute(self, imageFilepath, maskFilepath, label=None):
324327
args = self.kwargs.copy()
325328
args.update(customKwargs)
326329
self.logger.info("Applying filter: '%s' with settings: %s" % (imageType, str(args)))
327-
imageGenerators = chain(imageGenerators, eval('imageoperations.applyFilter%s(image, **args)' % (imageType)))
330+
imageGenerators = chain(imageGenerators, eval('imageoperations.get%sImage(image, **args)' % (imageType)))
328331

329332
# Calculate features for all (filtered) images in the generator
330333
for inputImage, inputImageName, inputKwargs in imageGenerators:
@@ -421,11 +424,11 @@ def computeFeatures(self, image, mask, inputImageName, **kwargs):
421424
def getInputImageTypes(cls):
422425
"""
423426
Returns a list of possible input image types. This function finds the image types dynamically by matching the
424-
signature ("applyFilter<filterName>") against functions defined in :ref:`imageoperations
425-
<radiomics-imageoperations-label>`. Returns a list containing available filter names (<filterName> part of the
427+
signature ("get<inputImage>Image") against functions defined in :ref:`imageoperations
428+
<radiomics-imageoperations-label>`. Returns a list containing available input image names (<inputImage> part of the
426429
corresponding function name).
427430
"""
428-
return [member[11:] for member in dir(imageoperations) if member.startswith('applyFilter')]
431+
return [member[3:-5] for member in dir(imageoperations) if member.startswith('get') and member.endswith("Image")]
429432

430433
@classmethod
431434
def getFeatureClasses(cls):

radiomics/imageoperations.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def applyThreshold(inputImage, lowerThreshold, upperThreshold, insideValue=None,
239239
return tif.Execute(inputImage)
240240

241241

242-
def applyFilterOriginal(inputImage, **kwargs):
242+
def getOriginalImage(inputImage, **kwargs):
243243
"""
244244
This function does not apply any filter, but returns the original image. This function is needed to
245245
dyanmically expose the original image as a valid input image.
@@ -249,7 +249,7 @@ def applyFilterOriginal(inputImage, **kwargs):
249249
yield inputImage, "original", kwargs
250250

251251

252-
def applyFilterLoG(inputImage, **kwargs):
252+
def getLoGImage(inputImage, **kwargs):
253253
"""
254254
Apply Laplacian of Gaussian filter to input image and compute signature for each filtered image.
255255
@@ -299,7 +299,7 @@ def applyFilterLoG(inputImage, **kwargs):
299299
logger.warning('applyLoG: sigma must be greater than 0.0: %g', sigma)
300300

301301

302-
def applyFilterWavelet(inputImage, **kwargs):
302+
def getWaveletImage(inputImage, **kwargs):
303303
"""
304304
Apply wavelet filter to image and compute signature for each filtered image.
305305
@@ -446,7 +446,7 @@ def _decompose_k(data, wavelet):
446446
return H, L
447447

448448

449-
def applyFilterSquare(inputImage, **kwargs):
449+
def getSquareImage(inputImage, **kwargs):
450450
r"""
451451
Computes the square of the image intensities.
452452
@@ -468,7 +468,7 @@ def applyFilterSquare(inputImage, **kwargs):
468468
yield im, "square", kwargs
469469

470470

471-
def applyFilterSquareRoot(inputImage, **kwargs):
471+
def getSquareRootImage(inputImage, **kwargs):
472472
r"""
473473
Computes the square root of the absolute value of image intensities.
474474
@@ -493,7 +493,7 @@ def applyFilterSquareRoot(inputImage, **kwargs):
493493
yield im, "squareroot", kwargs
494494

495495

496-
def applyFilterLogarithm(inputImage, **kwargs):
496+
def getLogarithmImage(inputImage, **kwargs):
497497
r"""
498498
Computes the logarithm of the absolute value of the original image + 1.
499499
@@ -519,7 +519,7 @@ def applyFilterLogarithm(inputImage, **kwargs):
519519
yield im, "logarithm", kwargs
520520

521521

522-
def applyFilterExponential(inputImage, **kwargs):
522+
def getExponentialImage(inputImage, **kwargs):
523523
r"""
524524
Computes the exponential of the original image.
525525

0 commit comments

Comments
 (0)