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