From 00a2a111bcec15dd5aef5506f2c8dbfb3b1bc79d Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 21 Jun 2023 13:43:44 +0200 Subject: [PATCH 1/2] Convert to PlanePositionSequence --- src/highdicom/seg/content.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/highdicom/seg/content.py b/src/highdicom/seg/content.py index 72208aa2..94b94435 100644 --- a/src/highdicom/seg/content.py +++ b/src/highdicom/seg/content.py @@ -481,8 +481,9 @@ def get_plane_positions_of_image( ) elif self._coordinate_system == CoordinateSystemNames.SLIDE: if hasattr(image, 'PerFrameFunctionalGroupsSequence'): - plane_positions = [ + plane_positions = [PlanePositionSequence.from_sequence( item.PlanePositionSlideSequence + ) for item in image.PerFrameFunctionalGroupsSequence ] else: @@ -491,7 +492,7 @@ def get_plane_positions_of_image( plane_positions = compute_plane_position_slide_per_frame(image) else: plane_positions = [ - item.PlanePositionSequence + PlanePositionSequence.from_sequence(item.PlanePositionSequence) for item in image.PerFrameFunctionalGroupsSequence ] From 9846a78944a212855263f8a1102f7d85c6ec7b5b Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 21 Jun 2023 13:45:42 +0200 Subject: [PATCH 2/2] Added tests for plance position sequence --- tests/test_seg.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_seg.py b/tests/test_seg.py index 85b363d2..0ae848c7 100644 --- a/tests/test_seg.py +++ b/tests/test_seg.py @@ -2512,6 +2512,30 @@ def test_spatial_positions_not_preserved(self): assert po_item.ImageOrientationSlide == list(image_orientation) self.check_dimension_index_vals(instance) + def test_get_plane_positions_of_image_patient(self): + seq = DimensionIndexSequence( + coordinate_system='PATIENT' + ) + plane_positions = seq.get_plane_positions_of_image(self._ct_multiframe) + for position in plane_positions: + assert isinstance(position, PlanePositionSequence) + + def test_get_plane_positions_of_image_slide(self): + seq = DimensionIndexSequence( + coordinate_system='SLIDE' + ) + plane_positions = seq.get_plane_positions_of_image(self._sm_image) + for position in plane_positions: + assert isinstance(position, PlanePositionSequence) + + def test_get_plane_positions_of_series(self): + seq = DimensionIndexSequence( + coordinate_system='PATIENT' + ) + plane_positions = seq.get_plane_positions_of_series(self._ct_series) + for position in plane_positions: + assert isinstance(position, PlanePositionSequence) + class TestSegmentationParsing():