Skip to content

Export the real global coordinates of cells (Xenium) #205

Open

Description

@weilicode

Hi,

I am working with a Xenium dataset that includes an H&E image as well as an alignmentmatrix.csv file. I understand that this alignment matrix can be used to transform the image data into the global coordinate system.
image

I have successfully created an sdata object from this dataset.
How can I locate a specific cell within the H&E image? More specifically, now the H&E and the cell location are aligned, but how can I explicitly know the exact cell locations on the H&E image? Thanks for your time!!

image

Activity

  1. LucaMarconato commented on Oct 3, 2024

    @LucaMarconato
    Member

    Hi, you can proceed as follows:

    1. you need to know the transformation between the image and the common coordinate system (global). You can use get_transformation(). For more complex cases you could use get_transformation_between_coordinate_systems(). Not needed here.
    2. you need to know the intrinsic coordinates (=pixel coordinates) of the image region(s) you want to query. Let's call them the "boxes".
    3. you need to transform these coordinates using the transformation found above. You can either use normal numpy operations on the matrix given by your_transformation.to_affine_matrix() or if you want you can also use the spatialdata APIs, in this second case, you need to create a shapes element with the box or list of boxes you have (using ShapesModel.parse()) and then call spatialdata.transform().
    4. After you get the coordinates of an image region (a box), you can use the bounding_box_query() API. This PR (unreleased) vectorize bounding box query spatialdata#699 allows to perform the query of all the regions in one go.
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions