Exporting Annotations and Transferring to Another Project

1,358 views
Skip to first unread message

Flora Vyas

unread,
Jul 20, 2018, 12:33:38 PM7/20/18
to QuPath users
Hello!

I'm in the processing of preparing to analyze multiple different stains and one of the ways we are planning on doing so is by using the experimental cytokeratin annotation feature. 

I've looked at this post before and the script works perfectly for the images present in one project, which is great! But, I need to impose them on a different project entirely. Is it possible? 

Thank you!

Pete

unread,
Jul 20, 2018, 12:38:29 PM7/20/18
to QuPath users
Hi,

Is it possible to put the images into the same project?  That would probably be easiest.

Otherwise it is possible - the only really project-specific thing I recall from the script is the path in which the objects are (temporarily) saved.  If you save the objects to some other file on your computer, and then access that file from your other project, that should be ok too.

So instead of
def path = buildFilePath(PROJECT_BASE_DIR, 'annotations')

you'd have something like
def path = 'C:/path/to/some/file'

Pete

micros...@gmail.com

unread,
Jul 20, 2018, 1:37:26 PM7/20/18
to QuPath users
If you need to transfer the entire annotation set between projects, and the images are roughly the same set for each project, you might rename the .qpdata files.   Or, make a folder full of "base annotation" qpdata files, then copy those files into any new project (data directory) you start that uses the same set of images.  The only requirement to have your annotations from one image in a second image is that the name of the .qpdata file match up with the name of the image.  

So if, in Project 1, I had an image called Image1.ndpi, I could take Image1.qpdata from the "data" folder with all of the cytokeratin annotations, and copy that into Project2's "data" folder.  If Project2 has an Image1Stain2.ndpi, I could rename Image1.qpdata to Image1Stain2.qpdata, and all of the annotations and detections that were created for Image1 would now be in Image1Stain2 in Project 2.

Flora Vyas

unread,
Jul 23, 2018, 9:49:58 AM7/23/18
to QuPath users
I tried doing that, but it saves the image as well so that when I open the base annotations qpdata file, then it replaces the image currently open within the project. (I saved the objects through save as, not sure if that was right). I also copied it into the other project folder and renamed it to match the image.

Pete

unread,
Jul 23, 2018, 9:55:20 AM7/23/18
to QuPath users
When working with projects, it's best to leave the naming up to QuPath and avoid Save As - at least for the first time.  If you try open another image within the project, it will ask if you want to save changes.  If you agree, it will use the default name.

Afterwards you can use File -> Save (Ctrl + S) to save the image - this won't change the name, and it should continue to work properly within your project.

It's true that the file path is stored within the .qpdata file, but if you open the image through the project then the paths in the project will the precedence.  If you open by double-clicking on the .qpdata file, then at that moment QuPath isn't aware of the connection to the project - and just uses the path within the .qpdata file.

Flora Vyas

unread,
Jul 23, 2018, 10:52:26 AM7/23/18
to QuPath users
Okay! Thank you! I opened the file through the project, but the image still gets replaced. (I used open through the file tab which might not actually be the way to open it, in which case, I apologize.) Dragging and dropping the file has the same image replacement occurring. 

When I double-click on the .qpdata file through finder, it doesn't open in qupath. It doesn't actually do anything; no response whatsoever.

Pete

unread,
Jul 23, 2018, 10:58:09 AM7/23/18
to QuPath users
Ah yes, it opens on Windows but handling that is a lot more awkward on a Mac.  This might help... but I no longer use it myself on my Mac.

Within a project, the image should be opened by double-clicking the entry in the list under the 'Project' tab: https://github.com/qupath/qupath/wiki/Projects

One main purpose of projects is to organise the files and make it unnecessary to use File -> Open or File -> Save As directly.

micros...@gmail.com

unread,
Jul 23, 2018, 11:07:02 AM7/23/18
to QuPath users
You mentioned opening "the file." Do you mean the .qpdata file or the new image?  You should be opening the new image.  The data file should only be handled when copying it into the "data" folder in the new project and renaming it to the new image.  The data file is not opened directly.  So you create the new project, import or open the images, then close the project.  Copy the .qpdata file into the data folder of the new project, rename the .qpdata file with the new image name, then re-open the project and double click the image in the side bar to bring both it (and it's newly associated data) up in the viewer.
Message has been deleted

Flora Vyas

unread,
Jul 23, 2018, 1:45:24 PM7/23/18
to QuPath users
Thank you! It worked! 

The only thing is that the annotations are small and are on one corner of the image instead of over the image. I have attached a picture to demonstrate what I mean. I'm not sure of how to expand it to a larger size to fit over the entire image.
Screen Shot 2018-07-23 at 1.44.12 PM.png

Pete

unread,
Jul 23, 2018, 1:48:23 PM7/23/18
to QuPath users
I would guess that the images have been scanned at very different resolutions.

Assuming it is not the same slide restained & rescanned, it will be difficult to match regions across both images (and even if the same tissue it is not entirely straightforward).

Flora Vyas

unread,
Jul 23, 2018, 2:39:06 PM7/23/18
to QuPath users
Ah, okay! Thank you!

micros...@gmail.com

unread,
Jul 23, 2018, 3:41:21 PM7/23/18
to QuPath users
Yep, that looks like it is size, translationally and rotationally transformed.  

These might be worth looking over along with the associated links within:

Reply all
Reply to author
Forward
0 new messages