Skip to content

Commit

Permalink
Fix transform_to_data_extent converting labels to images (#791)
Browse files Browse the repository at this point in the history
* Add test case for issue 783

* Pass parameter return_regions_as_labels=True to rasterize to preserve labels

---------

Co-authored-by: Luca Marconato <[email protected]>
  • Loading branch information
aeisenbarth and LucaMarconato authored Dec 16, 2024
1 parent 803a66e commit 243554e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/spatialdata/_core/operations/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def transform_to_data_extent(
target_width=target_width,
target_height=None,
target_depth=None,
return_regions_as_labels=True,
)
sdata_to_return_elements[element_name] = rasterized
else:
Expand Down
2 changes: 2 additions & 0 deletions tests/core/operations/test_spatialdata_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
PointsModel,
ShapesModel,
TableModel,
get_model,
get_table_keys,
)
from spatialdata.testing import assert_elements_dict_are_identical, assert_spatial_data_objects_are_identical
Expand Down Expand Up @@ -474,6 +475,7 @@ def test_transform_to_data_extent(full_sdata: SpatialData, maintain_positioning:
for element in elements:
before = full_sdata[element]
after = sdata[element]
assert get_model(after) == get_model(before)
data_extent_before = get_extent(before, coordinate_system="global")
data_extent_after = get_extent(after, coordinate_system="global")
# huge tolerance because of the bug with pixel perfectness
Expand Down

0 comments on commit 243554e

Please sign in to comment.