Why I can get minus value about first order mean or min.

36 views
Skip to first unread message

tatsuaki

unread,
Nov 3, 2019, 9:54:51 AM11/3/19
to pyradiomics
Hi, please help.
I do following script using lung2 sample.
I can not understand why mean value or min value are minus ??

My environment is,
ubuntu 18.04
Chrome and Google Colaboratory
pyradiomics latest (2019/11/3)

# get sample data as SimpleITK image
imageName, maskName = getTestCase('lung2')
image = sitk.ReadImage(imageName)
mask = sitk.ReadImage(maskName)

#extract one image(this case 25 image slice)
image = sitk.GetArrayFromImage(image)[24]
mask = sitk.GetArrayFromImage(mask)[24]
image = np.expand_dims(image, axis=0)
mask = np.expand_dims(mask, axis=0)

print(image.shape)
print(mask.shape)
#(1, 512, 512)
#(1, 512, 512)

# re-create as 2D single image SimpleITK Image instance
image = sitk.GetImageFromArray(image)
mask = sitk.GetImageFromArray(mask)

# defined settings
settings = {}
settings['binWidth'] = 25
settings['resampledPixelSpacing'] = None 
settings['interpolator'] = sitk.sitkBSpline
settings['label'] = 1

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

print('Calculating first order features...')
results = firstOrderFeatures.execute()
print('done')

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

My result;

Calculating first order features... done Calculated first order features: 10Percentile : -160.0 -> ?? 90Percentile : 61.0 Energy : 34147489.0 Entropy : 2.8876954173868135 InterquartileRange : 50.0 Kurtosis : 7.9737236022955535 Maximum : 105.0 MeanAbsoluteDeviation : 74.6507688484824 Mean : -3.0479159829340334 -> ?? Median : 41.0 Minimum : -569.0 -> ?? Range : 674.0 RobustMeanAbsoluteDeviation : 35.70272940607587 RootMeanSquared : 105.86274714931903 Skewness : -2.2815269999743983 -> ?? TotalEnergy : 34147489.0 Uniformity : 0.24640860626898856 Variance : 11197.63144216163

This sample nrrd file is near raw format, so, I do not think these value are HU(CT value).
How do you think ? What I should do ?

tatsuaki

tatsuaki

unread,
Nov 13, 2019, 6:14:41 PM11/13/19
to pyradiomics
Hi,

I find solution...(this was my mistake).
First, I checked lung2.nrrd using java program when did extract features,
so, all pixels automatically converted to signed value(-32768 〜 32767).
I misunderstand that I think these pixel values are correct.

For now, I can see lung2.nrrd images correctly.

Thanks.

tatsuaki


2019年11月3日日曜日 23時54分51秒 UTC+9 tatsuaki:

Joost van Griethuysen

unread,
Nov 14, 2019, 4:05:41 AM11/14/19
to pyradiomics
Hi,

1) HU values are, by definition, in the range [-1000, 4000], so negative values is quite OK.
2) You extract a single slice, but forget to copy over the geometric information! (image.CopyInformation(ref_image)) This is important to do, as it contains additional information on the spacing, orientation and origin, which is used during pre-processing and calculation of shape features! Moreover, in this case it may throw errors, as your size is different. An alternative would be to use SimpleITK functionality to select the correct slice (SimpleITK.ExtractImageFilter or SimpleITK.SliceImageFilter)

Regards,

Joost

Op donderdag 14 november 2019 00:14:41 UTC+1 schreef tatsuaki:

Visionary Imaging Services .

unread,
Nov 14, 2019, 6:26:49 AM11/14/19
to Joost van Griethuysen, pyradiomics
Thanks, Dr.Joost.

1) HU values are, by definition, in the range [-1000, 4000], so negative values is quite OK.

I think so too. I understood. water = 0, air = -1000.
In my case, when I checked lung2.nrrd, I was using java program.
My java program treat image as "signed(no unsigned)" image, so this was occured shift each pixel value -32768.
So, I was confused. sorry.
Now, I can see lung2 images correctly.
 
2) You extract a single slice, but forget to copy over the geometric information! (image.CopyInformation(ref_image)) This is important to do, as it contains additional information on the spacing, orientation and origin, which is used during pre-processing and calculation of shape features! Moreover, in this case it may throw errors, as your size is different. An alternative would be to use SimpleITK functionality to select the correct slice (SimpleITK.ExtractImageFilter or SimpleITK.SliceImageFilter)

Thank you for your help, these your suggested points are very important.
I fixed script,

# load lung2
imageName, maskName = getTestCase('lung2')
ref_imageStack = sitk.ReadImage(imageName)
ref_maskStack = sitk.ReadImage(maskName)

# choose slice(in this case 25 slice) and change to ndarray (for example, show image or calculate pixels purpose...)
ndimage = sitk.GetArrayFromImage(ref_imageStack)[24]
ndmask = sitk.GetArrayFromImage(ref_maskStack)[24]

# back to sitk image
image = sitk.GetImageFromArray(ndimage)
mask = sitk.GetImageFromArray(ndmask)

# copy geometric/calibration info
image.CopyInformation(ref_imageStack[:,:,24])
mask.CopyInformation(ref_maskStack[:,:,24])

# validate image and mask...
bb, correctedMask = imageoperations.checkMask(image, mask)
if correctedMask is not None:
  mask = correctedMask
image, mask = imageoperations.cropToTumorMask(image, mask, bb)

...continue

Thanks.

tatsuaki

-------------------------------------------
Visionary Imaging Services, Inc.
Tatsuaki Kobayashi
-------------------------------------------


2019年11月14日(木) 18:05 Joost van Griethuysen <j.v.gri...@nki.nl>:
--
You received this message because you are subscribed to the Google Groups "pyradiomics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyradiomics...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyradiomics/e0787b00-4b15-4bd0-b89a-814349e566bf%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages