|
39 | 39 | from spatialdata import transform |
40 | 40 | from spatialdata._logging import logger as logging |
41 | 41 | from spatialdata._types import ArrayLike |
42 | | -from spatialdata.models import ( |
43 | | - Image2DModel, |
44 | | -) |
| 42 | +from spatialdata.models import Image2DModel, Labels2DModel |
45 | 43 | from spatialdata.transformations import get_transformation |
46 | 44 |
|
47 | 45 | from spatialdata_plot.pp.utils import _get_coordinate_system_mapping |
@@ -279,19 +277,21 @@ def _get_extent_after_transformations(element: Any, cs_name: str) -> Sequence[in |
279 | 277 | for images_key in sdata.images: |
280 | 278 | for e_id in element_ids: |
281 | 279 | if images_key == e_id: |
282 | | - if not isinstance(sdata.images[e_id], msi.multiscale_spatial_image.MultiscaleSpatialImage): |
| 280 | + if isinstance(sdata.images[e_id], spatial_image.SpatialImage): |
283 | 281 | extent[cs_name][e_id] = _get_extent_after_transformations(sdata.images[e_id], cs_name) |
284 | 282 | else: |
285 | | - pass |
| 283 | + img = Image2DModel.parse(sdata.images[e_id]["scale0"].ds.to_array().squeeze(axis=0)) |
| 284 | + extent[cs_name][e_id] = _get_extent_after_transformations(img, cs_name) |
286 | 285 |
|
287 | 286 | if has_labels and cs_contents.query(f"cs == '{cs_name}'")["has_labels"][0]: |
288 | 287 | for labels_key in sdata.labels: |
289 | 288 | for e_id in element_ids: |
290 | 289 | if labels_key == e_id: |
291 | | - if not isinstance(sdata.labels[e_id], msi.multiscale_spatial_image.MultiscaleSpatialImage): |
| 290 | + if isinstance(sdata.labels[e_id], spatial_image.SpatialImage): |
292 | 291 | extent[cs_name][e_id] = _get_extent_after_transformations(sdata.labels[e_id], cs_name) |
293 | 292 | else: |
294 | | - pass |
| 293 | + label = Labels2DModel.parse(sdata.labels[e_id]["scale0"].ds.to_array().squeeze(axis=0)) |
| 294 | + extent[cs_name][e_id] = _get_extent_after_transformations(label, cs_name) |
295 | 295 |
|
296 | 296 | if has_shapes and cs_contents.query(f"cs == '{cs_name}'")["has_shapes"][0]: |
297 | 297 | for shapes_key in sdata.shapes: |
|
0 commit comments