Upload 3 files
Browse files- labels.py +393 -0
- masks.py +106 -0
- pos_weights.json +1 -0
labels.py
ADDED
@@ -0,0 +1,393 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
All target labels used in UMIE.
|
3 |
+
|
4 |
+
Each label has a unique id, RadLex name, RadLex id, grade, and source names.
|
5 |
+
Source names are the names of the labels used in the original datasets. They are meant to be helpful when translating labels from new source datasets to RadLex labels.
|
6 |
+
Each of the target labels has a grade, which is an integer value that represents the intensity of the label ranging from 0 to 1.
|
7 |
+
E.g. 0.25 - mild, 0.5 - moderate, 0.75 - severe, 1 - critical. If the grade is not specified, the default value is 1.
|
8 |
+
Here in "grades", we store the information about how many grades the label has.
|
9 |
+
"""
|
10 |
+
|
11 |
+
from dataclasses import dataclass, field
|
12 |
+
from typing import Optional
|
13 |
+
|
14 |
+
|
15 |
+
@dataclass
|
16 |
+
class Label: # Name of the label should match RadLex name
|
17 |
+
"""This class represents a target UMIE label."""
|
18 |
+
|
19 |
+
id: int # Unique id of the label in UMIE
|
20 |
+
radlex_name: str # name of the label in RadLex
|
21 |
+
radlex_id: str # unique id of the label in RadLex
|
22 |
+
grades: Optional[int] = field( # number of grades the label has (possible intensity levels of the label)
|
23 |
+
default_factory=int
|
24 |
+
) # Grades of the label, some datasets come with intesity scale for the labels
|
25 |
+
source_names: Optional[dict] = field(
|
26 |
+
default_factory=dict
|
27 |
+
) # Names used by other datasets, key - dataset name, value - source label name in this dataset
|
28 |
+
|
29 |
+
|
30 |
+
# Use camel case for the labels names
|
31 |
+
# We do not keep vague labels like "other" or "unknown"
|
32 |
+
# One source label may correspond to multiple RadLex labels
|
33 |
+
|
34 |
+
NormalityDecriptor = Label(
|
35 |
+
id=0,
|
36 |
+
radlex_name="NormalityDecriptor",
|
37 |
+
radlex_id="RID29001",
|
38 |
+
source_names={
|
39 |
+
"kits23": ["normal"],
|
40 |
+
"coronahack": ["Normal"],
|
41 |
+
"alzheimers": ["NonDemented"],
|
42 |
+
"covid19_detection": ["normal"],
|
43 |
+
"chestX-ray14": ["No Finding"],
|
44 |
+
"brain_tumor_classification": ["no_tumor"],
|
45 |
+
"brain_with_intracranial_hemorrhage": ["normal"],
|
46 |
+
"brain_tumor_detection": ["N"],
|
47 |
+
"lits": ["NormalityDescriptor"],
|
48 |
+
},
|
49 |
+
)
|
50 |
+
|
51 |
+
Neoplasm = Label(
|
52 |
+
id=1,
|
53 |
+
radlex_name="Neoplasm",
|
54 |
+
radlex_id="RID3957",
|
55 |
+
source_names={
|
56 |
+
"kits23": [
|
57 |
+
"angiomyolipoma",
|
58 |
+
"chromophobe",
|
59 |
+
"clear_cell_papillary_rcc",
|
60 |
+
"clear_cell_rcc",
|
61 |
+
"mest",
|
62 |
+
"multilocular_cystic_rcc",
|
63 |
+
"oncocytoma",
|
64 |
+
"papillary_rcc",
|
65 |
+
"rcc_unclassified",
|
66 |
+
"spindle_cell_neoplasm",
|
67 |
+
"urothelial",
|
68 |
+
"wilms",
|
69 |
+
"other",
|
70 |
+
],
|
71 |
+
"pad_chest": ["adenocarcinoma"],
|
72 |
+
"brain_tumor_detection": ["Y"],
|
73 |
+
"lits": ["Neoplasm"],
|
74 |
+
},
|
75 |
+
)
|
76 |
+
|
77 |
+
RenalAdenocarcinoma = Label(
|
78 |
+
id=2,
|
79 |
+
radlex_name="RenalAdenocarcinoma",
|
80 |
+
radlex_id="RID4234",
|
81 |
+
source_names={
|
82 |
+
"kits23": [
|
83 |
+
"clear_cell_rcc",
|
84 |
+
"chromophobe_rcc",
|
85 |
+
"papillary_rcc",
|
86 |
+
"multilocular_cystic_rcc",
|
87 |
+
"rcc_unclassified",
|
88 |
+
"clear_cell_papillary",
|
89 |
+
],
|
90 |
+
},
|
91 |
+
)
|
92 |
+
|
93 |
+
ClearCellAdenocarcinoma = Label(
|
94 |
+
id=3,
|
95 |
+
radlex_name="ClearCellAdenocarcinoma",
|
96 |
+
radlex_id="RID4235",
|
97 |
+
source_names={"kits23": ["clear_cell_rcc", "clear_cell_papillary"]},
|
98 |
+
)
|
99 |
+
|
100 |
+
ChromophobeAdenocarcinoma = Label(
|
101 |
+
id=4, radlex_name="ChromophobeAdenocarcinoma", radlex_id="RID4236", source_names={"kits23": ["chromophobe_rcc"]}
|
102 |
+
)
|
103 |
+
|
104 |
+
TransitionalCellCarcinoma = Label(
|
105 |
+
id=5,
|
106 |
+
radlex_name="TransitionalCellCarcinoma",
|
107 |
+
radlex_id="",
|
108 |
+
source_names={"kits23": ["transitional_cell_carcinoma"]},
|
109 |
+
)
|
110 |
+
|
111 |
+
PapillaryRenalAdenocarcinoma = Label(
|
112 |
+
id=6,
|
113 |
+
radlex_name="PapillaryRenalAdenocarcinoma",
|
114 |
+
radlex_id="RID4233",
|
115 |
+
source_names={"kits23": ["papillary_rcc", "clear_cell_papillary"]},
|
116 |
+
)
|
117 |
+
|
118 |
+
MultilocularCysticRenalTumor = Label(
|
119 |
+
id=7,
|
120 |
+
radlex_name="MultilocularCysticRenalTumor",
|
121 |
+
radlex_id="RID4538",
|
122 |
+
source_names={"kits23": ["multilocular_cystic_rcc"]},
|
123 |
+
)
|
124 |
+
|
125 |
+
WilmsTumor = Label(id=8, radlex_name="WilmsTumor", radlex_id="RID4553", source_names={"kits23": ["wilms"]})
|
126 |
+
|
127 |
+
Angiomyolipoma = Label(
|
128 |
+
id=9, radlex_name="Angiomyolipoma", radlex_id="RID4343", source_names={"kits23": ["angiomyolipoma"]}
|
129 |
+
)
|
130 |
+
|
131 |
+
Oncocytoma = Label(id=10, radlex_name="Oncocytoma", radlex_id="RID4515", source_names={"kits23": ["oncocytoma"]})
|
132 |
+
|
133 |
+
RenalCyst = Label(id=11, radlex_name="RenalCyst", radlex_id="RID35811", source_names={"kits23": ["cyst"]})
|
134 |
+
|
135 |
+
ViralInfection = Label(
|
136 |
+
id=12,
|
137 |
+
radlex_name="ViralInfection",
|
138 |
+
radlex_id="RID4687",
|
139 |
+
grades=5,
|
140 |
+
source_names={
|
141 |
+
"coronahack": ["PneumoniaVirus"],
|
142 |
+
"MosMedData": ["CT-1", "CT-2", "CT-3", "CT-4"],
|
143 |
+
"covid19_detection": ["pneumonia_viral"],
|
144 |
+
},
|
145 |
+
)
|
146 |
+
|
147 |
+
Pneumonia = Label(
|
148 |
+
id=13,
|
149 |
+
radlex_name="Pneumonia",
|
150 |
+
radlex_id="RID5350",
|
151 |
+
source_names={
|
152 |
+
"coronahack": ["PneumoniaVirus", "PneumoniaBacteria"],
|
153 |
+
"ChestX-ray14": ["Pneumonia"],
|
154 |
+
"PadChest": ["Pneumonia", "atypical pneumonia"],
|
155 |
+
"covid19_detection": ["pneumonia_bacterial", "pneumonia_viral"],
|
156 |
+
},
|
157 |
+
)
|
158 |
+
|
159 |
+
PneumoniaViral = Label(
|
160 |
+
id=14,
|
161 |
+
radlex_name="PneumoniaViral",
|
162 |
+
radlex_id="RID34769",
|
163 |
+
source_names={"coronahack": ["PneumoniaVirus"], "covid19_detection": ["pneumonia_viral"]},
|
164 |
+
)
|
165 |
+
|
166 |
+
Atelectasis = Label(
|
167 |
+
id=15,
|
168 |
+
radlex_name="Atelectasis",
|
169 |
+
radlex_id="RID28493",
|
170 |
+
source_names={"Chest_X-ray_Abnormalities_Detection": ["Atelectasis"], "ChestX-ray14": ["Atelectasis"]},
|
171 |
+
)
|
172 |
+
|
173 |
+
Calcification = Label(
|
174 |
+
id=16,
|
175 |
+
radlex_name="Calcification",
|
176 |
+
radlex_id="RID5196",
|
177 |
+
source_names={"Chest_X-ray_Abnormalities_Detection": ["Calcification"]},
|
178 |
+
)
|
179 |
+
|
180 |
+
BoxlikeHeart = Label(
|
181 |
+
id=17,
|
182 |
+
radlex_name="BoxlikeHeart",
|
183 |
+
radlex_id="RID35057",
|
184 |
+
source_names={"Chest_X-ray_Abnormalities_Detection": ["Cardiomegaly"], "ChestX-ray14": ["Cardiomegaly"]},
|
185 |
+
)
|
186 |
+
|
187 |
+
Consolidation = Label(
|
188 |
+
id=18,
|
189 |
+
radlex_name="Consolidation",
|
190 |
+
radlex_id="RID43255",
|
191 |
+
source_names={
|
192 |
+
"Chest_X-ray_Abnormalities_Detection": ["Consolidation", "Infiltration"],
|
193 |
+
"ChestX-ray14": ["Consolidation", "Infiltration"],
|
194 |
+
},
|
195 |
+
)
|
196 |
+
|
197 |
+
InterstitialLungDisease = Label(
|
198 |
+
id=19,
|
199 |
+
radlex_name="InterstitialLungDisease",
|
200 |
+
radlex_id="RID28799",
|
201 |
+
source_names={"Chest_X-ray_Abnormalities_Detection": ["ILD"]},
|
202 |
+
)
|
203 |
+
|
204 |
+
Opacity = Label(
|
205 |
+
id=20,
|
206 |
+
radlex_name="Opacity",
|
207 |
+
radlex_id="RID28530",
|
208 |
+
source_names={"Chest_X-ray_Abnormalities_Detection": ["Opacity"]},
|
209 |
+
)
|
210 |
+
|
211 |
+
Lesion = Label(
|
212 |
+
id=21,
|
213 |
+
radlex_name="Lesion",
|
214 |
+
radlex_id="RID38780",
|
215 |
+
source_names={
|
216 |
+
"Chest_X-ray_Abnormalities_Detection": ["Nodule/Mass", "Other Lesion"],
|
217 |
+
"ChestX-ray14": ["Mass", "Nodule"],
|
218 |
+
},
|
219 |
+
)
|
220 |
+
|
221 |
+
PleuralEffusion = Label(
|
222 |
+
id=22,
|
223 |
+
radlex_name="PleuralEffusion",
|
224 |
+
radlex_id="RID34539",
|
225 |
+
source_names={"Chest_X-ray_Abnormalities_Detection": ["Effusion"], "ChestX-ray14": ["Effusion"]},
|
226 |
+
)
|
227 |
+
|
228 |
+
Thickening = Label(
|
229 |
+
id=23,
|
230 |
+
radlex_name="Thickening",
|
231 |
+
radlex_id="RID5352",
|
232 |
+
source_names={
|
233 |
+
"Chest_X-ray_Abnormalities_Detection": ["Pleural_Thickening"],
|
234 |
+
"ChestX-ray14": ["Pleural_Thickening"],
|
235 |
+
},
|
236 |
+
)
|
237 |
+
|
238 |
+
Pneumothorax = Label(
|
239 |
+
id=24,
|
240 |
+
radlex_name="Pneumothorax",
|
241 |
+
radlex_id="RID5352",
|
242 |
+
source_names={"Chest_X-ray_Abnormalities_Detection": ["Pneumothorax"], "ChestX-ray14": ["Pneumothorax"]},
|
243 |
+
)
|
244 |
+
|
245 |
+
Fibrosis = Label(
|
246 |
+
id=25,
|
247 |
+
radlex_name="Fibrosis",
|
248 |
+
radlex_id="RID3820",
|
249 |
+
source_names={
|
250 |
+
"Chest_X-ray_Abnormalities_Detection": ["Pulmonary Fibrosis"],
|
251 |
+
"ChestX-ray14": ["Fibrosis"],
|
252 |
+
"PadChest": ["Pulmonary Fibrosis"],
|
253 |
+
},
|
254 |
+
)
|
255 |
+
|
256 |
+
Mass = Label(id=26, radlex_name="Mass", radlex_id="RID3874", source_names={"ChestX-ray14": ["Mass"]})
|
257 |
+
|
258 |
+
PulmonaryEdema = Label(
|
259 |
+
id=27,
|
260 |
+
radlex_name="PulmonaryEdema",
|
261 |
+
radlex_id="RID4866",
|
262 |
+
source_names={"ChestX-ray14": ["Edema"], "PadChest": ["Pulmonary Edema"]},
|
263 |
+
)
|
264 |
+
|
265 |
+
Emphysema = Label(
|
266 |
+
id=28,
|
267 |
+
radlex_name="Emphysema",
|
268 |
+
radlex_id="RID4799",
|
269 |
+
source_names={"ChestX-ray14": ["Emphysema"], "PadChest": ["Emphysema"]},
|
270 |
+
)
|
271 |
+
|
272 |
+
Hernia = Label(id=29, radlex_name="Hernia", radlex_id="RID4895", source_names={"ChestX-ray14": ["Hernia"]})
|
273 |
+
|
274 |
+
ChronicObstructivePulmonaryDisease = Label(
|
275 |
+
id=30,
|
276 |
+
radlex_name="ChronicObstructivePulmonaryDisease",
|
277 |
+
radlex_id="RID5317",
|
278 |
+
source_names={"PadChest": ["COPD signs"]},
|
279 |
+
)
|
280 |
+
|
281 |
+
Tubeculosis = Label(
|
282 |
+
id=31,
|
283 |
+
radlex_name="Tuberculosis",
|
284 |
+
radlex_id="RID29116",
|
285 |
+
source_names={"PadChest": ["Tuberculosis", "Tuberculosis seqelae"]},
|
286 |
+
)
|
287 |
+
|
288 |
+
Metastasis = Label(
|
289 |
+
id=32,
|
290 |
+
radlex_name="Metastasis",
|
291 |
+
radlex_id="RID5231",
|
292 |
+
source_names={"PadChest": ["Lung metastasis", "Bone metastasis"]},
|
293 |
+
)
|
294 |
+
|
295 |
+
Pneumonitis = Label(
|
296 |
+
id=33, radlex_name="Pneumonitis", radlex_id="RID3541", source_names={"PadChest": ["post radiotherapy changes"]}
|
297 |
+
)
|
298 |
+
|
299 |
+
PulmonaryHypertension = Label(
|
300 |
+
id=34,
|
301 |
+
radlex_name="PulmonaryHypertension",
|
302 |
+
radlex_id="RID3299",
|
303 |
+
source_names={"PadChest": ["Pulmonary artery hypertension"]},
|
304 |
+
)
|
305 |
+
|
306 |
+
AdultRespiratoryDistressSyndrome = Label(
|
307 |
+
id=35,
|
308 |
+
radlex_name="AdultRespiratoryDistressSyndrome",
|
309 |
+
radlex_id="RID5319",
|
310 |
+
source_names={"PadChest": ["Respiratory distress syndrome"]},
|
311 |
+
)
|
312 |
+
|
313 |
+
Asbestosis = Label(
|
314 |
+
id=36, radlex_name="Asbestosis", radlex_id="RID5346", source_names={"PadChest": {"Asbestosis signs"}}
|
315 |
+
)
|
316 |
+
|
317 |
+
Carcinomatosis = Label(
|
318 |
+
id=37, radlex_name="Carcinomatosis", radlex_id="RID5231", source_names={"PadChest": ["lymphangitis carcinomatosa"]}
|
319 |
+
)
|
320 |
+
|
321 |
+
Adenocarcinoma = Label(
|
322 |
+
id=38,
|
323 |
+
radlex_name="Adenocarcinoma",
|
324 |
+
radlex_id="RID4226",
|
325 |
+
source_names={
|
326 |
+
"kits23": [
|
327 |
+
"clear_cell_rcc",
|
328 |
+
"chromophobe_rcc",
|
329 |
+
"papillary_rcc",
|
330 |
+
"multilocular_cystic_rcc",
|
331 |
+
"rcc_unclassified",
|
332 |
+
"clear_cell_papillary",
|
333 |
+
],
|
334 |
+
"PadChest": ["adenocarcinoma"],
|
335 |
+
},
|
336 |
+
)
|
337 |
+
|
338 |
+
Glioma = Label(
|
339 |
+
id=39, radlex_name="Glioma", radlex_id="RID4026", source_names={"brain_tumor_classification": ["glioma_tumor"]}
|
340 |
+
)
|
341 |
+
|
342 |
+
Meningioma = Label(
|
343 |
+
id=40,
|
344 |
+
radlex_name="Meningioma",
|
345 |
+
radlex_id="RID4088",
|
346 |
+
source_names={"brain_tumor_classification": ["meningioma_tumor"]},
|
347 |
+
)
|
348 |
+
|
349 |
+
Pituitary = Label(
|
350 |
+
id=41,
|
351 |
+
radlex_name="Pituitary",
|
352 |
+
radlex_id="RID28679",
|
353 |
+
source_names={"brain_tumor_classification": ["pituitary_tumor"]},
|
354 |
+
)
|
355 |
+
|
356 |
+
Osteoarthritis = Label(
|
357 |
+
id=42,
|
358 |
+
radlex_name="Osteoarthritis",
|
359 |
+
radlex_id="RID3555",
|
360 |
+
grades=4,
|
361 |
+
source_names={
|
362 |
+
"knee_osteoarthritis": [
|
363 |
+
"DoubtfulOsteoarthritis",
|
364 |
+
"MinimalOsteoarthritis",
|
365 |
+
"ModerateOsteoarthritis",
|
366 |
+
"SevereOsteoarthritis",
|
367 |
+
]
|
368 |
+
},
|
369 |
+
)
|
370 |
+
|
371 |
+
Hemorrhage = Label(
|
372 |
+
id=43,
|
373 |
+
radlex_name="Hemorrhage",
|
374 |
+
radlex_id="RID4700",
|
375 |
+
source_names={"Brain_with_hemorrhage": ["brain_hemorrhage"]},
|
376 |
+
)
|
377 |
+
|
378 |
+
Dementia = Label(
|
379 |
+
id=44,
|
380 |
+
radlex_name="Dementia",
|
381 |
+
radlex_id="RID5136",
|
382 |
+
grades=3,
|
383 |
+
source_names={"alzheimers": ["VeryMildDemented", "MildDemented", "ModerateDemented"]},
|
384 |
+
)
|
385 |
+
|
386 |
+
HeartFailure = Label(
|
387 |
+
id=45,
|
388 |
+
radlex_name="HeartFailure",
|
389 |
+
radlex_id="RID34795",
|
390 |
+
source_names={"PadChest": ["heart insufficiency"]},
|
391 |
+
)
|
392 |
+
|
393 |
+
all_labels = [obj for name, obj in globals().items() if isinstance(obj, Label)]
|
masks.py
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
This file contains the masks used in the datasets. The masks are defined as mask dataclasses.
|
3 |
+
|
4 |
+
Each mask has the following attributes:
|
5 |
+
- id: int - the id of the mask
|
6 |
+
- radlex_name: str - the name of the mask in RadLex
|
7 |
+
- color: int - the color of the mask
|
8 |
+
- radlex_id: str - the id of the mask in RadLex
|
9 |
+
- source_names: dict - the names of the mask in other datasets, meant to be helpful when translating new source dataset masks to UMIE.
|
10 |
+
"""
|
11 |
+
from dataclasses import dataclass, field
|
12 |
+
from typing import Optional
|
13 |
+
|
14 |
+
|
15 |
+
@dataclass
|
16 |
+
class Mask:
|
17 |
+
"""This class represents a mask."""
|
18 |
+
|
19 |
+
id: int # The unique id of the mask in UMIE (also the value of the mask in the mask image)
|
20 |
+
radlex_name: str # The name of the mask in RadLex
|
21 |
+
color: int # The color of the mask in the mask image
|
22 |
+
radlex_id: str # The id of the mask in RadLex
|
23 |
+
source_names: Optional[dict] = field(
|
24 |
+
default_factory=dict
|
25 |
+
) # How the mask is named in other datasets, key - dataset name, value - source mask name in this dataset
|
26 |
+
|
27 |
+
|
28 |
+
Background = Mask(
|
29 |
+
id=0, radlex_name="Background", color=0, radlex_id=""
|
30 |
+
) # Actually there is no radlex for backgroud ofc but "Normality descriptor" didnt fit either
|
31 |
+
|
32 |
+
Kidney = Mask(
|
33 |
+
id=1, radlex_name="Kidney", color=1, radlex_id="RID205", source_names={"kits23": ["kidney"], "ct_org": ["Kidney"]}
|
34 |
+
)
|
35 |
+
|
36 |
+
Neoplasm = Mask(
|
37 |
+
id=2,
|
38 |
+
radlex_name="Neoplasm",
|
39 |
+
color=2,
|
40 |
+
radlex_id="RID3957",
|
41 |
+
source_names={"kits23": ["kidney tumor"], "brain_tumor_progression": ["Brain tumor"], "lits": ["liver_tumor"]},
|
42 |
+
)
|
43 |
+
RenalCyst = Mask(id=3, radlex_name="RenalCyst", color=3, radlex_id="RID35811", source_names={"kits23": ["cyst"]})
|
44 |
+
ViralInfection = Mask(
|
45 |
+
id=4, radlex_name="ViralInfection", color=4, radlex_id="RID4687", source_names={"mos_med_data": ["CT-1"]}
|
46 |
+
)
|
47 |
+
|
48 |
+
Lung = Mask(
|
49 |
+
id=5,
|
50 |
+
radlex_name="Lung",
|
51 |
+
color=5,
|
52 |
+
radlex_id="RID1301",
|
53 |
+
source_names={
|
54 |
+
"ct_org": ["lungs"],
|
55 |
+
"chest_xray_masks_and_label": ["Lungs"],
|
56 |
+
"finding_and_measuring_lungs": ["lungs"],
|
57 |
+
},
|
58 |
+
)
|
59 |
+
|
60 |
+
BoneOrgan = Mask(id=6, radlex_name="BoneOrgan", color=6, radlex_id="RID13197", source_names={"ct_org": ["Bones"]})
|
61 |
+
|
62 |
+
Liver = Mask(id=7, radlex_name="Liver", color=7, radlex_id="RID58", source_names={"ct_org": ["liver"]})
|
63 |
+
|
64 |
+
UrinaryBladder = Mask(
|
65 |
+
id=8, radlex_name="UrinaryBladder", color=8, radlex_id="RID237", source_names={"ct_org": ["bladder"]}
|
66 |
+
)
|
67 |
+
|
68 |
+
Brain = Mask(id=9, radlex_name="Brain", color=9, radlex_id="RID6434", source_names={"ct_org": ["Brain"]})
|
69 |
+
|
70 |
+
Nodule = Mask(
|
71 |
+
id=10,
|
72 |
+
radlex_name="Nodule",
|
73 |
+
color=10,
|
74 |
+
radlex_id="RID3875",
|
75 |
+
source_names={"lidc_idri": ["Nodule>=3mm", "Nodule<3mm"]},
|
76 |
+
)
|
77 |
+
|
78 |
+
Lesion = Mask(
|
79 |
+
id=11, radlex_name="Lesion", color=11, radlex_id="RID38780", source_names={"lidc_idri": ["Non-nodule>=3mm"]}
|
80 |
+
) # That is not a nodule
|
81 |
+
|
82 |
+
CalciumScore = Mask(
|
83 |
+
id=12,
|
84 |
+
radlex_name="CalciumScore",
|
85 |
+
color=12,
|
86 |
+
radlex_id="RID28808",
|
87 |
+
source_names={"coca": ["coronary_artery_calcium"]},
|
88 |
+
)
|
89 |
+
|
90 |
+
Metastasis = Mask(
|
91 |
+
id=13,
|
92 |
+
radlex_name="Metastasis",
|
93 |
+
color=13,
|
94 |
+
radlex_id="RID5231",
|
95 |
+
source_names={"brain_met_share": ["brain_metastasis"]},
|
96 |
+
)
|
97 |
+
|
98 |
+
Hemorrhage = Mask(
|
99 |
+
id=14,
|
100 |
+
radlex_name="Hemorrhage",
|
101 |
+
color=14,
|
102 |
+
radlex_id="RID4700",
|
103 |
+
source_names={"brain_with_intracranial_hemorrhage": ["brain_hemorrhage"]},
|
104 |
+
)
|
105 |
+
|
106 |
+
all_masks = [obj for name, obj in globals().items() if isinstance(obj, Mask)]
|
pos_weights.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"label_counts": {"NormalityDecriptor": 1.1057690645367633, "Neoplasm": 0.09583273355405211, "RenalAdenocarcinoma": 0.054858642325462566, "ClearCellAdenocarcinoma": 0.04114881613813146, "ChromophobeAdenocarcinoma": 0.00594213132151514, "TransitionalCellCarcinoma": 0, "PapillaryRenalAdenocarcinoma": 0.007627272877682368, "MultilocularCysticRenalTumor": 9.03171775060964e-05, "WilmsTumor": 0, "Angiomyolipoma": 0.0003120739779577222, "Oncocytoma": 0.004200520221444501, "RenalCyst": 0, "ViralInfection": 0.01151410716880852, "Pneumonia": 0.03661655383122769, "PneumoniaViral": 0.01151410716880852, "Atelectasis": 0.04981275506466307, "Calcification": 0, "BoxlikeHeart": 0.011526707414297104, "Consolidation": 0.11212662122740781, "InterstitialLungDisease": 0, "Opacity": 0, "Lesion": 0.052325104213913905, "PleuralEffusion": 0.05782683648080038, "Thickening": 0.014091073710677162, "Pneumothorax": 0.022248705445939255, "Fibrosis": 0.0069691884161010575, "Mass": 0.024311891887346213, "PulmonaryEdema": 0.009543938169536479, "Emphysema": 0.010435850214855739, "Hernia": 0.0009326940065165316, "ChronicObstructivePulmonaryDisease": 0, "Tuberculosis": 0, "Metastasis": 0, "Pneumonitis": 0, "PulmonaryHypertension": 0, "AdultRespiratoryDistressSyndrome": 0, "Asbestosis": 0, "Carcinomatosis": 0, "Adenocarcinoma": 0.054858642325462566, "Glioma": 0.0038156929644555426, "Meningioma": 0.003861194786356837, "Pituitary": 0.003712295071835588, "Osteoarthritis": 0.024945409565001537, "Hemorrhage": 0.002617585565414945, "Dementia": 0.013310705134604505, "HeartFailure": 0}, "mask_counts": {"Background": 0, "Kidney": 0.1532667717638816, "Neoplasm": 0.08602303933806484, "RenalCyst": 0.019574688926928693, "ViralInfection": 0, "Lung": 0.001097225703847687, "BoneOrgan": 0, "Liver": 0.08524893973413165, "UrinaryBladder": 0, "Brain": 0, "Nodule": 0, "Lesion": 0, "CalciumScore": 0.015244842675557408, "Metastasis": 0, "Hemorrhage": 0.002617585565414945}, "label_counts_list": [1.1057690645367633, 0.09583273355405211, 0.054858642325462566, 0.04114881613813146, 0.00594213132151514, 0, 0.007627272877682368, 9.03171775060964e-05, 0, 0.0003120739779577222, 0.004200520221444501, 0, 0.01151410716880852, 0.03661655383122769, 0.01151410716880852, 0.04981275506466307, 0, 0.011526707414297104, 0.11212662122740781, 0, 0, 0.052325104213913905, 0.05782683648080038, 0.014091073710677162, 0.022248705445939255, 0.0069691884161010575, 0.024311891887346213, 0.009543938169536479, 0.010435850214855739, 0.0009326940065165316, 0, 0, 0, 0, 0, 0, 0, 0, 0.054858642325462566, 0.0038156929644555426, 0.003861194786356837, 0.003712295071835588, 0.024945409565001537, 0.002617585565414945, 0.013310705134604505, 0], "mask_counts_list": [0, 0.1532667717638816, 0.08602303933806484, 0.019574688926928693, 0, 0.001097225703847687, 0, 0.08524893973413165, 0, 0, 0, 0, 0.015244842675557408, 0, 0.002617585565414945]}
|