ziq commited on
Commit
831742d
·
1 Parent(s): cd70113

Update rsna-atd.py

Browse files
Files changed (1) hide show
  1. rsna-atd.py +65 -62
rsna-atd.py CHANGED
@@ -32,27 +32,27 @@ class RSNAATD(datasets.GeneratorBasedBuilder):
32
  description=_DESCRIPTION,
33
  features=datasets.Features(
34
  {
35
- "patient_id": datasets.Value("int64"),
36
- "series_id": datasets.Value("int64"),
37
- "image": datasets.Array3D(shape=(None, 512, 512), dtype="uint8"),
38
- "mask": datasets.Array3D(shape=(None, 512, 512), dtype="uint8"),
39
- # datasets.Sequence(feature=datasets.Array2D(shape=(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,48 +81,51 @@ class RSNAATD(datasets.GeneratorBasedBuilder):
81
 
82
  def _generate_examples(self, images, masks, metadata):
83
  df = pd.read_csv(metadata)
 
 
 
84
  for idx, data in enumerate(df.to_numpy()):
85
- image, mask = [hkl.load(f"images/{data[0]}")], [hkl.load(f"masks/{data[0]}")]
86
- (
87
- patient_id,
88
- series_id,
89
- aortic_hu,
90
- incomplete_organ,
91
- bowel_healthy,
92
- bowel_injury,
93
- extravasation_healthy,
94
- extravasation_injury,
95
- kidney_healthy,
96
- kidney_low,
97
- kidney_high,
98
- liver_healthy,
99
- liver_low,
100
- liver_high,
101
- spleen_healthy,
102
- spleen_low,
103
- spleen_high,
104
- any_injury,
105
- ) = data[1:]
106
 
107
  yield idx, {
108
- "patient_id": patient_id,
109
- "series_id": series_id,
110
- "image": image,
111
- "mask": mask,
112
- "aortic_hu": aortic_hu,
113
- "incomplete_organ": incomplete_organ,
114
- "bowel_healthy": bowel_healthy,
115
- "bowel_injury": bowel_injury,
116
- "extravasation_healthy": extravasation_healthy,
117
- "extravasation_injury": extravasation_injury,
118
- "kidney_healthy": kidney_healthy,
119
- "kidney_low": kidney_low,
120
- "kidney_high": kidney_high,
121
- "liver_healthy": liver_healthy,
122
- "liver_low": liver_low,
123
- "liver_high": liver_high,
124
- "spleen_healthy": spleen_healthy,
125
- "spleen_low": spleen_low,
126
- "spleen_high": spleen_high,
127
- "any_injury": any_injury,
128
  }
 
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
+ yield 0, {
85
+ "test": images
86
+ }
87
  for idx, data in enumerate(df.to_numpy()):
88
+ # image, mask = [hkl.load(f"images/{data[0]}")], [hkl.load(f"masks/{data[0]}")]
89
+ # (
90
+ # patient_id,
91
+ # series_id,
92
+ # aortic_hu,
93
+ # incomplete_organ,
94
+ # bowel_healthy,
95
+ # bowel_injury,
96
+ # extravasation_healthy,
97
+ # extravasation_injury,
98
+ # kidney_healthy,
99
+ # kidney_low,
100
+ # kidney_high,
101
+ # liver_healthy,
102
+ # liver_low,
103
+ # liver_high,
104
+ # spleen_healthy,
105
+ # spleen_low,
106
+ # spleen_high,
107
+ # any_injury,
108
+ # ) = data[1:]
109
 
110
  yield idx, {
111
+ # "patient_id": patient_id,
112
+ # "series_id": series_id,
113
+ # "image": image,
114
+ # "mask": mask,
115
+ # "aortic_hu": aortic_hu,
116
+ # "incomplete_organ": incomplete_organ,
117
+ # "bowel_healthy": bowel_healthy,
118
+ # "bowel_injury": bowel_injury,
119
+ # "extravasation_healthy": extravasation_healthy,
120
+ # "extravasation_injury": extravasation_injury,
121
+ # "kidney_healthy": kidney_healthy,
122
+ # "kidney_low": kidney_low,
123
+ # "kidney_high": kidney_high,
124
+ # "liver_healthy": liver_healthy,
125
+ # "liver_low": liver_low,
126
+ # "liver_high": liver_high,
127
+ # "spleen_healthy": spleen_healthy,
128
+ # "spleen_low": spleen_low,
129
+ # "spleen_high": spleen_high,
130
+ # "any_injury": any_injury,
131
  }