1
14
15"""
16Usage:
17
18 python NewSequence.py input.dcm output.dcm
19
20
21Thanks to Robert Irie for code
22"""
23
24import sys
25import gdcm
26
27if __name__ == "__main__":
28
29 file1 = sys.argv[1]
30 file2 = sys.argv[2]
31
33 r.SetFileName( file1 )
34 if not r.Read():
35 sys.exit(1)
36
37 f = r.GetFile()
38 ds = f.GetDataSet()
39
40
41
43 de.SetByteStringValue("Occupation")
45
46
48 it.SetVLToUndefined()
49
50 nds=it.GetNestedDataSet()
51 nds.Insert(de)
52
53
55 sq.SetLengthToUndefined()
56 sq.AddItem(it)
57
58
61 des.SetValue(sq.__ref__())
62 des.SetVLToUndefined()
63
64 ds.Insert(des)
65
67 w.SetFile( f )
68 w.SetFileName( file2 )
69 if not w.Write():
70 sys.exit(1)
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
Class to represent an Item.
Definition gdcmItem.h:46
Reader ala DOM (Document Object Model)
Definition gdcmReader.h:54
Class to represent a Sequence Of Items.
Definition gdcmSequenceOfItems.h:40
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
VR class.
Definition gdcmVR.h:55
Writer ala DOM (Document Object Model)
Definition gdcmWriter.h:49