Chris Oswald commited on
Commit
e9b9cd5
·
1 Parent(s): fa67d9b

added feature information

Browse files
Files changed (1) hide show
  1. SPIDER.py +121 -12
SPIDER.py CHANGED
@@ -23,6 +23,7 @@ from typing import Dict, List, Mapping, Optional, Set, Sequence, Tuple, Union
23
  import numpy as np
24
 
25
  import datasets
 
26
  import SimpleITK as sitk
27
 
28
  # Define functions
@@ -135,18 +136,123 @@ class SPIDER(datasets.GeneratorBasedBuilder):
135
  This method specifies the datasets.DatasetInfo object which contains
136
  informations and typings for the dataset.
137
  """
138
- features = datasets.Features(
139
- {
140
- "patient_id": datasets.Value("string"),
141
- "scan_type": datasets.Value("string"),
142
- "raw_image": datasets.Value(sitk.Image),
143
- "numeric_array": datasets.Value(np.array),
144
- "metadata": datasets.Value(dict),
145
- "rad_gradings": datasets.Value(dict),
146
-
147
- # These are the features of your dataset like images, labels ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
- )
150
 
151
  return datasets.DatasetInfo(
152
  # This is the description that will appear on the datasets page.
@@ -297,10 +403,13 @@ class SPIDER(datasets.GeneratorBasedBuilder):
297
  grades_data = import_csv_data(paths_dict['gradings'])
298
 
299
  # Convert overview data list of dicts to dict of dicts
 
300
  overview_dict = {}
301
  for item in overview_data:
302
  key = item['new_file_name']
303
- overview_dict[key] = item
 
 
304
 
305
  # Merge patient records for radiological gradings data
306
  grades_dict = {}
 
23
  import numpy as np
24
 
25
  import datasets
26
+ from datasets import Image
27
  import SimpleITK as sitk
28
 
29
  # Define functions
 
136
  This method specifies the datasets.DatasetInfo object which contains
137
  informations and typings for the dataset.
138
  """
139
+ features = datasets.Features({
140
+ "patient_id": datasets.Value("string"),
141
+ "scan_type": datasets.Value("string"),
142
+ "raw_image": datasets.Value("object"),
143
+ "numeric_array": datasets.Value("numpy", dtype="int16", shape=(512, 512, 17)),
144
+ "metadata": {
145
+ "num_vertebrae": datasets.Value(dtype="string"),
146
+ "num_discs": datasets.Value(dtype="string"),
147
+ "sex": datasets.Value(dtype="string"),
148
+ "birth_date": datasets.Value(dtype="string"),
149
+ "AngioFlag": datasets.Value(dtype="string"),
150
+ "BodyPartExamined": datasets.Value(dtype="string"),
151
+ "DeviceSerialNumber": datasets.Value(dtype="string"),
152
+ "EchoNumbers": datasets.Value(dtype="string"),
153
+ "EchoTime": datasets.Value(dtype="string"),
154
+ "EchoTrainLength": datasets.Value(dtype="string"),
155
+ "FlipAngle": datasets.Value(dtype="string"),
156
+ "ImagedNucleus": datasets.Value(dtype="string"),
157
+ "ImagingFrequency": datasets.Value(dtype="string"),
158
+ "InPlanePhaseEncodingDirection": datasets.Value(dtype="string"),
159
+ "MRAcquisitionType": datasets.Value(dtype="string"),
160
+ "MagneticFieldStrength": datasets.Value(dtype="string"),
161
+ "Manufacturer": datasets.Value(dtype="string"),
162
+ "ManufacturerModelName": datasets.Value(dtype="string"),
163
+ "NumberOfPhaseEncodingSteps": datasets.Value(dtype="string"),
164
+ "PercentPhaseFieldOfView": datasets.Value(dtype="string"),
165
+ "PercentSampling": datasets.Value(dtype="string"),
166
+ "PhotometricInterpretation": datasets.Value(dtype="string"),
167
+ "PixelBandwidth": datasets.Value(dtype="string"),
168
+ "PixelSpacing": datasets.Value(dtype="string"),
169
+ "RepetitionTime": datasets.Value(dtype="string"),
170
+ "SAR": datasets.Value(dtype="string"),
171
+ "SamplesPerPixel": datasets.Value(dtype="string"),
172
+ "ScanningSequence": datasets.Value(dtype="string"),
173
+ "SequenceName": datasets.Value(dtype="string"),
174
+ "SeriesDescription": datasets.Value(dtype="string"),
175
+ "SliceThickness": datasets.Value(dtype="string"),
176
+ "SoftwareVersions": datasets.Value(dtype="string"),
177
+ "SpacingBetweenSlices": datasets.Value(dtype="string"),
178
+ "SpecificCharacterSet": datasets.Value(dtype="string"),
179
+ "TransmitCoilName": datasets.Value(dtype="string"),
180
+ "WindowCenter": datasets.Value(dtype="string"),
181
+ "WindowWidth": datasets.Value(dtype="string"),
182
+ },
183
+ "rad_gradings": {
184
+ "IVD1": {
185
+ "Modic": datasets.Value(dtype="string"),
186
+ "UP endplate": datasets.Value(dtype="string"),
187
+ "LOW endplate": datasets.Value(dtype="string"),
188
+ "Spondylolisthesis": datasets.Value(dtype="string"),
189
+ "Disc herniation": datasets.Value(dtype="string"),
190
+ "Disc narrowing": datasets.Value(dtype="string"),
191
+ "Disc bulging": datasets.Value(dtype="string"),
192
+ "Pfirrman grade": datasets.Value(dtype="string"),
193
+ },
194
+ "IVD2": {
195
+ "Modic": datasets.Value(dtype="string"),
196
+ "UP endplate": datasets.Value(dtype="string"),
197
+ "LOW endplate": datasets.Value(dtype="string"),
198
+ "Spondylolisthesis": datasets.Value(dtype="string"),
199
+ "Disc herniation": datasets.Value(dtype="string"),
200
+ "Disc narrowing": datasets.Value(dtype="string"),
201
+ "Disc bulging": datasets.Value(dtype="string"),
202
+ "Pfirrman grade": datasets.Value(dtype="string"),
203
+ },
204
+ "IVD3": {
205
+ "Modic": datasets.Value(dtype="string"),
206
+ "UP endplate": datasets.Value(dtype="string"),
207
+ "LOW endplate": datasets.Value(dtype="string"),
208
+ "Spondylolisthesis": datasets.Value(dtype="string"),
209
+ "Disc herniation": datasets.Value(dtype="string"),
210
+ "Disc narrowing": datasets.Value(dtype="string"),
211
+ "Disc bulging": datasets.Value(dtype="string"),
212
+ "Pfirrman grade": datasets.Value(dtype="string"),
213
+ },
214
+ "IVD4": {
215
+ "Modic": datasets.Value(dtype="string"),
216
+ "UP endplate": datasets.Value(dtype="string"),
217
+ "LOW endplate": datasets.Value(dtype="string"),
218
+ "Spondylolisthesis": datasets.Value(dtype="string"),
219
+ "Disc herniation": datasets.Value(dtype="string"),
220
+ "Disc narrowing": datasets.Value(dtype="string"),
221
+ "Disc bulging": datasets.Value(dtype="string"),
222
+ "Pfirrman grade": datasets.Value(dtype="string"),
223
+ },
224
+ "IVD5": {
225
+ "Modic": datasets.Value(dtype="string"),
226
+ "UP endplate": datasets.Value(dtype="string"),
227
+ "LOW endplate": datasets.Value(dtype="string"),
228
+ "Spondylolisthesis": datasets.Value(dtype="string"),
229
+ "Disc herniation": datasets.Value(dtype="string"),
230
+ "Disc narrowing": datasets.Value(dtype="string"),
231
+ "Disc bulging": datasets.Value(dtype="string"),
232
+ "Pfirrman grade": datasets.Value(dtype="string"),
233
+ },
234
+ "IVD6": {
235
+ "Modic": datasets.Value(dtype="string"),
236
+ "UP endplate": datasets.Value(dtype="string"),
237
+ "LOW endplate": datasets.Value(dtype="string"),
238
+ "Spondylolisthesis": datasets.Value(dtype="string"),
239
+ "Disc herniation": datasets.Value(dtype="string"),
240
+ "Disc narrowing": datasets.Value(dtype="string"),
241
+ "Disc bulging": datasets.Value(dtype="string"),
242
+ "Pfirrman grade": datasets.Value(dtype="string"),
243
+ },
244
+ "IVD7": {
245
+ "Modic": datasets.Value(dtype="string"),
246
+ "UP endplate": datasets.Value(dtype="string"),
247
+ "LOW endplate": datasets.Value(dtype="string"),
248
+ "Spondylolisthesis": datasets.Value(dtype="string"),
249
+ "Disc herniation": datasets.Value(dtype="string"),
250
+ "Disc narrowing": datasets.Value(dtype="string"),
251
+ "Disc bulging": datasets.Value(dtype="string"),
252
+ "Pfirrman grade": datasets.Value(dtype="string"),
253
+ },
254
  }
255
+ })
256
 
257
  return datasets.DatasetInfo(
258
  # This is the description that will appear on the datasets page.
 
403
  grades_data = import_csv_data(paths_dict['gradings'])
404
 
405
  # Convert overview data list of dicts to dict of dicts
406
+ exclude_vars = ['new_file_name', 'subset'] # Original data only lists train and validate
407
  overview_dict = {}
408
  for item in overview_data:
409
  key = item['new_file_name']
410
+ overview_dict[key] = {
411
+ k:v for k,v in item.items() if k not in exclude_vars
412
+ }
413
 
414
  # Merge patient records for radiological gradings data
415
  grades_dict = {}