From 15a71691a1622fc93814a88d998662d14093b2c0 Mon Sep 17 00:00:00 2001 From: hackermd Date: Tue, 30 Aug 2022 09:11:39 -0400 Subject: [PATCH] Add checks to ensure similarity of source images --- src/highdicom/seg/sop.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/highdicom/seg/sop.py b/src/highdicom/seg/sop.py index 29f99ed1..a9e8821d 100644 --- a/src/highdicom/seg/sop.py +++ b/src/highdicom/seg/sop.py @@ -280,14 +280,29 @@ def __init__( image.SeriesInstanceUID, image.Rows, image.Columns, + int(getattr(image, 'NumberOfFrames', '1')), + hasattr(image, 'FrameOfReferenceUID'), getattr(image, 'FrameOfReferenceUID', None), + hasattr(image, 'TotalPixelMatrixRows'), + getattr(image, 'TotalPixelMatrixRows', None), + hasattr(image, 'TotalPixelMatrixColumns'), + getattr(image, 'TotalPixelMatrixColumns', None), + hasattr(image, 'TotalPixelMatrixFocalPlanes'), + getattr(image, 'TotalPixelMatrixFocalPlanes', None), + tuple(getattr(image, 'ImageOrientation', [])), + tuple(getattr(image, 'ImageOrientationSlide', [])), + hasattr(image, 'DimensionOrganizationType'), + getattr(image, 'DimensionOrganizationType', None), + len(getattr(image, 'PerFrameFunctionalGroupsSequence', [])), + len(getattr(image, 'SharedFunctionalGroupsSequence', [])), ) for image in source_images ) if len(uniqueness_criteria) > 1: raise ValueError( - 'Source images must all be part of the same series and must ' - 'have the same image dimensions (number of rows/columns).' + 'Source images must all be part of the same series, must ' + 'have the same image dimensions (number of rows/columns), and ' + 'must have the same image orientation.' ) src_img = source_images[0]