Skip to content

Commit

Permalink
Prohibit PlanarROIMeasurementsAndQualitativeEvaluations to use
Browse files Browse the repository at this point in the history
coordinates in measurements

TID 1410 (Planar ROI Measurements and Qualitative Evaluations) makes use
of TID 1419 (ROI Measurements) which does not include coordinates like
TID 300 (Measurements).
  • Loading branch information
Fedalto committed Oct 3, 2024
1 parent 81dd8fb commit 3580c65
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/highdicom/sr/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -3424,6 +3424,13 @@ def __init__(
'Argument "referenced_segment" must have type '
'ReferencedSegmentationFrame.'
)
if measurements is not None:
for measurement in measurements:
if measurement.referenced_coordinates:
raise ValueError(
'Referenced coordinates in measurements are not allowed in '
'PlanarROIMeasurementsAndQualitativeEvaluations.'
)
super().__init__(
tracking_identifier=tracking_identifier,
referenced_regions=referenced_regions,
Expand Down
18 changes: 18 additions & 0 deletions tests/test_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3093,6 +3093,24 @@ def test_constructed_with_multiple_references(self):
referenced_segment=self._segment
)

def test_constructed_with_measurements_coordinates(self):
measurement = Measurement(
name=codes.SCT.Diameter,
value=5,
unit=codes.UCUM.Millimeter,
referenced_coordinates=[CoordinatesForMeasurement(
graphic_type=GraphicTypeValues.POLYLINE,
graphic_data=np.array([[1, 1], [2, 2]]),
source_image=self._image_for_region
)]
)
with pytest.raises(ValueError):
PlanarROIMeasurementsAndQualitativeEvaluations(
tracking_identifier=self._tracking_identifier,
referenced_region=self._region,
measurements=[measurement],
)


class TestVolumetricROIMeasurementsAndQualitativeEvaluations(unittest.TestCase):

Expand Down

0 comments on commit 3580c65

Please sign in to comment.