Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nkuweili opened this issue Sep 9, 2024 · 1 comment
Open

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

nkuweili opened this issue Sep 9, 2024 · 1 comment

Comments

@nkuweili
Copy link

nkuweili commented Sep 9, 2024

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

@LucaMarconato
Copy link
Member

LucaMarconato commented Oct 3, 2024

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants