Spatialdata wrong shapes translation

I have a xenium image, which is the concatenation of 4 different samples. To get samples, I use bounding_box_query().
For instance, I get the sample number 3 like that:

crop_sample_3 = lambda x: bounding_box_query(
    min_coordinate=[15000, 70000],
    max_coordinate=[17000, 70000 + 17000],
    axes=("x", "y"),

sdata_sample3 = crop_sample_3(sdata)

Then, I need to reset the coordinates (I want the point in the upper left corner of the image to have coordinates (0, 0) instead of (15000, 70000).
To do so, I create the following translation:

translation = Translation([0, 0], axes=("x", "y"))

Then I apply the transformation to my spatialdata object:

set_transformation(sdata_sample3.images["morphology_mip"], translation, to_coordinate_system="global")
set_transformation(sdata_sample3.labels["cell_labels"], translation, to_coordinate_system="global")
set_transformation(sdata_sample3.shapes["cell_boundaries"], translation, to_coordinate_system="global")

But, the transformation works fine for images and labels, but It does something really weirds for shapes: shapes are translated on different coordinates, and seemed to be ‘downscaled’ (They appear smaller when I plot them).

In the image, i applied the same translation to the image, labels, and to one shape. We see that the shape got translated in the bottom right corner. tried many scaling/translation coordinates, the result is always weird.

I cant put more than 1 image in my post, so:
Here is the cropped spatialdata:

Here is what small translation applied only to image and one label looks like:
So i expect, when translating shapes, that they move the same way that image and labels moved

Hi, thanks for reaching out. Can you please post the code that you use for plotting?

One note, the syntax required for translation requires a fix, here (0, 0) will be used as the translation vector, so no translation will be made. To translate to 0, 0 you will need to translate by [-15000, -70000].

Hello, thanks for your answer !

Concerning the syntax for translation, I started by translating by [-15000, -70000], but the output were coordinates whose origin (in the upper left of the image) was the point (-15000, -70000), this is why I changed for [0, 0]

Here is all the code I used for plotting images

# Load spatial data
sdata = sd.read_zarr("/data/tmp/aconsten/data/imm_05.zarr")

# Crop spatial data. I selected a tile of size (2000, 2000)
crop_sample_3 = lambda x: bounding_box_query(
    min_coordinate=[15000, 70000],
    max_coordinate=[15000 + 2000, 70000 + 2000],
    axes=("x", "y"),

sdata_sample3 = crop_sample_3(sdata)

# plot image with shapes and labels"Image with shapes and labels")

# Define small transformation of 500 pixels
translation = Translation([15000 + 500, 70000 + 500], axes=("x", "y"))

# Plot translated image with shapes and labels
set_transformation(sdata_sample3.images["morphology_mip"], translation, to_coordinate_system="global")"Image translated with shapes and labels")

# Plot translated image and labels, with shapes
set_transformation(sdata_sample3.labels["cell_labels"], translation, to_coordinate_system="global")"Image & labels translated with shapes")

# Plot translated image, labels and shapes. This is the weird plot as shown above
set_transformation(sdata_sample3.shapes["cell_boundaries"], translation, to_coordinate_system="global")"Image & labels & shapes translated")

Here is what happens if i set the translation to [-15000, -70000], and apply to to the image. Image gets located in position (-15000, -70000), and labels are in position (15000, 70000)

translation = Translation([-15000, -70000], axes=("x", "y"))
set_transformation(sdata_sample3.images["morphology_mip"], translation, to_coordinate_system="global")"Image with [-15000, -70000] translation")