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
Activity
LucaMarconato commentedon Mar 11, 2025
Hi @ConstensouxAlexis, would it be an option to retrieve this coefficient from the coordinate transformation metadata?
Adding the metadata would work for VisiumHD, but the approach above (or something adapted from it) would work for any tech and any image.
Please let me know what you think.
ConstensouxAlexis commentedon Mar 11, 2025
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 !
LucaMarconato commentedon Mar 11, 2025
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
"micron"coordinate system). Then instead ofget_transformation()one would call get_transformation_between_coordinate_systems(), between the image and the"micron"coordinate system.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
get_transformation()orget_transformation_between_coordinate_systems(), or manually adding the additional metadata.ConstensouxAlexis commentedon Mar 12, 2025
Ok, thank you very much for explanations !
quentinblampey commentedon Aug 29, 2025
Hi @ConstensouxAlexis,
I was also interested in accessing the
microns_to_pixelvalue, but, since there is no microns coordinate system when reading the Visium HD data, it's not possible to simply use the information from the transformations.I found a way to access it via the bins surfaces: