Transferring annotations using image overlay alignment

Hey QuPath Community,

I have two images that are almost identical but differ in some artifacts and stain. On one image it is easier to see my region of interest and mark it with an annotation then it is with the other. I am wondering if it is possible to:

Align the images using the image overlay alignment tool
Copy and transfer the annotation to the other image so they have the same exact ROI

I have read a few topics like this on the forum but when I apply them they haven’t seemed to do exactly what I need them to. I have little coding experience (maybe I should get some) so the whole scripting part of this is a bit out of my league at the moment.

Here is what I am talking about:

This is a snip of the original images overlaid.

Here is them overlaid (manually done)

So I would like the annotation to be on the H&E image in the project as well. Is this possible? I dont want this run for a whole project, just two images as I have duplicates (and soon 3 different stained images) that I would like to apply this too.

As always, any and all help is welcome and appreciated!
Thanks!

That sounds like the original script from Pete that transfers objects between images, without any of the more complex project related stuff we added in. You will need to manually add the names of the images and the affine matrix, though.

The original posts were linked to within the scripts themselves:

Script base on: https://forum.image.sc/t/interactive-image-alignment/23745/9
and adjusted thanks to Pete's script: https://forum.image.sc/t/writing-objects-to-another-qpdata-file-in-the-project/35495/2

Direct link to Pete’s code: Script to transfer QuPath objects from one image to another, applying an AffineTransform to any ROIs · GitHub

1 Like

Hey @Mike_Nelson thanks! It works but since my images aren’t the same size/dimensions, it places the annotation where the red ellipse is but the goal is to directly plant it where the yellow ellipse is:

thus why I was wondering about he overlay application to it… is there a way to combine the two?

The size and dimensions should not really make a difference - objects can be transferred to small JPEG pictures or between images with wildly different image sizes. If you have already tried the createInverse boolean, I can’t be sure what is going on, but I do not think it is a limitation of what the script will work on.

And just to make sure, the script should be using the transform matrix from the interactive overlay. If you are not, nothing is going to work correctly! :slight_smile: