Upload datasets.py
Browse files- datasets.py +13 -4
datasets.py
CHANGED
@@ -316,7 +316,7 @@ def preproc_mimic(batch):
|
|
316 |
elif k in ["race"]:
|
317 |
batch[k] = F.one_hot(batch[k], num_classes=3).squeeze().float()
|
318 |
elif k in ["finding"]:
|
319 |
-
batch[k] = batch[k].
|
320 |
else:
|
321 |
batch[k] = batch[k].float().unsqueeze(-1)
|
322 |
return batch
|
@@ -336,8 +336,8 @@ class MIMICDataset(Dataset):
|
|
336 |
self.transform = transform
|
337 |
self.disease_labels = [
|
338 |
"No Finding",
|
339 |
-
"
|
340 |
-
"
|
341 |
# "Lung Opacity",
|
342 |
]
|
343 |
self.samples = {
|
@@ -362,7 +362,16 @@ class MIMICDataset(Dataset):
|
|
362 |
# self.samples["pleural_effusion"].append(pleural_effusion)
|
363 |
|
364 |
disease = self.data.loc[idx, "disease"]
|
365 |
-
finding = 0 if disease == "No Finding" else 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
|
367 |
self.samples["x"].append(img_path)
|
368 |
self.samples["finding"].append(finding)
|
|
|
316 |
elif k in ["race"]:
|
317 |
batch[k] = F.one_hot(batch[k], num_classes=3).squeeze().float()
|
318 |
elif k in ["finding"]:
|
319 |
+
batch[k] = F.one_hot(batch[k], num_classes=3).squeeze().float()
|
320 |
else:
|
321 |
batch[k] = batch[k].float().unsqueeze(-1)
|
322 |
return batch
|
|
|
336 |
self.transform = transform
|
337 |
self.disease_labels = [
|
338 |
"No Finding",
|
339 |
+
"Consolidation",
|
340 |
+
"Lung Opacity",
|
341 |
# "Lung Opacity",
|
342 |
]
|
343 |
self.samples = {
|
|
|
362 |
# self.samples["pleural_effusion"].append(pleural_effusion)
|
363 |
|
364 |
disease = self.data.loc[idx, "disease"]
|
365 |
+
# finding = 0 if disease == "No Finding" else 1
|
366 |
+
if disease == "No Finding":
|
367 |
+
finding = 0
|
368 |
+
elif disease == "Consolidation":
|
369 |
+
finding = 1
|
370 |
+
elif disease == "Lung Opacity":
|
371 |
+
finding = 2
|
372 |
+
else:
|
373 |
+
finding = None
|
374 |
+
|
375 |
|
376 |
self.samples["x"].append(img_path)
|
377 |
self.samples["finding"].append(finding)
|