@@ -134,7 +134,7 @@ def create_annotation_dicom(annot_arrays, slide_file, geojson):
134134
135135 # add the annotation data
136136 ds .AnnotationGroupSequence = []
137- i = 0
137+ i = 1
138138 idx = 1
139139 point_indices = []
140140 # make the array first?
@@ -298,7 +298,7 @@ def dicomToCamic(annot_path, image_dimensions, output_file, source_url=None, sli
298298 newFeature = deepcopy (featureTemplate )
299299 newFeature ['geometry' ]['type' ] = "Ellipse"
300300 newFeature ['geometry' ]['coordinates' ] = [center_x , center_y ]
301- newFeature ['geometry' ]["radius" ] = [major_axis_length ,minor_axis_length ],
301+ newFeature ['geometry' ]["radius" ] = [major_axis_length ,minor_axis_length ]
302302 newFeature ['geometry' ]["rotation" ] = rotation
303303 newFeature ['bound' ]['type' ] = "Point"
304304 newFeature ['bound' ]['coordinates' ] = [center_x , center_y ]
@@ -378,11 +378,15 @@ def dicomToCamic(annot_path, image_dimensions, output_file, source_url=None, sli
378378 #print("prev", prevIndex, "idx", idx)
379379 # make a thing
380380 points = coordinates_array [prevIndex :end_idx , :]
381- points = np .concatenate ((points , [points [0 ]]))
381+ polygon = np .concatenate ((points , [points [0 ]]))
382382 #print('len(points)', len(points))
383383 if len (points ) > 0 :
384384 newFeature = deepcopy (featureTemplate )
385- newFeature ['geometry' ]['coordinates' ].append (points .tolist ())
385+ if x .GraphicType == "POLYLINE" :
386+ newFeature ['geometry' ]['type' ] = "Polyline"
387+ newFeature ['geometry' ]['coordinates' ].append (points .tolist ())
388+ else :
389+ newFeature ['geometry' ]['coordinates' ].append (polygon .tolist ())
386390 bounding_box = _makeBound (points )
387391 # [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
388392 newFeature ['bound' ]['coordinates' ].append (bounding_box )
@@ -401,10 +405,14 @@ def dicomToCamic(annot_path, image_dimensions, output_file, source_url=None, sli
401405 # and the bound
402406 # then add the last one
403407 points = coordinates_array [prevIndex :, :]
404- points = np .concatenate ((points , [points [0 ]]))
408+ polygon = np .concatenate ((points , [points [0 ]]))
405409 if len (points ) > 0 :
406410 newFeature = deepcopy (featureTemplate )
407- newFeature ['geometry' ]['coordinates' ].append (points .tolist ())
411+ if x .GraphicType == "POLYLINE" :
412+ newFeature ['geometry' ]['type' ] = "Polyline"
413+ newFeature ['geometry' ]['coordinates' ].append (points .tolist ())
414+ else :
415+ newFeature ['geometry' ]['coordinates' ].append (polygon .tolist ())
408416 bounding_box = _makeBound (points )
409417 # [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
410418 newFeature ['bound' ]['coordinates' ].append (bounding_box )
@@ -422,9 +430,13 @@ def dicomToCamic(annot_path, image_dimensions, output_file, source_url=None, sli
422430 else :
423431 # whole thing at once. Only do area and circumference here.
424432 points = coordinates_array
425- points = np .concatenate ((points , [points [0 ]]))
433+ polygon = np .concatenate ((points , [points [0 ]]))
426434 newFeature = deepcopy (featureTemplate )
427- newFeature ['geometry' ]['coordinates' ].append (points .tolist ())
435+ if x .GraphicType == "POLYLINE" :
436+ newFeature ['geometry' ]['type' ] = "Polyline"
437+ newFeature ['geometry' ]['coordinates' ].append (points .tolist ())
438+ else :
439+ newFeature ['geometry' ]['coordinates' ].append (polygon .tolist ())
428440 bounding_box = _makeBound (points )
429441 # [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
430442 newFeature ['bound' ]['coordinates' ].append (bounding_box )
0 commit comments