From 3e0a0d2c9f1991af6c7f1e2704bb8321dd580fa7 Mon Sep 17 00:00:00 2001 From: mmelqin Date: Tue, 11 Jan 2022 22:31:09 -0800 Subject: [PATCH 1/2] Assume default values for missing Rescale Intercept and Slope attributes. --- .../operators/dicom_series_to_volume_operator.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/monai/deploy/operators/dicom_series_to_volume_operator.py b/monai/deploy/operators/dicom_series_to_volume_operator.py index bbccb173..86f4327d 100644 --- a/monai/deploy/operators/dicom_series_to_volume_operator.py +++ b/monai/deploy/operators/dicom_series_to_volume_operator.py @@ -84,8 +84,15 @@ def generate_voxel_data(self, series): # This is to have the same numpy ndarray as from Monai ImageReader (ITK, NiBabel etc). vol_data = np.stack([np.transpose(s.get_pixel_array()) for s in slices], axis=-1) vol_data = vol_data.astype(np.int16) - intercept = slices[0][0x0028, 0x1052].value - slope = slices[0][0x0028, 0x1053].value + # Rescale Intercept and Slope attributes might be missing, but safe to assume defaults. + try: + intercept = slices[0][0x0028, 0x1052].value + except KeyError: + intercept = 0 + try: + slope = slices[0][0x0028, 0x1053].value + except KeyError: + slope = 1 if slope != 1: vol_data = slope * vol_data.astype(np.float64) From cfeac9eb991fa806221c0d4cf353bca1a1c21afb Mon Sep 17 00:00:00 2001 From: mmelqin Date: Tue, 11 Jan 2022 22:33:31 -0800 Subject: [PATCH 2/2] Sign off Signed-off-by: mmelqin --- monai/deploy/operators/dicom_series_to_volume_operator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/monai/deploy/operators/dicom_series_to_volume_operator.py b/monai/deploy/operators/dicom_series_to_volume_operator.py index 86f4327d..25aeb3b0 100644 --- a/monai/deploy/operators/dicom_series_to_volume_operator.py +++ b/monai/deploy/operators/dicom_series_to_volume_operator.py @@ -89,6 +89,7 @@ def generate_voxel_data(self, series): intercept = slices[0][0x0028, 0x1052].value except KeyError: intercept = 0 + try: slope = slices[0][0x0028, 0x1053].value except KeyError: