Rotating view in QuPath

This is perhaps a naive question, but is there a reason why rotation of the view in QuPath is limited to +/- 90 degrees? Is there a way to rotate a view, say, 180 degrees, without exporting a view to ImageJ and performing the rotation there?

I came across a hack some time ago that involved manually editing the project file to achieve this, but I’m wondering if there is a way to perform this rotation via the interface and, if not, are there any plans to incorporate such functionality?

The reason for the limited rotation is that it is really only a visualization trick - the coordinate system used by QuPath remains the same, with (0,0) in the top left corner of the unrotated image.

A common reason to want to rotate the image 180 degrees is to ‘correct’ an image (e.g. a tissue microarray) that is ‘upside down’.

If this is attempted just with the rotation slider the results and behavior could be surprising because internally all of the analysis and annotation code doesn’t know (or care) anything about what rotation was applied for visualization. QuPath would treat the bottom right of the image as (0,0) and all numbering would likely be the opposite of what is expected.

The purpose of the hack was to effectively rotate the image fully, so that the image behaved completely as if it had been scanned the other way around.

I’ve written the code to implement the hack more cleanly and offer 90, 180 and 270 degree rotations. I plan to incorporate it into the interface but haven’t got around to it yet.

Are you asking because of a rotated tissue microarray, or is there another reason why this would be important?

2 Likes

Thanks for the reply @petebankhead, that makes sense.

Honestly, it was more of a curiosity as I’ve had a few users ask about rotating tissue sections for ease of viewing and interpretation if they happened to have been imaged the “wrong way 'round”. However, yes, it’s quite likely that we’ll be dealing with microarrays at some point so it would be useful to have this functionality.

Hi @petebankhead, did you end up writing a code to rotate a image 180 degrees?

Yes, it should be working in v0.2.0-m4 (requires you to use a project): https://petebankhead.github.io/qupath/2019/08/20/fourth-milestone.html#more-options-when-importing-images-to-projects

180 degrees works for me, but not 270, for some reason.

Did you get a specific error message, either popping up or under View → Show log? I happen to be working with an image using Rotate 270 right now and it seems ok for me.