Chris Oswald commited on
Commit
4b43c77
1 Parent(s): e0f64ef
Files changed (1) hide show
  1. SPIDER.py +6 -8
SPIDER.py CHANGED
@@ -142,7 +142,7 @@ class SPIDER(datasets.GeneratorBasedBuilder):
142
  "patient_id": datasets.Value("string"),
143
  "scan_type": datasets.Value("string"),
144
  # "raw_image": datasets.Image(),
145
- # "numeric_array": datasets.Sequence(datasets.Value("int16")),
146
  "metadata": {
147
  "num_vertebrae": datasets.Value(dtype="string"),
148
  "num_discs": datasets.Value(dtype="string"),
@@ -224,7 +224,6 @@ class SPIDER(datasets.GeneratorBasedBuilder):
224
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
225
  paths_dict = dl_manager.download_and_extract(_URLS)
226
  scan_types = self.config.scan_types
227
- # scan_types = ['t1'] #TODO: remove
228
  return [
229
  datasets.SplitGenerator(
230
  name=datasets.Split.TRAIN,
@@ -443,10 +442,7 @@ class SPIDER(datasets.GeneratorBasedBuilder):
443
  # (note that only images need to be shuffled since masks and metadata
444
  # will be linked to the selected image)
445
  np.random.shuffle(image_files)
446
-
447
- print(image_files)
448
- print(mask_files)
449
- print(len(image_files), len(mask_files))
450
  ## Generate next example
451
  # ----------------------
452
  for idx, example in enumerate(image_files):
@@ -463,6 +459,8 @@ class SPIDER(datasets.GeneratorBasedBuilder):
463
  # Convert .mha image to numeric array
464
  image_array = sitk.GetArrayFromImage(image)
465
 
 
 
466
  # Extract overview data corresponding to image
467
  image_overview = overview_dict[scan_id]
468
 
@@ -473,8 +471,8 @@ class SPIDER(datasets.GeneratorBasedBuilder):
473
  return_dict = {'patient_id':patient_id, 'scan_type':scan_type}
474
  # if raw_image:
475
  # return_dict['raw_image'] = image
476
- # if numeric_array:
477
- # return_dict['numeric_array'] = image_array
478
  if metadata:
479
  return_dict['metadata'] = image_overview
480
  if rad_gradings:
 
142
  "patient_id": datasets.Value("string"),
143
  "scan_type": datasets.Value("string"),
144
  # "raw_image": datasets.Image(),
145
+ "numeric_array": datasets.Sequence(datasets.Value("int16")),
146
  "metadata": {
147
  "num_vertebrae": datasets.Value(dtype="string"),
148
  "num_discs": datasets.Value(dtype="string"),
 
224
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
225
  paths_dict = dl_manager.download_and_extract(_URLS)
226
  scan_types = self.config.scan_types
 
227
  return [
228
  datasets.SplitGenerator(
229
  name=datasets.Split.TRAIN,
 
442
  # (note that only images need to be shuffled since masks and metadata
443
  # will be linked to the selected image)
444
  np.random.shuffle(image_files)
445
+
 
 
 
446
  ## Generate next example
447
  # ----------------------
448
  for idx, example in enumerate(image_files):
 
459
  # Convert .mha image to numeric array
460
  image_array = sitk.GetArrayFromImage(image)
461
 
462
+ #TODO: load mask file and numeric array
463
+
464
  # Extract overview data corresponding to image
465
  image_overview = overview_dict[scan_id]
466
 
 
471
  return_dict = {'patient_id':patient_id, 'scan_type':scan_type}
472
  # if raw_image:
473
  # return_dict['raw_image'] = image
474
+ if numeric_array:
475
+ return_dict['numeric_array'] = image_array
476
  if metadata:
477
  return_dict['metadata'] = image_overview
478
  if rad_gradings: