<commit_before>from radiomics import firstorder, glcm, preprocessing, shape, rlgl
import SimpleITK as sitk
import sys, os

#testBinWidth = 25 this is the default bin size
#testResampledPixelSpacing = (3,3,3) no resampling for now.

dataDir = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + ".." + os.path.sep + "data"
imageName = str(dataDir + os.path.sep + 'prostate_phantom_subvolume.nrrd')
maskName = str(dataDir + os.path.sep + 'prostate_phantom_subvolume-label.nrrd')


if not os.path.exists(imageName):
  print 'Error: problem finding input image',imageName
  os.exit()
if not os.path.exists(maskName):
  print 'Error: problem finding input image',maskName
  os.exit()

image = sitk.ReadImage(imageName)
mask = sitk.ReadImage(maskName)

#
# Show the first order feature calculations
#
firstOrderFeatures = firstorder.RadiomicsFirstOrder(image,mask)

firstOrderFeatures.enableFeatureByName('MeanIntensity', True)
# firstOrderFeatures.enableAllFeatures()

print 'Will calculate the following first order features: '
for f in firstOrderFeatures.enabledFeatures.keys():
  print '  ',f
  print eval('firstOrderFeatures.get'+f+'FeatureValue.__doc__')

print 'Calculating first order features...',
firstOrderFeatures.calculateFeatures()
print 'done'

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

#
# Show Shape features
#<commit_msg>BUG: fix hard-coded Mean feature name<commit_after>from radiomics import firstorder, glcm, preprocessing, shape, rlgl
import SimpleITK as sitk
import sys, os

#testBinWidth = 25 this is the default bin size
#testResampledPixelSpacing = (3,3,3) no resampling for now.

dataDir = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + ".." + os.path.sep + "data"
imageName = str(dataDir + os.path.sep + 'prostate_phantom_subvolume.nrrd')
maskName = str(dataDir + os.path.sep + 'prostate_phantom_subvolume-label.nrrd')


if not os.path.exists(imageName):
  print 'Error: problem finding input image',imageName
  os.exit()
if not os.path.exists(maskName):
  print 'Error: problem finding input image',maskName
  os.exit()

image = sitk.ReadImage(imageName)
mask = sitk.ReadImage(maskName)

#
# Show the first order feature calculations
#
firstOrderFeatures = firstorder.RadiomicsFirstOrder(image,mask)

firstOrderFeatures.enableFeatureByName('Mean', True)
# firstOrderFeatures.enableAllFeatures()

print 'Will calculate the following first order features: '
for f in firstOrderFeatures.enabledFeatures.keys():
  print '  ',f
  print eval('firstOrderFeatures.get'+f+'FeatureValue.__doc__')

print 'Calculating first order features...',
firstOrderFeatures.calculateFeatures()
print 'done'

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

#
# Show Shape features
#
{'fraction_non_alphanumeric': 0.11555864949530108, 'fraction_numerical': 0.003480682213713888, 'mean_word_length': 5.794326241134752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '75434', 'n_tokens_mistral': 926, 'n_tokens_neox': 906, 'n_words': 235}