Skip to content

Commit

Permalink
Merge pull request #240 from thomas-albrecht/Convert-plane-positions-…
Browse files Browse the repository at this point in the history
…to-PlanePositionSlideSequence

Convert plane positions to plane position slide sequence
  • Loading branch information
CPBridge committed Jun 22, 2023
2 parents aed7798 + 9846a78 commit 723f579
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/highdicom/seg/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
]

Expand Down
24 changes: 24 additions & 0 deletions tests/test_seg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():

Expand Down

0 comments on commit 723f579

Please sign in to comment.