dlup 0.8.1__cp310-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. dlup/__init__.py +38 -0
  2. dlup/_background.pyd +0 -0
  3. dlup/_background.pyi +27 -0
  4. dlup/_exceptions.py +46 -0
  5. dlup/_geometry.pyd +0 -0
  6. dlup/_geometry.pyi +137 -0
  7. dlup/_image.py +673 -0
  8. dlup/_libtiff_tiff_writer.pyd +0 -0
  9. dlup/_libtiff_tiff_writer.pyi +32 -0
  10. dlup/_region.py +97 -0
  11. dlup/_types.py +30 -0
  12. dlup/annotations/__init__.py +1081 -0
  13. dlup/annotations/exporters/__init__.py +14 -0
  14. dlup/annotations/exporters/dlup_xml.py +100 -0
  15. dlup/annotations/exporters/geojson.py +120 -0
  16. dlup/annotations/exporters/slidescore_tsv.py +163 -0
  17. dlup/annotations/importers/__init__.py +14 -0
  18. dlup/annotations/importers/asap_xml.py +130 -0
  19. dlup/annotations/importers/darwin_json.py +273 -0
  20. dlup/annotations/importers/dlup_xml.py +145 -0
  21. dlup/annotations/importers/geojson.py +145 -0
  22. dlup/annotations/importers/halo_xml.py +138 -0
  23. dlup/annotations/importers/slidescore_json.py +172 -0
  24. dlup/annotations/importers/slidescore_tsv.py +341 -0
  25. dlup/annotations/tags.py +26 -0
  26. dlup/backends/__init__.py +33 -0
  27. dlup/backends/common.py +257 -0
  28. dlup/backends/fastslide_backend.py +144 -0
  29. dlup/backends/fimage_backend.py +139 -0
  30. dlup/backends/openslide_backend.py +241 -0
  31. dlup/backends/tifffile_backend.py +139 -0
  32. dlup/background.py +151 -0
  33. dlup/data/__init__.py +14 -0
  34. dlup/data/dataset.py +712 -0
  35. dlup/geometry/__init__.py +528 -0
  36. dlup/geometry/marching_squares.pyd +0 -0
  37. dlup/geometry/measure.py +35 -0
  38. dlup/logging.py +104 -0
  39. dlup/py.typed +0 -0
  40. dlup/tiling.py +195 -0
  41. dlup/tools.py +92 -0
  42. dlup/utils/__init__.py +15 -0
  43. dlup/utils/annotations_utils.py +100 -0
  44. dlup/utils/backends.py +47 -0
  45. dlup/utils/geometry_xml.py +302 -0
  46. dlup/utils/image.py +41 -0
  47. dlup/utils/imports.py +42 -0
  48. dlup/utils/schemas/dlup_schema_v1.0.xsd +343 -0
  49. dlup/utils/schemas/generated/__init__.py +35 -0
  50. dlup/utils/schemas/generated/dlup_schema_v1_0.py +629 -0
  51. dlup/utils/tifffile_utils.py +108 -0
  52. dlup/writers.py +458 -0
  53. dlup-0.8.1.dist-info/METADATA +20 -0
  54. dlup-0.8.1.dist-info/RECORD +55 -0
  55. dlup-0.8.1.dist-info/WHEEL +4 -0
dlup/__init__.py ADDED
@@ -0,0 +1,38 @@
1
+ # Copyright 2024 AI for Oncology Research Group. All Rights Reserved.
2
+ # Copyright 2024 Jonas Teuwen. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ from ._image import SlideImage, SlideImageView, Resampling
17
+ from ._region import BoundaryMode, RegionView
18
+
19
+ from .annotations import SlideAnnotations, SlideAnnotationsView
20
+ from .data.dataset import SlideDataset, TilingConfig, MaskConfig, ImageConfig, AnnotationConfig
21
+
22
+ __author__ = """dlup contributors"""
23
+ __email__ = "j.teuwen@nki.nl"
24
+ __version__ = "0.8.1"
25
+ __all__ = (
26
+ "SlideImage",
27
+ "SlideImageView",
28
+ "SlideDataset",
29
+ "SlideAnnotations",
30
+ "SlideAnnotationsView",
31
+ "RegionView",
32
+ "BoundaryMode",
33
+ "Resampling",
34
+ "TilingConfig",
35
+ "MaskConfig",
36
+ "ImageConfig",
37
+ "AnnotationConfig",
38
+ )
dlup/_background.pyd ADDED
Binary file
dlup/_background.pyi ADDED
@@ -0,0 +1,27 @@
1
+ # Copyright 2024 AI for Oncology Research Group. All Rights Reserved.
2
+ # Copyright 2024 Jonas Teuwen. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import numpy as np
17
+ import numpy.typing as npt
18
+
19
+ def get_foreground_indices_numpy(
20
+ image_width: int,
21
+ image_height: int,
22
+ image_slide_average_mpp: float,
23
+ background_mask: npt.NDArray[np.int_],
24
+ regions_array: npt.NDArray[np.float64],
25
+ threshold: float,
26
+ foreground_indices: npt.NDArray[np.int64],
27
+ ) -> int: ...
dlup/_exceptions.py ADDED
@@ -0,0 +1,46 @@
1
+ # Copyright 2024 AI for Oncology Research Group. All Rights Reserved.
2
+ # Copyright 2024 Jonas Teuwen. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """Custom exceptions for dlup."""
16
+
17
+ from __future__ import annotations
18
+
19
+
20
+ class DlupError(Exception):
21
+ """Base class for exceptions in dlup."""
22
+
23
+ pass
24
+
25
+
26
+ class UnsupportedSlideError(DlupError):
27
+ """Raised when a slide is not supported."""
28
+
29
+ def __init__(self, msg: str, identifier: str | None = None):
30
+ msg = msg if identifier is None else f"slide '{identifier}': " + msg
31
+ super().__init__(self, msg)
32
+
33
+
34
+ class SlideError(RuntimeError):
35
+ """Raised when an error occurs with a slide."""
36
+
37
+ def __init__(self, msg: str, identifier: str | None = None):
38
+ msg = msg if identifier is None else f"slide '{identifier}': " + msg
39
+ super().__init__(self, msg)
40
+
41
+
42
+ class AnnotationError(DlupError):
43
+ """Raised when an annotation is invalid."""
44
+
45
+ def __init__(self, msg: str):
46
+ super().__init__(self, msg)
dlup/_geometry.pyd ADDED
Binary file
dlup/_geometry.pyi ADDED
@@ -0,0 +1,137 @@
1
+ # Copyright 2024 AI for Oncology Research Group. All Rights Reserved.
2
+ # Copyright 2024 Jonas Teuwen. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ from typing import Callable, overload
16
+
17
+ import numpy as np
18
+ from dlup._types import GenericNumber
19
+ from dlup.geometry import Box as Box_
20
+ from dlup.geometry import Point as Point_
21
+ from dlup.geometry import Polygon as Polygon_
22
+ from numpy.typing import NDArray
23
+
24
+ class Polygon:
25
+ @property
26
+ def fields(self) -> list[str]: ...
27
+ def get_exterior(self) -> list[tuple[float, float]]: ...
28
+ def get_interiors(self) -> list[list[tuple[float, float]]]: ...
29
+ def contains(self, other: Polygon_) -> bool: ...
30
+ def correct_orientation(self) -> None: ...
31
+ @property
32
+ def bounding_box(self) -> "Box": ...
33
+ def scale(self, scaling: float) -> None: ...
34
+ def clone(self) -> "Polygon": ...
35
+ @property
36
+ def area(self) -> float: ...
37
+
38
+ def set_polygon_factory(factory: Callable[[Polygon_], Polygon_]) -> None: ...
39
+
40
+ class Point:
41
+ @property
42
+ def fields(self) -> list[str]: ...
43
+ def scale(self, scaling: float) -> None: ...
44
+ def get_coordinates(self) -> tuple[float, float]: ...
45
+ @property
46
+ def x(self) -> float: ...
47
+ @property
48
+ def y(self) -> float: ...
49
+ def clone(self) -> "Point": ...
50
+
51
+ def set_point_factory(factory: Callable[[Point_], Point_]) -> None: ...
52
+
53
+ class Box:
54
+ @property
55
+ def fields(self) -> list[str]: ...
56
+ def as_polygon(self) -> Polygon_: ...
57
+ @property
58
+ def area(self) -> float: ...
59
+ def scale(self, scaling: float) -> None: ...
60
+ @property
61
+ def coordinates(self) -> tuple[float, float]: ...
62
+ @property
63
+ def size(self) -> tuple[float, float]: ...
64
+ def clone(self) -> "Box": ...
65
+
66
+ def set_box_factory(factory: Callable[[Box_], Box_]) -> None: ...
67
+
68
+ class LazyArray:
69
+ def __array__(self) -> NDArray[np.int_]: ...
70
+ def numpy(self) -> NDArray[np.int_]: ...
71
+
72
+ class PolygonCollection:
73
+ def get_geometries(self) -> list[Polygon_]: ...
74
+ def to_mask(self) -> LazyArray: ...
75
+
76
+ class AnnotationRegion:
77
+ @property
78
+ def polygons(self) -> PolygonCollection: ...
79
+ @property
80
+ def rois(self) -> PolygonCollection: ...
81
+ @property
82
+ def points(self) -> list[Point_]: ...
83
+ @property
84
+ def boxes(self) -> list[Box_]: ...
85
+ @property
86
+ def has_rois(self) -> bool: ...
87
+
88
+ class GeometryCollection:
89
+ def add_polygon(self, polygon: Polygon) -> None: ...
90
+ def add_roi(self, roi: Polygon) -> None: ...
91
+ def add_point(self, point: Point) -> None: ...
92
+ def add_box(self, box: Box) -> None: ...
93
+ @property
94
+ def polygons(self) -> list[Polygon_]: ...
95
+ @property
96
+ def rois(self) -> list[Polygon_]: ...
97
+ @property
98
+ def points(self) -> list[Point_]: ...
99
+ @property
100
+ def boxes(self) -> list[Box_]: ...
101
+ def set_offset(self, offset: tuple[float, float]) -> None: ...
102
+ def rebuild_rtree(self) -> None: ...
103
+ def reindex_polygons(self, index_map: dict[str, int]) -> None: ...
104
+ @overload
105
+ def remove_point(self, index: int) -> None: ...
106
+ @overload
107
+ def remove_point(self, point: Point_) -> None: ...
108
+ @overload
109
+ def remove_polygon(self, index: int) -> None: ...
110
+ @overload
111
+ def remove_polygon(self, polygon: Polygon_) -> None: ...
112
+ @overload
113
+ def remove_roi(self, index: int) -> None: ...
114
+ @overload
115
+ def remove_roi(self, roi: Polygon_) -> None: ...
116
+ @overload
117
+ def remove_box(self, index: int) -> None: ...
118
+ @overload
119
+ def remove_box(self, box: Box_) -> None: ...
120
+ def sort_polygons(self, key: Callable[[Polygon_], int | float | str | None], reverse: bool) -> None: ...
121
+ @property
122
+ def bounding_box(self) -> tuple[tuple[float, float], tuple[float, float]]: ...
123
+ def size(self) -> int: ...
124
+ def simplify(self, tolerance: float) -> None: ...
125
+ def scale(self, scaling: float) -> None: ...
126
+ def read_region(
127
+ self,
128
+ coordinates: tuple[GenericNumber, GenericNumber],
129
+ scaling: float,
130
+ size: tuple[GenericNumber, GenericNumber],
131
+ ) -> AnnotationRegion: ...
132
+ @property
133
+ def rtree_invalidated(self) -> bool: ...
134
+ @property
135
+ def index_map(self) -> dict[str, int]: ...
136
+ @property
137
+ def has_rois(self) -> bool: ...