1111
1212from highdicom .ann .content import Measurements , AnnotationGroup
1313from highdicom .ann .enum import (
14+ AnnotationCoordinateTypeValues ,
1415 AnnotationGroupGenerationTypeValues ,
1516 GraphicTypeValues ,
1617)
@@ -231,6 +232,10 @@ def test_construction(self):
231232 assert values .shape == (2 , 0 )
232233
233234 def test_alternative_construction_from_dataset (self ):
235+ coordinates_data = np .array (
236+ [1.0 , 1.0 , 2.0 , 2.0 , 3.0 , 3.0 ],
237+ dtype = np .double
238+ )
234239 dataset = Dataset ()
235240 dataset .AnnotationGroupNumber = 1
236241 dataset .AnnotationGroupUID = str (UID ())
@@ -249,19 +254,34 @@ def test_alternative_construction_from_dataset(self):
249254 dataset .AnnotationPropertyTypeCodeSequence = [annotated_type ]
250255 dataset .NumberOfAnnotations = 3
251256 dataset .GraphicType = 'POINT'
252- dataset .DoublePointCoordinatesData = [ 1.0 , 1.0 , 2.0 , 2.0 , 3.0 , 3.0 ]
257+ dataset .DoublePointCoordinatesData = coordinates_data . tobytes ()
253258 dataset .AnnotationAppliesToAllZPlanes = 'NO'
254259 dataset .AnnotationAppliesToAllOpticalPaths = 'YES'
255260
256261 group = AnnotationGroup .from_dataset (dataset )
257262 assert isinstance (group , AnnotationGroup )
258263 assert isinstance (group .graphic_type , GraphicTypeValues )
259- assert isinstance (group .algorithm_type ,
260- AnnotationGroupGenerationTypeValues )
264+ assert isinstance (
265+ group .algorithm_type ,
266+ AnnotationGroupGenerationTypeValues
267+ )
261268 assert group .algorithm_identification is None
262269 assert isinstance (group .annotated_property_category , CodedConcept )
263270 assert isinstance (group .annotated_property_type , CodedConcept )
264271
272+ graphic_data = group .get_graphic_data (
273+ coordinate_type = AnnotationCoordinateTypeValues .SCOORD
274+ )
275+ assert isinstance (graphic_data , list )
276+ assert len (graphic_data ) == 3
277+ assert graphic_data [0 ].dtype == np .double
278+ assert graphic_data [0 ].shape [1 ] == 2
279+ assert graphic_data [0 ].shape [0 ] == 1
280+ assert np .array_equal (
281+ graphic_data [0 ],
282+ np .array ([[1.0 , 1.0 ]], dtype = np .double )
283+ )
284+
265285 names , values , units = group .get_measurements ()
266286 assert names == []
267287 assert units == []
0 commit comments