AddPrivateAttribute.py
"""
Usage:
python AddPrivateAttribute.py input.dcm output.dcm
"""
import sys
import gdcm
if __name__ == "__main__":
file1 = sys.argv[1]
file2 = sys.argv[2]
r = gdcm.Reader()
r.SetFileName( file1 )
if not r.Read():
sys.exit(1)
f = r.GetFile()
ds = f.GetDataSet()
# Create a dataelement
de = gdcm.DataElement(gdcm.Tag(0x0051, 0x1011))
de.SetByteStringValue("p2")
de.SetVR(gdcm.VR(gdcm.VR.SH))
ds.Insert(de)
w = gdcm.Writer()
w.SetFile( f )
w.SetFileName( file2 )
if not w.Write():
sys.exit(1)
gdcm::DataElement
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
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::VR
VR class.
Definition gdcmVR.h:55
gdcm::Writer
Writer ala DOM (Document Object Model).
Definition gdcmWriter.h:49