Skip to content
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

Bug/fix annotation sorting #203

Merged
merged 8 commits into from
Dec 2, 2023
Merged

Bug/fix annotation sorting #203

merged 8 commits into from
Dec 2, 2023

Conversation

jonasteuwen
Copy link
Contributor

This PR fixes the way the annotations are sorted in the GeoJSON output. Previously, the output of WsiAnnotations.as_geojson() exported them in the order they were inserted without taking into account the sorting order selected while this is actually required to get the proper order of annotations. Also the tests are updated to reflect this.

annotation = shapely.geometry.MultiPoint(annotation_list)
json_dict = _geometry_to_geojson(annotation, label=label)

json_dict["id"] = str(idx)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there could be a placeholder for id in _geometry_to_geojson. Also is the key "id" in data ever used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do a placeholder, but we cannot set it as it denotes the order of the annotations and this is only available in this function. It’s also required by GeoJSON

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay as you prefer

Copy link

@sinberlin2 sinberlin2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this PR:

  • Split_by_label option removed in as_geojson() of WsiAnnotations.
  • Consecutive annotations are grouped as long as they are of the same label to reduce the size of the output
  • The proper order of annotations is retained in in as_geojson() of WsiAnnotations.
    Tests:
    A number of annotations for a slide are defined using ASAP format. The test checks whether the annotations are the same after being converted to geojson. The tests covers areas with annotations and an area of the slide where there are no annotations (and area is therefore None).

@jonasteuwen jonasteuwen merged commit 368d019 into main Dec 2, 2023
8 checks passed
@jonasteuwen jonasteuwen deleted the bug/fix-annotation-sorting branch December 2, 2023 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants