2020
2121#include < string>
2222#include < unordered_set>
23+ #include " itkGDCMImageIO.h"
2324
24- using Tags = std::unordered_set<std::string>;
25+ using TagKey = std::string;
26+ using TagKeys = std::unordered_set<TagKey>;
27+ using TagNames = std::unordered_map<TagKey, std::string>;
28+ using TagMap = TagNames; // TagKey -> TagValue
2529
26- const Tags PATIENT_TAGS = {
27- " 0010|0010" , // Patient's Name
28- " 0010|0020" , // Patient ID
29- " 0010|0030" , // Patient's Birth Date
30- " 0010|0040" , // Patient's Sex
31- " 0010|1010" , // Patient's Age
32- " 0010|1030" , // Patient's Weight
33- " 0010|21b0" , // Additional Patient's History
30+ // Tag names from https://docs.aws.amazon.com/healthimaging/latest/devguide/reference-dicom-support.html
31+ const TagNames PATIENT_TAG_NAMES = {
32+ // Patient Module Elements
33+ {" 0010|0010" , " Patient's Name" },
34+ {" 0010|0020" , " Patient ID" },
35+ // Issuer of Patient ID Macro Elements
36+ {" 0010|0021" , " Issuer of Patient ID" },
37+ {" 0010|0024" , " Issuer of Patient ID Qualifiers Sequence" },
38+ {" 0010|0022" , " Type of Patient ID" },
39+ {" 0010|0030" , " Patient's Birth Date" },
40+ {" 0010|0033" , " Patient's Birth Date in Alternative Calendar" },
41+ {" 0010|0034" , " Patient's Death Date in Alternative Calendar" },
42+ {" 0010|0035" , " Patient's Alternative Calendar Attribute" },
43+ {" 0010|0040" , " Patient's Sex" },
44+ {" 0010|1100" , " Referenced Patient Photo Sequence" },
45+ {" 0010|0200" , " Quality Control Subject" },
46+ {" 0008|1120" , " Referenced Patient Sequence" },
47+ {" 0010|0032" , " Patient's Birth Time" },
48+ {" 0010|1002" , " Other Patient IDs Sequence" },
49+ {" 0010|1001" , " Other Patient Names" },
50+ {" 0010|2160" , " Ethnic Group" },
51+ {" 0010|4000" , " Patient Comments" },
52+ {" 0010|2201" , " Patient Species Description" },
53+ {" 0010|2202" , " Patient Species Code Sequence Attribute" },
54+ {" 0010|2292" , " Patient Breed Description" },
55+ {" 0010|2293" , " Patient Breed Code Sequence" },
56+ {" 0010|2294" , " Breed Registration Sequence Attribute" },
57+ {" 0010|0212" , " Strain Description" },
58+ {" 0010|0213" , " Strain Nomenclature Attribute" },
59+ {" 0010|0219" , " Strain Code Sequence" },
60+ {" 0010|0218" , " Strain Additional Information Attribute" },
61+ {" 0010|0216" , " Strain Stock Sequence" },
62+ {" 0010|0221" , " Genetic Modifications Sequence Attribute" },
63+ {" 0010|2297" , " Responsible Person" },
64+ {" 0010|2298" , " Responsible Person Role Attribute" },
65+ {" 0010|2299" , " Responsible Organization" },
66+ {" 0012|0062" , " Patient Identity Removed" },
67+ {" 0012|0063" , " De-identification Method" },
68+ {" 0012|0064" , " De-identification Method Code Sequence" },
69+ // Patient Group Macro Elements
70+ {" 0010|0026" , " Source Patient Group Identification Sequence" },
71+ {" 0010|0027" , " Group of Patients Identification Sequence" },
72+ // Clinical Trial Subject Module
73+ {" 0012|0010" , " Clinical Trial Sponsor Name" },
74+ {" 0012|0020" , " Clinical Trial Protocol ID" },
75+ {" 0012|0021" , " Clinical Trial Protocol Name Attribute" },
76+ {" 0012|0030" , " Clinical Trial Site ID" },
77+ {" 0012|0031" , " Clinical Trial Site Name" },
78+ {" 0012|0040" , " Clinical Trial Subject ID" },
79+ {" 0012|0042" , " Clinical Trial Subject Reading ID" },
80+ {" 0012|0081" , " Clinical Trial Protocol Ethics Committee Name" },
81+ {" 0012|0082" , " Clinical Trial Protocol Ethics Committee Approval Number" },
3482};
3583
36- const Tags STUDY_TAGS = {
37- " 0020|000D" , // Study Instance UID
38- " 0008|0020" , // Study Date
39- " 0008|0030" , // Study Time
40- " 0008|1030" , // Study Description
41- " 0008|0050" , // Accession Number
84+ const TagNames STUDY_TAG_NAMES = {
85+ // General Study Module
86+ {" 0020|000d" , " Study Instance UID" },
87+ {" 0008|0020" , " Study Date" },
88+ {" 0008|0030" , " Study Time" },
89+ {" 0008|0090" , " Referring Physician's Name" },
90+ {" 0008|0096" , " Referring Physician Identification Sequence" },
91+ {" 0008|009c" , " Consulting Physician's Name" },
92+ {" 0008|009d" , " Consulting Physician Identification Sequence" },
93+ {" 0020|0010" , " Study ID" },
94+ {" 0008|0050" , " Accession Number" },
95+ {" 0008|0051" , " Issuer of Accession Number Sequence" },
96+ {" 0008|1030" , " Study Description" },
97+ {" 0008|1048" , " Physician(s) of Record" },
98+ {" 0008|1049" , " Physician(s) of Record Identification Sequence" },
99+ {" 0008|1060" , " Name of Physician(s) Reading Study" },
100+ {" 0008|1062" , " Physician(s) Reading Study Identification Sequence" },
101+ {" 0032|1033" , " Requesting Service" },
102+ {" 0032|1034" , " Requesting Service Code Sequence" },
103+ {" 0008|1110" , " Referenced Study Sequence" },
104+ {" 0008|1032" , " Procedure Code Sequence" },
105+ {" 0040|1012" , " Reason For Performed Procedure Code Sequence" },
106+ // Patient Study Module
107+ {" 0008|1080" , " Admitting Diagnoses Description" },
108+ {" 0008|1084" , " Admitting Diagnoses Code Sequence" },
109+ {" 0010|1010" , " Patient's Age" },
110+ {" 0010|1020" , " Patient's Size" },
111+ {" 0010|1030" , " Patient's Weight" },
112+ {" 0010|1022" , " Patient's Body Mass Index" },
113+ {" 0010|1023" , " Measured AP Dimension" },
114+ {" 0010|1024" , " Measured Lateral Dimension" },
115+ {" 0010|1021" , " Patient's Size Code Sequence" },
116+ {" 0010|2000" , " Medical Alerts" },
117+ {" 0010|2110" , " Allergies" },
118+ {" 0010|21a0" , " Smoking Status" },
119+ {" 0010|21c0" , " Pregnancy Status" },
120+ {" 0010|21d0" , " Last Menstrual Date" },
121+ {" 0038|0500" , " Patient State" },
122+ {" 0010|2180" , " Occupation" },
123+ {" 0010|21b0" , " Additional Patient History" },
124+ {" 0038|0010" , " Admission ID" },
125+ {" 0038|0014" , " Issuer of Admission ID Sequence" },
126+ {" 0032|1066" , " Reason for Visit" },
127+ {" 0032|1067" , " Reason for Visit Code Sequence" },
128+ {" 0038|0060" , " Service Episode ID" },
129+ {" 0038|0064" , " Issuer of Service Episode ID Sequence" },
130+ {" 0038|0062" , " Service Episode Description" },
131+ {" 0010|2203" , " Patient's Sex Neutered" },
132+ // Clinical Trial Study Module
133+ {" 0012|0050" , " Clinical Trial Time Point ID" },
134+ {" 0012|0051" , " Clinical Trial Time Point Description" },
135+ {" 0012|0052" , " Longitudinal Temporal Offset from Event" },
136+ {" 0012|0053" , " Longitudinal Temporal Event Type" },
137+ {" 0012|0083" , " Consent for Clinical Trial Use Sequence" },
42138};
43139
44- const Tags SERIES_TAGS = {
45- " 0020|000e" , // Series Instance UID
46- " 0008|103e" , // Series Description
47- " 0008|0060" , // Modality
140+ const TagNames SERIES_TAG_NAMES = {
141+ // General Series Module
142+ {" 0008|0060" , " Modality" },
143+ {" 0020|000e" , " Series Instance UID" },
144+ {" 0020|0011" , " Series Number" },
145+ {" 0020|0060" , " Laterality" },
146+ {" 0008|0021" , " Series Date" },
147+ {" 0008|0031" , " Series Time" },
148+ {" 0008|1050" , " Performing Physician's Name" },
149+ {" 0008|1052" , " Performing Physician Identification Sequence" },
150+ {" 0018|1030" , " Protocol Name" },
151+ {" 0008|103e" , " Series Description" },
152+ {" 0008|103f" , " Series Description Code Sequence" },
153+ {" 0008|1070" , " Operators' Name" },
154+ {" 0008|1072" , " Operator Identification Sequence" },
155+ {" 0008|1111" , " Referenced Performed Procedure Step Sequence" },
156+ {" 0008|1250" , " Related Series Sequence" },
157+ {" 0018|0015" , " Body Part Examined" },
158+ {" 0018|5100" , " Patient Position" },
159+ {" 0028|0108" , " Smallest Pixel Value in Series" },
160+ {" 0028|0109" , " Largest Pixel Value in Series" },
161+ {" 0040|0275" , " Request Attributes Sequence" },
162+ {" 0010|2210" , " Anatomical Orientation Type" },
163+ {" 300a|0700" , " Treatment Session UID" },
164+ // Clinical Trial Series Module
165+ {" 0012|0060" , " Clinical Trial Coordinating Center Name" },
166+ {" 0012|0071" , " Clinical Trial Series ID" },
167+ {" 0012|0072" , " Clinical Trial Series Description" },
168+ // General Equipment Module
169+ {" 0008|0070" , " Manufacturer" },
170+ {" 0008|0080" , " Institution Name" },
171+ {" 0008|0081" , " Institution Address" },
172+ {" 0008|1010" , " Station Name" },
173+ {" 0008|1040" , " Institutional Department Name" },
174+ {" 0008|1041" , " Institutional Department Type Code Sequence" },
175+ {" 0008|1090" , " Manufacturer's Model Name" },
176+ {" 0018|100b" , " Manufacturer's Device Class UID" },
177+ {" 0018|1000" , " Device Serial Number" },
178+ {" 0018|1020" , " Software Versions" },
179+ {" 0018|1008" , " Gantry ID" },
180+ {" 0018|100a" , " UDI Sequence" },
181+ {" 0018|1002" , " Device UID" },
182+ {" 0018|1050" , " Spatial Resolution" },
183+ {" 0018|1200" , " Date of Last Calibration" },
184+ {" 0018|1201" , " Time of Last Calibration" },
185+ {" 0028|0120" , " Pixel Padding Value" },
186+ // Frame of Reference Module
187+ {" 0020|0052" , " Frame of Reference UID" },
188+ {" 0020|1040" , " Position Reference Indicator" },
48189};
49190
50- const Tags NON_INSTANCE_TAGS = {
51- " 0010|0010" , // Patient's Name
52- " 0010|0020" , // Patient ID
53- " 0010|0030" , // Patient's Birth Date
54- " 0010|0040" , // Patient's Sex
55- " 0010|1010" , // Patient's Age
56- " 0010|1030" , // Patient's Weight
57- " 0010|21b0" , // Additional Patient's History
58- " 0020|000D" , // Study Instance UID
59- " 0008|0020" , // Study Date
60- " 0008|0030" , // Study Time
61- " 0008|1030" , // Study Description
62- " 0008|0050" , // Accession Number
63- " 0020|000e" , // Series Instance UID
64- " 0008|103e" , // Series Description
65- " 0008|0060" , // Modality
66- };
191+ TagMap extractAndRename (const TagMap &tags, const TagNames &keeperTags)
192+ {
193+ TagMap extracted;
194+ for (const auto &[key, name] : keeperTags)
195+ {
196+ const auto it = tags.find (key);
197+ if (it != tags.end ())
198+ {
199+ extracted[name] = it->second ;
200+ }
201+ }
202+ return extracted;
203+ }
204+
205+ TagMap remove (const TagMap &tags, const TagNames &removeTags)
206+ {
207+ TagMap filteredTags = tags;
208+ for (const auto &[key, name] : removeTags)
209+ {
210+ filteredTags.erase (key);
211+ }
212+ return filteredTags;
213+ }
214+
215+ TagMap relabel (const TagMap &tags)
216+ {
217+ TagMap relabelTags;
218+ for (const auto &[key, value] : tags)
219+ {
220+ std::string name = key;
221+ if (itk::GDCMImageIO::GetLabelFromTag (key, name))
222+ {
223+ relabelTags[name] = value;
224+ }
225+ else
226+ {
227+ relabelTags[key] = value;
228+ }
229+ }
230+ return relabelTags;
231+ }
67232
68233#endif // TAGS_H
0 commit comments