GDCM: CreateRAWStorage.py

GDCM 3.2.8

CreateRAWStorage.py
1
14
15"""
16 <uid value="1.2.840.10008.5.1.4.1.1.66" name="Raw Data Storage" type="SOP Class" part="PS 3.4" retired="false"/>
17"""
18
19import gdcm
20import sys,os
21
22if __name__ == "__main__":
23 r = gdcm.Reader()
24 # Will require Testing...
25 dataroot = gdcm.Testing.GetDataRoot()
26 filename = os.path.join( dataroot, '012345.002.050.dcm' )
27 r.SetFileName( filename )
28 r.Read()
29 f = r.GetFile()
30 ds = f.GetDataSet()
31
32 uid = "1.2.840.10008.5.1.4.1.1.66"
33# f = gdcm.File()
34# ds = f.GetDataSet()
35 de = gdcm.DataElement( gdcm.Tag(0x0008,0x0016) )
36 de.SetByteStringValue( uid )
37 vr = gdcm.VR( gdcm.VR.UI )
38 de.SetVR( vr )
39 ds.Replace( de )
40
41 ano = gdcm.Anonymizer()
42 ano.SetFile( r.GetFile() )
43 ano.RemovePrivateTags()
44 ano.RemoveGroupLength()
45 taglist = [
46 gdcm.Tag(0x0008,0x0008),
47 gdcm.Tag(0x0008,0x0022),
48 gdcm.Tag(0x0008,0x0032),
49 gdcm.Tag(0x0008,0x2111),
50 gdcm.Tag(0x0008,0x1150),
51 gdcm.Tag(0x0008,0x1155),
52 gdcm.Tag(0x0008,0x0100),
53 gdcm.Tag(0x0008,0x0102),
54 gdcm.Tag(0x0008,0x0104),
55 gdcm.Tag(0x0040,0xa170),
56 gdcm.Tag(0x0008,0x2112),
57 gdcm.Tag(0x0008,0x0100),
58 gdcm.Tag(0x0008,0x0102),
59 gdcm.Tag(0x0008,0x0104),
60 gdcm.Tag(0x0008,0x9215),
61 gdcm.Tag(0x0018,0x0010),
62 gdcm.Tag(0x0018,0x0022),
63 gdcm.Tag(0x0018,0x0050),
64 gdcm.Tag(0x0018,0x0060),
65 gdcm.Tag(0x0018,0x0088),
66 gdcm.Tag(0x0018,0x0090),
67 gdcm.Tag(0x0018,0x1040),
68 gdcm.Tag(0x0018,0x1100),
69 gdcm.Tag(0x0018,0x1110),
70 gdcm.Tag(0x0018,0x1111),
71 gdcm.Tag(0x0018,0x1120),
72 gdcm.Tag(0x0018,0x1130),
73 gdcm.Tag(0x0018,0x1150),
74 gdcm.Tag(0x0018,0x1151),
75 gdcm.Tag(0x0018,0x1152),
76 gdcm.Tag(0x0018,0x1160),
77 gdcm.Tag(0x0018,0x1190),
78 gdcm.Tag(0x0018,0x1210),
79 gdcm.Tag(0x0020,0x0012),
80 gdcm.Tag(0x0020,0x0032),
81 gdcm.Tag(0x0020,0x0037),
82 gdcm.Tag(0x0020,0x1041),
83 gdcm.Tag(0x0020,0x4000),
84 gdcm.Tag(0x0028,0x0002),
85 gdcm.Tag(0x0028,0x0004),
86 gdcm.Tag(0x0028,0x0010),
87 gdcm.Tag(0x0028,0x0011),
88 gdcm.Tag(0x0028,0x0030),
89 gdcm.Tag(0x0028,0x0100),
90 gdcm.Tag(0x0028,0x0101),
91 gdcm.Tag(0x0028,0x0102),
92 gdcm.Tag(0x0028,0x0103),
93 gdcm.Tag(0x0028,0x1052),
94 gdcm.Tag(0x0028,0x1053),
95 gdcm.Tag(0x0028,0x2110),
96 gdcm.Tag(0x0028,0x2112),
97 gdcm.Tag(0x7fe0,0x0010),
98 gdcm.Tag(0x0018,0x0020),
99 gdcm.Tag(0x0018,0x0021),
100 gdcm.Tag(0x0018,0x0023),
101 gdcm.Tag(0x0018,0x0025),
102 gdcm.Tag(0x0018,0x0080),
103 gdcm.Tag(0x0018,0x0081),
104 gdcm.Tag(0x0018,0x0083),
105 gdcm.Tag(0x0018,0x0084),
106 gdcm.Tag(0x0018,0x0085),
107 gdcm.Tag(0x0018,0x0086),
108 gdcm.Tag(0x0018,0x0087),
109 gdcm.Tag(0x0018,0x0091),
110 gdcm.Tag(0x0018,0x0093),
111 gdcm.Tag(0x0018,0x0094),
112 gdcm.Tag(0x0018,0x0095),
113 gdcm.Tag(0x0018,0x1088),
114 gdcm.Tag(0x0018,0x1090),
115 gdcm.Tag(0x0018,0x1094),
116 gdcm.Tag(0x0018,0x1250),
117 gdcm.Tag(0x0018,0x1251),
118 gdcm.Tag(0x0018,0x1310),
119 gdcm.Tag(0x0018,0x1312),
120 gdcm.Tag(0x0018,0x1314),
121 gdcm.Tag(0x0018,0x1315),
122 gdcm.Tag(0x0018,0x1316),
123 gdcm.Tag(0x0020,0x0110),
124 gdcm.Tag(0x0028,0x0120),
125 gdcm.Tag(0x0028,0x1050),
126 gdcm.Tag(0x0028,0x1051)
127 ]
128 for tag in taglist:
129 #print tag
130 ano.Remove( tag )
131
132 # special handling
133 gen = gdcm.UIDGenerator()
134 ano.Replace( gdcm.Tag(0x0008,0x9123), gen.Generate() )
135 #ano.Empty( gdcm.Tag(0x0040,0x0555) )
136
137
138#
139# uid = gen.Generate()
140# de.SetTag( gdcm.Tag(0x0008,0x0018) )
141# de.SetByteStringValue( uid )
142# ds.Insert( de )
143
144 # init FMI now:
145 #fmi = f.GetHeader()
146 #ts = gdcm.TransferSyntax()
147 #print ts
148 #fmi.SetDataSetTransferSyntax( ts ) # default
149 #print fmi.GetDataSetTransferSyntax()
150 #de.SetTag( gdcm.Tag(0x0002,0x0010) )
151 #uid = "1.2.840.10008.1.2"
152 #de.SetByteStringValue( uid )
153 #fmi.Insert( de )
154# f.SetHeader( r.GetFile().GetHeader() )
155
156 writer = gdcm.Writer()
157 writer.SetFile( ano.GetFile() )
158 writer.SetFileName( "rawstorage.dcm" );
159 writer.Write()
gdcm::Anonymizer
Anonymizer.
Definition gdcmAnonymizer.h:78
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::Testing::GetDataRoot
static const char * GetDataRoot()
Return the GDCM DATA ROOT.
gdcm::UIDGenerator
Class for generating unique UID.
Definition gdcmUIDGenerator.h:28
gdcm::VR
VR class.
Definition gdcmVR.h:55
gdcm::Writer
Writer ala DOM (Document Object Model).
Definition gdcmWriter.h:49