Closed BPdeRooij closed 3 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 98.63%. Comparing base (
548fc87
) to head (faa019e
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR implements some new features, refactors the annotations code and aims to simplify it. Most importantly are the addition of
AnnotatedGeometry
and new dunder methods inWsiAnnotations
. It is an initial idea and implementation for features, which could be useful. It would be great to further discuss these ideas and get feedback.Changes
AnnotatedGeometry
to inheret from forPoint
andPolgyon
classes. This simplifies code for thePoint
andPolygon
classes. This also allows us to extend to new annotated geometries forMultiPolygon
orMultiPoint
with our own annotation classes.__iadd__
and__isub__
methods forAnnotatedGeometry
that raises aTypeError
.__new__
function to be in line with shapely. This allows polygons (with holes) to be created directly as a dlupPolygon
.annotation_type
lookup into a single enum for ASAP, V7 and GeoJSON.annotation_type
toDarwinV7Metadata
lookup for colors. This is useful when a class for keypoints and polygons have the same label, but different colors. In that caseannotation_type
is needed to retrieve the correct color._is_rectangle
and added_is_alligned_rectangle
for determining unrotated bounding boxes.transform
DarwinV7Metadata
and_get_v7_metadata
can also be moved here._ComplexDarwinPolygonWrapper
directly into_parse_darwin_complex_polygon
.Changes made to
WsiAnnotations
:_available_labels
to use set instead of list for efficiencyWsiAnnotations
shapely.affinity.affine_transform
in theread_region
function.WsiAnnotations
dunder methods:__len__
as length of _layers__contains__
to check if aPoint
orPolygon
is in layers__add__
,__iadd__
and__radd__
for addition, in-place addition and right side addition.__sub__
,__isub__
and__rsub__
Further changes and comments:
__radd__
of lists of Polygons and PointsWsiAnnotations
.DarwinV7Metadata
and_get_v7_metadata
to utils file. This is not possible now becauseAnnotationType
is added to the metadata._geometry_to_geojson
,GeoJsonDict
,CoordinatesDict
,_is_rectangle
,_is_allagined_rectangle
) to util file to simplify code.WsiAnotations.copy
function uses deepcopy. The test and behavior for this method are not completely in line with the shallow and deep copy operations defined in the standard python library. Another__copy__
and__deepcopy__
method could be added.