Skip to content

Commit

Permalink
Merge pull request #364 from JoostJM/imagetype-bug
Browse files Browse the repository at this point in the history
Update the validation rule for image types
  • Loading branch information
JoostJM authored Mar 21, 2018
2 parents 62b3cbd + 665e9bc commit 38c3fb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
12 changes: 3 additions & 9 deletions radiomics/schemas/paramSchema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,7 @@ mapping:

imageType:
type: map
func: checkImageType
matching-rule: 'any'
mapping:
# possible image types, it's value is a dictionary (holding image type specific settings) that follows the rules
# as in 'setting'
Original: *settings
LoG: *settings
Wavelet: *settings
Square: *settings
SquareRoot: *settings
Logarithm: *settings
Exponential: *settings
regex;(.+): *settings
16 changes: 15 additions & 1 deletion radiomics/schemas/schemaFuncs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pywt
import six

from radiomics import getFeatureClasses
from radiomics import getFeatureClasses, getImageTypes

featureClasses = getFeatureClasses()
imageTypes = getImageTypes()

def checkWavelet(value, rule_obj, path):
if not isinstance(value, six.string_types):
Expand Down Expand Up @@ -66,3 +67,16 @@ def checkFeatureClass(value, rule_obj, path):
raise ValueError('Feature Class %s contains unrecognized features: %s' % (className, str(unrecognizedFeatures)))

return True


def checkImageType(value, rule_obj, path):
global imageTypes
if value is None:
raise TypeError('imageType dictionary cannot be None value')

for im_type in value:
if im_type not in imageTypes:
raise ValueError('Image Type %s is not recognized. Available image types are %s' %
(im_type, imageTypes))

return True

0 comments on commit 38c3fb6

Please sign in to comment.