NKI-AI / dlup

Dlup are the Deep Learning Utilities for Pathology developed at the Netherlands Cancer Institute
Apache License 2.0
25 stars 7 forks source link

Implement WsiAnnotations in C++ #252

Closed jonasteuwen closed 2 months ago

jonasteuwen commented 3 months ago

The WsiAnnotations have been rewritten using boost.Polygon, replacing shapely. The current implementation with shapely has a few issues:

The proposal is to keep WsiAnnotations around until v1.0.0, add deprecation warnings to the current calls that are not 1-1 compatible with the new SlideAnnotations (available in dlup.annotations_experimental). In particular these features are implemented

The function SlideAnnotations.read_region() returns an AnnotationRegion object rather than list of objects. You can access the polygons using AnnotationRegion.polygons, points using AnnotationRegion.points and boxes using AnnotationRegion.boxes. The first two behave as expected, but the boxes are not cropped to the read_region, so it is possible the (x, y) coordinate is negative (slightly outside of the read_region). In addition there is a call to_mask() that generates the mask. The evaluation is lazy, so a call to read_region does not execute the pipeline until you access the polygons, points, boxes or mask in the object.

The SlideAnnotations has a few new calls:

Lazy evaluation

The library supports lazy evaluation, most operations are only performed when requesting masks or polygons.

WARNING: The operations might not all be thread-safe due to their in-place modification behaviour.

Something that might be nice to have

Please add more possible features.

moerlemans commented 3 months ago

To install I had to pip install meson pip install ninja pip install dlup and meson build to get it working. Maybe others can test this in their setup and we can change the readme.md to reflect all of this. I also had to remove the pure=false from the meson.build file (at line 7) because of meson version issues.

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 83.61757% with 317 lines in your changes missing coverage. Please review.

Project coverage is 85.73%. Comparing base (8d31221) to head (0009ba5). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dlup/annotations_experimental.py 67.10% 131 Missing and 71 partials :warning:
dlup/utils/geometry_xml.py 50.49% 41 Missing and 9 partials :warning:
tests/test_slide_annotations.py 90.35% 24 Missing and 6 partials :warning:
dlup/geometry.py 93.95% 9 Missing and 8 partials :warning:
dlup/annotations.py 78.43% 8 Missing and 3 partials :warning:
tests/test_geometry.py 98.34% 6 Missing :warning:
tests/test_annotations.py 87.50% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #252 +/- ## =========================================== - Coverage 98.63% 85.73% -12.90% =========================================== Files 14 45 +31 Lines 1169 4985 +3816 Branches 0 1074 +1074 =========================================== + Hits 1153 4274 +3121 - Misses 16 490 +474 - Partials 0 221 +221 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.