Chris Oswald
commited on
Commit
·
0dfab66
1
Parent(s):
7458736
debugging
Browse files
SPIDER.py
CHANGED
@@ -77,6 +77,7 @@ def standardize_3D_image(
|
|
77 |
image = skimage.transform.resize(image, resize_shape)
|
78 |
return image
|
79 |
|
|
|
80 |
# Define constants
|
81 |
MIN_IVD = 0
|
82 |
MAX_IVD = 9
|
@@ -486,15 +487,15 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
486 |
# Convert .mha image to original size numeric array
|
487 |
image_array_original = sitk.GetArrayFromImage(image)
|
488 |
|
|
|
|
|
|
|
489 |
# Convert .mha image to standardized numeric array
|
490 |
image_array_standardized = standardize_3D_image(
|
491 |
-
|
492 |
resize_shape,
|
493 |
)
|
494 |
|
495 |
-
# Rescale image to UInt8 type (required for PyArrow and PIL)
|
496 |
-
image_array_standardized = skimage.img_as_ubyte(image_array_standardized)
|
497 |
-
|
498 |
# Load .mha mask file
|
499 |
mask_path = os.path.join(paths_dict['masks'], 'masks', example)
|
500 |
mask = sitk.ReadImage(mask_path)
|
@@ -502,9 +503,12 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
502 |
# Convert .mha mask to original size numeric array
|
503 |
mask_array_original = sitk.GetArrayFromImage(mask)
|
504 |
|
|
|
|
|
|
|
505 |
# Convert .mha mask to standardized numeric array
|
506 |
mask_array_standardized = standardize_3D_image(
|
507 |
-
|
508 |
resize_shape,
|
509 |
)
|
510 |
|
|
|
77 |
image = skimage.transform.resize(image, resize_shape)
|
78 |
return image
|
79 |
|
80 |
+
|
81 |
# Define constants
|
82 |
MIN_IVD = 0
|
83 |
MAX_IVD = 9
|
|
|
487 |
# Convert .mha image to original size numeric array
|
488 |
image_array_original = sitk.GetArrayFromImage(image)
|
489 |
|
490 |
+
# Rescale to UInt8 type (required for PyArrow and PIL)
|
491 |
+
image_array_rescaled = skimage.img_as_ubyte(image_array_original)
|
492 |
+
|
493 |
# Convert .mha image to standardized numeric array
|
494 |
image_array_standardized = standardize_3D_image(
|
495 |
+
image_array_rescaled,
|
496 |
resize_shape,
|
497 |
)
|
498 |
|
|
|
|
|
|
|
499 |
# Load .mha mask file
|
500 |
mask_path = os.path.join(paths_dict['masks'], 'masks', example)
|
501 |
mask = sitk.ReadImage(mask_path)
|
|
|
503 |
# Convert .mha mask to original size numeric array
|
504 |
mask_array_original = sitk.GetArrayFromImage(mask)
|
505 |
|
506 |
+
# Rescale to UInt8 type (required for PyArrow and PIL)
|
507 |
+
mask_array_rescaled = skimage.img_as_ubyte(mask_array_original)
|
508 |
+
|
509 |
# Convert .mha mask to standardized numeric array
|
510 |
mask_array_standardized = standardize_3D_image(
|
511 |
+
mask_array_rescaled,
|
512 |
resize_shape,
|
513 |
)
|
514 |
|