import gdcm
import sys
filename = sys.argv[1]
tmpfile = "/tmp/philips_rescaled.dcm"
reader = gdcm.Reader()
reader.SetFileName( filename )
if not reader.Read():
sys.exit(1)
ds = reader.GetFile().GetDataSet()
tag1 = gdcm.PrivateTag(0x2005,0x09,"Philips MR Imaging DD 005")
tag2 = gdcm.PrivateTag(0x2005,0x0a,"Philips MR Imaging DD 005")
print tag1
print tag2
el1 = gdcm.DataElement( ds.GetDataElement( tag1 ) )
print el1
el2 = gdcm.DataElement( ds.GetDataElement( tag2 ) )
print el2
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"