Skip to content

Commit 134c75b

Browse files
author
nanli-emory
committed
fixed the issue that polyline is closed
1 parent eeb96e7 commit 134c75b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

DicomAnnotUtils.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -378,13 +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)
385385
if x.GraphicType == "POLYLINE":
386386
newFeature['geometry']['type'] = "Polyline"
387-
newFeature['geometry']['coordinates'].append(points.tolist())
387+
newFeature['geometry']['coordinates'].append(points.tolist())
388+
else:
389+
newFeature['geometry']['coordinates'].append(polygon.tolist())
388390
bounding_box = _makeBound(points)
389391
# [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
390392
newFeature['bound']['coordinates'].append(bounding_box)
@@ -403,12 +405,14 @@ def dicomToCamic(annot_path, image_dimensions, output_file, source_url=None, sli
403405
# and the bound
404406
# then add the last one
405407
points = coordinates_array[prevIndex:, :]
406-
points = np.concatenate((points, [points[0]]))
408+
polygon = np.concatenate((points, [points[0]]))
407409
if len(points) > 0:
408410
newFeature = deepcopy(featureTemplate)
409411
if x.GraphicType == "POLYLINE":
410412
newFeature['geometry']['type'] = "Polyline"
411-
newFeature['geometry']['coordinates'].append(points.tolist())
413+
newFeature['geometry']['coordinates'].append(points.tolist())
414+
else:
415+
newFeature['geometry']['coordinates'].append(polygon.tolist())
412416
bounding_box = _makeBound(points)
413417
# [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
414418
newFeature['bound']['coordinates'].append(bounding_box)
@@ -426,11 +430,13 @@ def dicomToCamic(annot_path, image_dimensions, output_file, source_url=None, sli
426430
else:
427431
# whole thing at once. Only do area and circumference here.
428432
points = coordinates_array
429-
points = np.concatenate((points, [points[0]]))
433+
polygon = np.concatenate((points, [points[0]]))
430434
newFeature = deepcopy(featureTemplate)
431435
if x.GraphicType == "POLYLINE":
432436
newFeature['geometry']['type'] = "Polyline"
433-
newFeature['geometry']['coordinates'].append(points.tolist())
437+
newFeature['geometry']['coordinates'].append(points.tolist())
438+
else:
439+
newFeature['geometry']['coordinates'].append(polygon.tolist())
434440
bounding_box = _makeBound(points)
435441
# [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
436442
newFeature['bound']['coordinates'].append(bounding_box)

0 commit comments

Comments
 (0)