Skip to content

Points transformation ignored #182

Closed

Description

@aeisenbarth

When plotting points and the points has a transformation additionally to the coordinates in the dataframe, the transformation is ignored.

This could be related to #171.

Example code

from spatialdata import SpatialData
from spatialdata.models import Image2DModel, PointsModel
from spatialdata.transformations import Scale
import numpy as np
import pandas as pd
import spatialdata_plot

sdata = SpatialData(
    images={
        "image1": Image2DModel.parse(
            np.full((10, 10, 3), fill_value=128), dims=("y", "x", "c")
        )
    },
    points={
        "points1": PointsModel.parse(
            pd.DataFrame({"y": [0.1, 0.1, 0.9, 0.9], "x": [0.1, 0.9, 0.9, 0.1]}),
            transformations={"global": Scale([10, 10], ("y", "x"))},
        )
    },
)
sdata.pl.render_images("image1").pl.render_points("points1").pl.show()

Actual:
image

Expected:
image

Workaround

Convert the coordinates in the dataframe to the global coordinate system (either overwriting, or storing under another key):

sdata.points["points1"] = sdata.transform_element_to_coordinate_system(
    sdata.points["points1"], "global"
)

Now the points have transformation Identity() for which it is no problem to be ignored.

Activity

  1. added this to the v0.1.0 release milestone on Dec 8, 2023
  2. timtreis commented on Dec 8, 2023

    @timtreis
    Member

    #198 now produces:
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions