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

Visium HD fix bug projective transformation (CytAssist image) #247

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

LucaMarconato
Copy link
Member

@LucaMarconato LucaMarconato commented Dec 7, 2024

Closes #242

@LucaMarconato LucaMarconato marked this pull request as ready for review December 8, 2024 16:06
@LucaMarconato
Copy link
Member Author

LucaMarconato commented Dec 8, 2024

The transformation needed to align the CytAssist matrix is a projective transformation that is not an affine transformation. To take into account for this, since NGFF doesn't currently support projective transformations, I decompose the projective transformation into an affine part and a "purely projective" residual part (projective shift). I then warp the CytAssist image using the projective shift, with the effect that using the affine transformation will then be equivalent to the original projective transformation. Luckily the CytAssist image is small, so we can load it in memory and warp with no slowdowns.

I used this dataset (Human Lung Cancer Visium HD 3.1.1) to develop the PR. The discrepancy that I observed between the old and the new approach was small (see figures): the biggest shift is of approximately 5 pixels, but since it affects only one of the 4 corners and since the CytAssist image has a large padding, the actual shift in the sample is barely noticeable. Anyway, in other datasets the shift may be large, so it's good to have this addressed by this PR.

Finally, the microscopy image was already using an affine transformation, so no adjustments was needed. I double checked this by comparing the output from LoupeBrowser with the one from napari-spatialdata (see image below).

(edit: in the figure I am showing the 8µm bins, not the 2µm bins).
Artboard 1@4x-100
Artboard 3@4x-100

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

Successfully merging this pull request may close these issues.

Visium HD alignment sometimes require a projective transformation, affine not enough
1 participant