X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=gdcmPython%2Fdemo%2FvtkGdcmDemo.py;h=a6d14e4d44388c96530b07b31af4c06b17f2205b;hb=8845fe9fca6c1ed22eaaae4dd4561c0ba2f31a6b;hp=142066a1b8d650b999ddb193cc759a735a567998;hpb=297fe0ed9c4b5535b92c36615acff0b059209ed3;p=gdcm.git diff --git a/gdcmPython/demo/vtkGdcmDemo.py b/gdcmPython/demo/vtkGdcmDemo.py index 142066a1..a6d14e4d 100644 --- a/gdcmPython/demo/vtkGdcmDemo.py +++ b/gdcmPython/demo/vtkGdcmDemo.py @@ -1,4 +1,11 @@ -## A small demo that displays with VTK an image parsed with gdcm. +## A small demo that displays with VTK a dicom image parsed with gdcm. +## Warning: the parsing of header of the dicom file is done with gdcm +## but the process of in-memory loading of the image is performed +## by vtkImageReader (classical vtk operator). Since vtkImageReader +## has no special knowledge of Dicom file format, this demo +## will only work for a restrained sub-set of Dicom files (basically +## non compressed and with "HighBit + 1 != BitsStored"). +## When those conditions are not met try using vtkgdcmReader.py... import sys import vtk from gdcmPython import gdcmHeader @@ -172,10 +179,10 @@ if not check.IsReadable(): print "The ", FileName, " file is not " print " readable with gdcm. Sorry." sys.exit() -check = check.GetPubElVal() +check = check.GetPubEntry() try: - BitsAlloc = check["Bits Allocated"] - if len(BitsAlloc) == 0 or BitsAlloc == "gdcm::Unfound": + HighBit = check["High Bit"] + if len(HighBit) == 0 or HighBit == "gdcm::Unfound": raise KeyError except KeyError: print "Gdcm couldn't find the Bits Allocated Dicom tag in file ", FileName @@ -187,9 +194,12 @@ try: except KeyError: print "Gdcm couldn't find the Bits Stored Dicom tag in file ", FileName sys.exit() -if BitsAlloc != BitsStored: +if int(HighBit) + 1 != int(BitsStored): print "vtkImageReader cannot read the file ", FileName - print " because the Bits Allocated and the Bits stored don't match." + print " because the High Bit is offseted from the BitsStored." + print " You should consider using vtkGdcmReader as opposed to the" + print " vtkImageReader python class present in this demo. Please" + print " see gdcmPython/demo/vtkGdcmReader.py for a demo." sys.exit() ### Display in a vtk RenderWindow