Skip to content

Commit

Permalink
paquo.images: support loading annotations if image file is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-- committed Aug 7, 2020
1 parent 88668f3 commit cd6ff6b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions paquo/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
from typing import Iterator, Optional, Any, List

from paquo._base import QuPathBase
from paquo._logging import redirect
from paquo._logging import redirect, get_logger
from paquo._utils import cached_property
from paquo.hierarchy import QuPathPathObjectHierarchy
from paquo.java import String, DefaultProjectImageEntry, ImageType, ImageData, IOException, URI, URISyntaxException

_log = get_logger(__name__)


class ImageProvider(ABC):
"""Maps image ids to paths and paths to image ids."""
Expand Down Expand Up @@ -366,7 +368,11 @@ def properties(self, value):
@cached_property
def hierarchy(self) -> QuPathPathObjectHierarchy:
"""the image entry hierarchy. it contains all annotations"""
return QuPathPathObjectHierarchy(self._image_data.getHierarchy())
try:
return QuPathPathObjectHierarchy(self._image_data.getHierarchy())
except OSError:
_log.warning("could not open image data. loading annotation hierarchy from project.")
return QuPathPathObjectHierarchy(self.java_object.readHierarchy())

def __repr__(self):
return f"<ImageEntry('{self.image_name}')>"
Expand Down

0 comments on commit cd6ff6b

Please sign in to comment.