GDCM 3.2.1

AddPrivateAttribute.py
1
14
15"""
16 Usage:
17
18 python AddPrivateAttribute.py input.dcm output.dcm
19
20
21"""
22
23 import sys
24 import gdcm
25
26 if __name__ == "__main__":
27
28 file1 = sys.argv[1]
29 file2 = sys.argv[2]
30
31 r = gdcm.Reader()
32 r.SetFileName( file1 )
33 if not r.Read():
34 sys.exit(1)
35
36 f = r.GetFile()
37 ds = f.GetDataSet()
38
39 # Create a dataelement
40 de = gdcm.DataElement(gdcm.Tag(0x0051, 0x1011))
41 de.SetByteStringValue("p2")
42 de.SetVR(gdcm.VR(gdcm.VR.SH))
43
44 ds.Insert(de)
45
46 w = gdcm.Writer()
47 w.SetFile( f )
48 w.SetFileName( file2 )
49 if not w.Write():
50 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