Update rsna-atd.py
Browse files- rsna-atd.py +61 -22
rsna-atd.py
CHANGED
@@ -32,26 +32,26 @@ class RSNAATD(datasets.GeneratorBasedBuilder):
|
|
32 |
description=_DESCRIPTION,
|
33 |
features=datasets.Features(
|
34 |
{
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
"image": datasets.Array3D(shape=(None, 512, 512), dtype=np.uint8),
|
54 |
-
"mask": datasets.Array3D(shape=(None, 512, 512), dtype=np.uint8),
|
55 |
}
|
56 |
),
|
57 |
supervised_keys=None,
|
@@ -81,9 +81,48 @@ class RSNAATD(datasets.GeneratorBasedBuilder):
|
|
81 |
def _generate_examples(self, images, masks, metadata):
|
82 |
df = pd.read_csv(metadata)
|
83 |
for idx, data in enumerate(df.to_numpy()):
|
84 |
-
image, mask = hkl.load(f"images/{data[0]}"), hkl.load(f"masks/{data[0]}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
yield idx, {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
# for idx, ((image_path), (mask_path)) in enumerate(zip(images, masks)):
|
89 |
# # row = df.loc[df["path"] == image_path.lower().replace("images/", "")]
|
|
|
32 |
description=_DESCRIPTION,
|
33 |
features=datasets.Features(
|
34 |
{
|
35 |
+
"patient_id": datasets.Value("int64"),
|
36 |
+
"series_id": datasets.Value("int64"),
|
37 |
+
"aortic_hu": datasets.Value("float64"),
|
38 |
+
"incomplete_organ": datasets.Value("int64"),
|
39 |
+
"bowel_healthy": datasets.Value("int64"),
|
40 |
+
"bowel_injury": datasets.Value("int64"),
|
41 |
+
"extravasation_healthy": datasets.Value("int64"),
|
42 |
+
"extravasation_injury": datasets.Value("int64"),
|
43 |
+
"kidney_healthy": datasets.Value("int64"),
|
44 |
+
"kidney_low": datasets.Value("int64"),
|
45 |
+
"kidney_high": datasets.Value("int64"),
|
46 |
+
"liver_healthy": datasets.Value("int64"),
|
47 |
+
"liver_low": datasets.Value("int64"),
|
48 |
+
"liver_high": datasets.Value("int64"),
|
49 |
+
"spleen_healthy": datasets.Value("int64"),
|
50 |
+
"spleen_low": datasets.Value("int64"),
|
51 |
+
"spleen_high": datasets.Value("int64"),
|
52 |
+
"any_injury": datasets.Value("int64"),
|
53 |
+
# "image": datasets.Array3D(shape=(None, 512, 512), dtype=np.uint8),
|
54 |
+
# "mask": datasets.Array3D(shape=(None, 512, 512), dtype=np.uint8),
|
55 |
}
|
56 |
),
|
57 |
supervised_keys=None,
|
|
|
81 |
def _generate_examples(self, images, masks, metadata):
|
82 |
df = pd.read_csv(metadata)
|
83 |
for idx, data in enumerate(df.to_numpy()):
|
84 |
+
# image, mask = hkl.load(f"images/{data[0]}"), hkl.load(f"masks/{data[0]}")
|
85 |
+
(
|
86 |
+
patient_id,
|
87 |
+
series_id,
|
88 |
+
aortic_hu,
|
89 |
+
incomplete_organ,
|
90 |
+
bowel_healthy,
|
91 |
+
bowel_injury,
|
92 |
+
extravasation_healthy,
|
93 |
+
extravasation_injury,
|
94 |
+
kidney_healthy,
|
95 |
+
kidney_low,
|
96 |
+
kidney_high,
|
97 |
+
liver_healthy,
|
98 |
+
liver_low,
|
99 |
+
liver_high,
|
100 |
+
spleen_healthy,
|
101 |
+
spleen_low,
|
102 |
+
spleen_high,
|
103 |
+
any_injury,
|
104 |
+
) = data[1:]
|
105 |
|
106 |
+
yield idx, {
|
107 |
+
"patient_id": patient_id,
|
108 |
+
"series_id": series_id,
|
109 |
+
"aortic_hu": aortic_hu,
|
110 |
+
"incomplete_organ": incomplete_organ,
|
111 |
+
"bowel_healthy": bowel_healthy,
|
112 |
+
"bowel_injury": bowel_injury,
|
113 |
+
"extravasation_healthy": extravasation_healthy,
|
114 |
+
"extravasation_injury": extravasation_injury,
|
115 |
+
"kidney_healthy": kidney_healthy,
|
116 |
+
"kidney_low": kidney_low,
|
117 |
+
"kidney_high": kidney_high,
|
118 |
+
"liver_healthy": liver_healthy,
|
119 |
+
"liver_low": liver_low,
|
120 |
+
"liver_high": liver_high,
|
121 |
+
"spleen_healthy": spleen_healthy,
|
122 |
+
"spleen_low": spleen_low,
|
123 |
+
"spleen_high": spleen_high,
|
124 |
+
"any_injury": any_injury,
|
125 |
+
}
|
126 |
|
127 |
# for idx, ((image_path), (mask_path)) in enumerate(zip(images, masks)):
|
128 |
# # row = df.loc[df["path"] == image_path.lower().replace("images/", "")]
|