-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend dunder methods and code simplification for annotations #251
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #251 +/- ##
==========================================
+ Coverage 98.53% 98.63% +0.09%
==========================================
Files 14 14
Lines 1091 1169 +78
==========================================
+ Hits 1075 1153 +78
Misses 16 16 ☔ View full report in Codecov by Sentry. |
BPdeRooij
force-pushed
the
feature/extend-dunder-methods
branch
from
August 13, 2024 11:32
06bb573
to
d1ecb26
Compare
jonasteuwen
approved these changes
Aug 13, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work!
jonasteuwen
pushed a commit
that referenced
this pull request
Aug 14, 2024
* Add z_index to geojson properties when importing and exporting * Fix annotation crop for Polygons in read_region and test_annotations * Created new AnnotatedGeometry, adhere to shapely dunder and functions * Add helper function to utils and Enum for Darwin/ASAP annotation types * Add darwin_annotation_type to color look up and move Darwin util function to utils * Bugfix for WsiAnnotations.filter function
jonasteuwen
pushed a commit
that referenced
this pull request
Aug 17, 2024
* Add z_index to geojson properties when importing and exporting * Fix annotation crop for Polygons in read_region and test_annotations * Created new AnnotatedGeometry, adhere to shapely dunder and functions * Add helper function to utils and Enum for Darwin/ASAP annotation types * Add darwin_annotation_type to color look up and move Darwin util function to utils * Bugfix for WsiAnnotations.filter function Refactor into multiple modules Support pickling and some other features Extend dunder methods and code simplification for annotations (#251) * Add z_index to geojson properties when importing and exporting * Fix annotation crop for Polygons in read_region and test_annotations * Created new AnnotatedGeometry, adhere to shapely dunder and functions * Add helper function to utils and Enum for Darwin/ASAP annotation types * Add darwin_annotation_type to color look up and move Darwin util function to utils * Bugfix for WsiAnnotations.filter function Removing files, improving test coverage and mypy
jonasteuwen
added a commit
that referenced
this pull request
Sep 26, 2024
* Updated workflows * Adding C++ TIFF writer - Bump version to 0.7 - Rebuild setup toolchain to pyproject.toml - Remove CLI utilities and tests - Rename dlup.types to dlup._types - Reduce cyclic imports - Remove color transform from internal_handler='pil' (working towards v1.0) - Bugfixes * Add ZSTD compression, reformat some files * First commit with geometries * First writing of Polygon * Some additional changes to cast the Polygon. * Commiting to not lose work * Updated for initial version of WsiAnnotations * updates * Some updates during development * Fix scaling issues * Added functionality to remove polygons and points and to rebuild the RTree * Implement complete initial version of geometry module * We actually need to iterate over all layers, not just polys * Implement scaling and offset functions * Adding functionality to reindex polygons * Created output container for results * Sensible updates * Add masking utility to AnnotationRegion * Memory optimizations * Adding sorting capabilities * Add bounding box * Added color LUT * Refactor * Extend dunder methods and code simplification for annotations (#251) * Add z_index to geojson properties when importing and exporting * Fix annotation crop for Polygons in read_region and test_annotations * Created new AnnotatedGeometry, adhere to shapely dunder and functions * Add helper function to utils and Enum for Darwin/ASAP annotation types * Add darwin_annotation_type to color look up and move Darwin util function to utils * Bugfix for WsiAnnotations.filter function Refactor into multiple modules Support pickling and some other features Extend dunder methods and code simplification for annotations (#251) * Add z_index to geojson properties when importing and exporting * Fix annotation crop for Polygons in read_region and test_annotations * Created new AnnotatedGeometry, adhere to shapely dunder and functions * Add helper function to utils and Enum for Darwin/ASAP annotation types * Add darwin_annotation_type to color look up and move Darwin util function to utils * Bugfix for WsiAnnotations.filter function Removing files, improving test coverage and mypy * Fixing the scaling, mypy and adding tests * minor changes in annotations * Updating geometry module, and its tests. * Rename modules, improve CI/CD * Almost done with the geometry module Strange bug remains. * Disable a few tests, squash pylint errors * Fixing some bugs when trees get invalidated This was a problem when the insertation order was not the same. * Do an allclose rather than equal * Weirdly enough different values on github * Maybe a sudo install won't hurt * Remove assert * Restructure C++ code * Restructure C++ code * Refactored code. * Refactoring * Refactor code * Rename functions, remove functions * Adhere to google C++ style guide * Maybe include stdexcept so that github understandS? * Reducing a few compiler warnings * Make sure mypy runs. * Convenient helper function * Implement XML export * Add xsdata to requirements * XML Schema reading now works * Order can be 0... * Several changes to support HaloXML * Improve test coverage * Improve test coverage to 90% * Streamlining * Trying to get better CI/CD coverage * Fix bug in annotations_experimental.py * Add more tests, and fix bug in process * Updating tests, updating schema, add box * Add more boxes functionality. * Refactor factory methods to factory.h * Refactor * Code simplifications * Some final memory improvements * Adding boxes to the geometry module * Improve CI/CD * Adding deprecation warnings * Streamline meson * Attempt lazy initialization of the geometry collection in the region class * Update tests for lazy evaluation * Fixing memory error in region.h. Fix tox * Improve workflows * Improve workflows * Update tox.ini * Remove line that doesn't work on github (?!) * Cleanup code * Try to run tests non-parallel * Squash errors for now * Fixes for ubuntu * Improving annotations to mask conversion * Reformat * Add Lazy Array * Added some extra functionality to lazy array * Added lazy evaluation for PolygonCollection * Added lazy evaluation for PolygonCollection * Make precommit run * Updates to CI * Fix mypy * Add ROI to the GeometryCollection * Added ROIs to DLUP XML * Added ROIs to output xml and parsing * move declarations to headers --------- Co-authored-by: Bart de Rooij <33282665+BPdeRooij@users.noreply.github.com> Co-authored-by: Jonas Teuwen <j.teuwen@.nki.nl> Co-authored-by: JorenB <jorenb@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.