-
Notifications
You must be signed in to change notification settings - Fork 35
VisiumHD: load scalefactor microns_per_pixel in anndata #286
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
Comments
Hi @ConstensouxAlexis, would it be an option to retrieve this coefficient from the coordinate transformation metadata? from spatialdata.transformations import get_transformation
transformation = get_transformation(sdata['my_element'], to_coordinate_system='my_coordinate_system')
# if it's a scale
print(transformation.scale)
# in the general case, to get the `x` scale factor
transformation.to_affine_matrix(input_axes=('x',), output_axes=('x',)).flatten().item() Adding the metadata would work for VisiumHD, but the approach above (or something adapted from it) would work for any tech and any image. |
Hi, thank you for your answer ! I might be wrong, but I think that if we want to derive the number of micron per pixel from the transformation metadata, we need for at least one image resolution the absolute value of the number of microns per pixel. I think that this value depends on the microscope used to generate the full resolution image. For instance, on my VisiumHD samples, this value is different accross samples, thus the "micron_per_pixel" key in the scalefactors.json is different. However I think my usecase is marginal and I am fine parsing this value manually ! |
You are right, in the sense that the information on how to map pixels to microns should be present somewhere in the transformations, but if this is available there is no need to explicitly pass the metadata. Practically, the general case is that there is a series of transformations to map the image to a physical space (let's call it Also the functions described in this issue would be of help: scverse/spatialdata#436. Regarding timelines, we are currently working on the OME-NGFF side to push for the release of the coordinate transformation specification. When this is available the ergonomics around working with units will improve, by implementing the functions in the issue above above. For the moment I'd suggest either
|
Ok, thank you very much for explanations ! |
Hello,
Segmentation of nuclei on VisiumHD H&E image might require (at least for StarDist segmentation model) to have the micron per pixel information (since pre trained models can be trained on H&E images with different micron per pixel ratio, it is sometimes needed to rescale the image).
Could it be possibe for the visiumHD reader to parse this info and store it somewhere in the Anndata ? Thank you very much !
Alexis
The text was updated successfully, but these errors were encountered: