GDCM: PhilipsPrivateRescaleInterceptSlope.py

GDCM 3.2.11

PhilipsPrivateRescaleInterceptSlope.py
"""
Usage:
python
"""
import gdcm
import sys
filename = sys.argv[1]
tmpfile = "/tmp/philips_rescaled.dcm"
# Need to access some private tags, read the file :
reader = gdcm.Reader()
reader.SetFileName( filename )
if not reader.Read():
sys.exit(1)
ds = reader.GetFile().GetDataSet()
#print ds
# (2005,1409) DS 4 0.0
# (2005,140a) DS 16 1.52283272283272
# (2005,0014) LO 26 Philips MR Imaging DD 005
tag1 = gdcm.PrivateTag(0x2005,0x09,"Philips MR Imaging DD 005")
tag2 = gdcm.PrivateTag(0x2005,0x0a,"Philips MR Imaging DD 005")
print tag1
print tag2
# make sure to do a copy, we want the private tag to remain
# otherwise gdcm gives us a reference
el1 = gdcm.DataElement( ds.GetDataElement( tag1 ) )
print el1
el2 = gdcm.DataElement( ds.GetDataElement( tag2 ) )
print el2
# (0028,1052) DS [-1000] # 6, 1 RescaleIntercept
# (0028,1053) DS [1] # 2, 1 RescaleSlope
el1.SetTag( gdcm.Tag(0x0028,0x1052) )
el2.SetTag( gdcm.Tag(0x0028,0x1053) )
ds.Insert( el1 )
ds.Insert( el2 )
w = gdcm.Writer()
w.SetCheckFileMetaInformation( False )
w.SetFileName( tmpfile )
w.SetFile( reader.GetFile() )
if not w.Write():
sys.exit(1)
print "success"
gdcm::DataElement
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
gdcm::PrivateTag
Class to represent a Private DICOM Data Element (Attribute) Tag (Group, Element, Owner).
Definition gdcmPrivateTag.h:39
gdcm::Reader
Reader ala DOM (Document Object Model).
Definition gdcmReader.h:54
gdcm::Tag
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
gdcm::Writer
Writer ala DOM (Document Object Model).
Definition gdcmWriter.h:49