Skip to content

Commit 3e0a0d2

Browse files
committed
Assume default values for missing Rescale Intercept and Slope attributes.
1 parent 0aa7ef0 commit 3e0a0d2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

monai/deploy/operators/dicom_series_to_volume_operator.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,15 @@ def generate_voxel_data(self, series):
8484
# This is to have the same numpy ndarray as from Monai ImageReader (ITK, NiBabel etc).
8585
vol_data = np.stack([np.transpose(s.get_pixel_array()) for s in slices], axis=-1)
8686
vol_data = vol_data.astype(np.int16)
87-
intercept = slices[0][0x0028, 0x1052].value
88-
slope = slices[0][0x0028, 0x1053].value
87+
# Rescale Intercept and Slope attributes might be missing, but safe to assume defaults.
88+
try:
89+
intercept = slices[0][0x0028, 0x1052].value
90+
except KeyError:
91+
intercept = 0
92+
try:
93+
slope = slices[0][0x0028, 0x1053].value
94+
except KeyError:
95+
slope = 1
8996

9097
if slope != 1:
9198
vol_data = slope * vol_data.astype(np.float64)

0 commit comments

Comments
 (0)