From 66ca135e83aa23d4ad852e1ea36b424643ac7945 Mon Sep 17 00:00:00 2001 From: William Grisaitis Date: Thu, 20 Oct 2016 02:16:25 -0400 Subject: [PATCH] Don't zero-pad image in get_numpy_dataset() if the source array is already zero-padded --- data_io/dataset_reading.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data_io/dataset_reading.py b/data_io/dataset_reading.py index 5c1c5d2..734a0b7 100644 --- a/data_io/dataset_reading.py +++ b/data_io/dataset_reading.py @@ -125,7 +125,11 @@ def get_numpy_dataset(original_dataset, input_slice, output_slice, transform): image_slices = [slice(0, l) for l in original_dataset['data'].shape] image_slices[-n_spatial_dimensions:] = input_slice logger.debug("image_slices: {}".format(image_slices)) - source_image = get_zero_padded_array_slice(original_dataset['data'], image_slices) + image_is_zero_padded = original_dataset.get("image_is_zero_padded", False) + if image_is_zero_padded: + source_image = original_dataset["data"][image_slices] + else: + source_image = get_zero_padded_array_slice(original_dataset['data'], image_slices) image = np.array(source_image, dtype=np.float32) image_scaling_factor = original_dataset.get('image_scaling_factor', None) if image_scaling_factor is None and source_image.dtype.kind in ('i', 'u'): # integer, signed or unsigned