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

Bounding box property WSIAnnotations class errors when loading multipoint. #150

Closed
Dafidofff opened this issue Mar 14, 2023 · 2 comments
Closed
Labels
bug Something isn't working Stale

Comments

@Dafidofff
Copy link

Describe the bug
When calling the property bounding_box of the WSIAnnotation class return an the following attribute error
AttributeError: 'Point' object has no attribute 'exterior'

To Reproduce

from pathlib import Path

from dlup import SlideImage
from dlup.annotations import WsiAnnotations


slide_path = Path("/data/datasets/NKI/slides/1285/195551/T17-06278 A1 PD-L1 (22C3).svs")
anno_path = Path("/data/datasets/NKI/data/annotations/studies/slidescore_1285/v20230210-0/annotations/wsong@ellogon.ai/195551/Lymphocytes.json")  # --> multipoint annotation
dlup_slide = SlideImage.from_file_path(slide_path)
dlup_anno = WsiAnnotations.from_geojson(anno_path)

# wsi = dlup_slide.read_region(location=(0,0), size=dlup_slide.size, scaling=1.0)
anno_in_region = dlup_anno.read_region(coordinates=(0,0), region_size=dlup_slide.size, scaling=0.01)
print(anno_in_region)

bounds = dlup_anno.bounding_box

Gives the following error:

Traceback (most recent call last):
  File "/homes/dwessels/LightningGon/test_multipoint.py", line 41, in <module>
    bounds = dlup_anno.bounding_box
  File "/homes/dwessels/.cache/pypoetry/virtualenvs/lgon-WMDuiRwL-py3.10/lib/python3.10/site-packages/dlup/annotations.py", line 321, in bounding_box
    curr_bboxes = self[label].bounding_boxes
  File "/homes/dwessels/.cache/pypoetry/virtualenvs/lgon-WMDuiRwL-py3.10/lib/python3.10/site-packages/dlup/annotations.py", line 227, in bounding_boxes
    data = [np.asarray(annotation.envelope.exterior.coords) for annotation in self.as_list()]
  File "/homes/dwessels/.cache/pypoetry/virtualenvs/lgon-WMDuiRwL-py3.10/lib/python3.10/site-packages/dlup/annotations.py", line 227, in <listcomp>
    data = [np.asarray(annotation.envelope.exterior.coords) for annotation in self.as_list()]
AttributeError: 'Point' object has no attribute 'exterior'

Expected behavior
Give back then bounds of the point annotations, something like the following:

points = dlup_anno._annotations["Lymphocytes"].as_list()
bounds = [point.bounds[:2] for point in points]

Environment
dlup version: 0.3.23
How installed: via Git on branch #148
Python version: 3.10.8
Operating System: Linux

@Dafidofff Dafidofff added the bug Something isn't working label Mar 14, 2023
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

@jonasteuwen
Copy link
Contributor

This will be fixed in the upcoming release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

2 participants