diff --git a/exporters/spline_segmentation_exporter.py b/exporters/spline_segmentation_exporter.py index 30f76d8..9f60afd 100644 --- a/exporters/spline_segmentation_exporter.py +++ b/exporters/spline_segmentation_exporter.py @@ -247,6 +247,16 @@ def draw_segmentation(image_size, control_points, label: int = 1, canvas: np.nda @staticmethod def compute_scaling(image_size, spacing): + if len(spacing) > len(image_size): + warnings.warn(f'Image is {len(image_size)}D and spacing is {len(spacing)}D.' + f'Dropping the extra axes in the spacing vector.') + for n in range(len(spacing) - len(image_size)): + spacing.pop(-1) + elif len(spacing) < len(image_size): + raise ValueError(f'Something wrong with the data:' + f'image is {len(image_size)}D and spacing is {len(spacing)}D.') + + assert len(image_size) == len(spacing), 'Image size and spacing are expected to have the same dimensions.' if len(spacing) == 2: aspect_ratio = image_size[0] / image_size[1] new_aspect_ratio = image_size[0] * spacing[0] / (image_size[1] * spacing[1])