[Insight-users] LabelStatisticsImageFilter's GetValidLabels depends upon volume image type?
Johnson, Hans J
hans-johnson at uiowa.edu
Fri Nov 30 18:18:02 EST 2012
David,
You also have the scalar image and the label image backwards in the "Execute" command.
"temp" is your label image, and it must be integer valued.
"newVol" is your scalar image, and it can be floating point valued.
Hans
From: David Welch <david.m.welch at gmail.com<mailto:david.m.welch at gmail.com>>
Date: Friday, November 30, 2012 5:06 PM
To: "insight-users at itk.org<mailto:insight-users at itk.org>" <insight-users at itk.org<mailto:insight-users at itk.org>>
Cc: Bradley Lowekamp <blowekamp at mail.nih.gov<mailto:blowekamp at mail.nih.gov>>, Hans Johnson <hans-johnson at uiowa.edu<mailto:hans-johnson at uiowa.edu>>, Kent Williams <norman-k-williams at uiowa.edu<mailto:norman-k-williams at uiowa.edu>>
Subject: LabelStatisticsImageFilter's GetValidLabels depends upon volume image type?
Hello all,
I've run into this behavior when reading in a Freesurfer label file that was converted to nifti format (64-bit float):
import SimpleITK as sitk
temp = sitk.ReadImage(label_file)
newVol = sitk.ReadImage(fMRI_single_vol_file)
print temp.GetPixelIDTypeAsString()
print newVol.GetPixelIDTypeAsString()
labelStat1 = sitk.LabelStatisticsImageFilter()
labelStat1.Execute(temp, sitk.Cast(newVol, sitk.sitkUInt16))
labelStat2 = sitk.LabelStatisticsImageFilter()
labelStat2.Execute(temp, sitk.Cast(newVol, sitk.sitkUInt32))
print labelStat1.GetValidLabels()
print "=========================================="
print labelStat2.GetValidLabels()
assert labelStat1.GetValidLabels() == labelStat2.GetValidLabels(), "Valid labels are not the same!"
--------------------------- RESULTS: -------------------------
64-bit float
32-bit float
---------------------------------------------------------------------------AssertionError Traceback (most recent call last)
<ipython-input-19-873f6fd284b8> in <module>() 8 print "==========================================" 9 print labelStat2.GetValidLabels()---> 10 assert labelStat1.GetValidLabels() == labelStat2.GetValidLabels(), "Valid labels are not the same!"AssertionError: Valid labels are not the same!
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 65501, 65502, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535)
==========================================
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 4294967261, 4294967262, 4294967264, 4294967265, 4294967266, 4294967267, 4294967268, 4294967269, 4294967270, 4294967271, 4294967272, 4294967273, 4294967274, 4294967275, 4294967276, 4294967277, 4294967278, 4294967279, 4294967280, 4294967281, 4294967282, 4294967283, 4294967284, 4294967285, 4294967286, 4294967287, 4294967288, 4294967289, 4294967290, 4294967291, 4294967292, 4294967293, 4294967294, 4294967295)
The label values should have a max at ~2350 and the length of the returned lists is LONGER than the length of labels in the label image, so I can't see how this could be caused by my choice of cast type…
If I DON'T cast the image file to a lower bit, I get the error:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-28-605e85d6adb9> in <module>() 3 # statMap1 = labelStat.GetLabelStatisticsMap() 4 labelStat2 = sitk.LabelStatisticsImageFilter()----> 5 labelStat2.Execute(temp, newVol) 6 # statMap2 = labelStat.GetLabelStatisticsMap() 7 print labelStat1.GetValidLabels()/Volumes/scratch/welchdm/bld/latest_BSA/SimpleITK-build/lib/SimpleITK.pyc in Execute(self, *args, **kwargs) 3712 def Execute(self, *args, **kwargs): 3713 """Execute(LabelStatisticsImageFilter self, Image arg2, Image arg3) -> Image"""-> 3714 return _SimpleITK.LabelStatisticsImageFilter_Execute(self, *args, **kwargs) 3715 3716 def GetMinimum(self, *args, **kwargs):RuntimeError: Exception thrown in SimpleITK LabelStatisticsImageFilter_Execute: /Volumes/scratch/welchdm/bld/latest_BSA/SimpleITK/Code/Common/include/sitkDualMemberFunctionFactory.hxx:201:
sitk::ERROR: Pixel type: 64-bit float is not supported in 3D byN3itk6simple26LabelStatisticsImageFilterE
Any idea what is going on here?
Cheers,
Dave Welch
david.m.welch at gmail.com<mailto:david.m.welch at gmail.com>
________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121130/eac2a544/attachment.htm>
More information about the Insight-users
mailing list