Skip to content

Commit

Permalink
Add checks to ensure similarity of source images
Browse files Browse the repository at this point in the history
  • Loading branch information
hackermd committed Aug 30, 2022
1 parent 18fc8f4 commit 15a7169
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/highdicom/seg/sop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 15a7169

Please sign in to comment.