How do I rotate the TMA image 180 degrees?

425 views
Skip to first unread message

Roy Granit

unread,
Nov 20, 2017, 11:32:54 AM11/20/17
to QuPath users
Hello,

Some of my TMA samples have been scanned in such a manner that I need to rotate them 180 degrees to match the map, I noticed that the rotation option does not support this rotation/inverse..

Any suggestions?

Thanks,
Roy

Pete

unread,
Nov 20, 2017, 12:44:12 PM11/20/17
to QuPath users
I’d like to suggest rotating the map.  That sounds safest.

Although I will admit to an undocumented hack that may be helpful… although I’m not sure if it will survive in future QuPath updates.

Anyhow, if you put your images in a project then you can open the project.qpproj file in a text editor and add a secret metadata value “rotate180”.  The result should look something like this:

{
    "createTimestamp”:12345678910,
    "modifyTimestamp":12345678910,
    "images":[
{
            "path”:”/path/to/image",
            "name”:”name.ext",
            "metadata":{
                "rotate180":"true",
            }
}
]
}

Now if you reopen the project, images with this metadata value set should be opened in a rotated way.  Note that it only works for 180 degrees... no other rotations are supported.  Also, if you have opened the image previously then you would need to restart QuPath to ensure that the rotation is applied - since otherwise unrotated tiles may be cached and displayed.

Because the value is only stored in the project file (not the data file), it is necessary to open the image via the project every time for the rotation to happen.

I’m not sure how common this issue is, but if it turns out to occur often then I guess a more elegant solution may be needed one day...

Finn

unread,
Nov 21, 2017, 12:34:33 PM11/21/17
to QuPath users
I'd just like to second that this would be a really useful feature! It has been a real headache working across TMAs for different marker panels that have been randomly inverted in processing...

Pete

unread,
Nov 21, 2017, 5:08:11 PM11/21/17
to QuPath users
Ah ok, that's good to know.  I guess this should be stored in the .qpdata file and made 'permanent' then.  And ideally have a user interface option that doesn't require text editing...

Would it be safe to assume that only 180 rotations really need support?  Or has the lack of support for any other transform / rotation / flipping ever been troublesome in practice?

Finn

unread,
Nov 21, 2017, 6:16:03 PM11/21/17
to QuPath users
Well -- I've only seen the 180 rotations, so I think that would be most important. And I'm not sure how common this is for other people, but seems to arise quite a bit by the time I see a TMA in our group...

And thanks again for being so responsive on this!

Roy Granit

unread,
Dec 3, 2017, 3:18:45 PM12/3/17
to QuPath users
I only now got to implementing this suggestion, and added the rotaion bit to the project file, yet now QuPath won't open the project (no error or any thing, just nothing happening..)

Any suggestions?


Pete

unread,
Dec 3, 2017, 3:54:03 PM12/3/17
to QuPath users
Ah, I experienced this too for the first time recently... I used TextEdit on a Mac and thereafter my project wouldn't open.  Previously I'd be using TextWranger and all was fine.  I've also used Notepad++ on Windows without problems.

So it does depend on the editor (and whatever encoding it uses).

Roy Granit

unread,
Dec 3, 2017, 4:20:24 PM12/3/17
to QuPath users
Thanks Pete - I have tried to edit the file even via the Mac terminal and did not succeed.. 

Pete

unread,
Dec 3, 2017, 4:44:18 PM12/3/17
to QuPath users
I've just tried the TextEdit thing again, and it breaks my project.qpproj file as before.  However, I can open the same file inside QuPath's 'Script editor' and change it again, saving the result, and then that can be opened once more in QuPath as a proper project.

In this case, the problem I suffered appears to have been that TextEdit was using smart quotes that QuPath didn't like.  Replacing them with straight quotes was the solution.

In the end, the project file should contain valid JSON.  If it still won't open in QuPath, you could also try parsing the contents of the project file elsewhere (e.g. using Python), and perhaps get a more informative error message that way.

Roy Granit

unread,
Dec 4, 2017, 5:09:15 AM12/4/17
to QuPath users
Thanks, I ran this on a Json editor and found the issue.. There was an extra comma after "rotate180":"true"

Should be like this:


            }
 }
 ]
}

maged darwish

unread,
Feb 15, 2019, 5:55:43 AM2/15/19
to QuPath users
Hello,
I tried rotating 180 and it broke the whole project, should i download python or what ?

Roy Granit

unread,
Feb 15, 2019, 7:03:50 AM2/15/19
to QuPath users
Can you pls provide more details? no python is needed, just to edit the json file  project.qpproj  with josn simple text editor to include

 "metadata":{
                "rotate180":"true"

            }
 
Reply all
Reply to author
Forward
0 new messages