Scripts and Workflow, Label positioning

Hello everyone,
I have a few questions to improve my workflow.
Is it possible to align the name of an annotation in any way (e.g. top left instead of center)?

Is there any way to expose script variables in a GUI? Also is there a way to quickly execute scripts without having to open the script window (maybe in the workflow column)?

Also why is there a lock of not being able to move the viewer panel when a script is running? Also is there any possibility of showing output messages in the GUI window?

Also is it possible to change the opacity of the filled annotations?

Thanks a lot,
QuPath is a very impressive tool!

Not currently – you can only turn the names on or off (press n to toggle them).

Probably no, but I don’t know exactly what you mean.

Yes and no (mostly no). You currently need to open the script editor to run a script.

However, you can also:

  1. write a script that installs a new menu item, and run this first. There’s no built-in way to do this beyond ‘normal’ JavaFX/Groovy, but in the end I can’t see why it wouldn’t work.
  2. write an extension, in the form of a .jar file, which you can drag onto QuPath to install. If you don’t have one already, QuPath will prompt you to define a user directory and add the extension there. The extension can add menu commands… which conceivably might run a script. But it’s considerably more effort.
  3. write a script called startup.groovy and add it to the QuPath extensions directory (this is basically a compromise between method #1 and method #2); you’ll need to activate the Run startup script (if available) option for it to be run on startup.

You can zoom out & in, using the cursor location to move… but otherwise the viewer is locked because it is too easy to mess things up by interacting with objects at the same time as they are being manipulated by the script.

Do you mean something other than View → Show log?

No, but there is the opacity slider at the top that can change the opacity of everything on the image. You can use Ctrl/Cmd + the scroll wheel to adjust this as well.

3 Likes

Thanks a lot for the detailed answer!
For extending the GUI, I think I’ll decide on method #3 you proposed, having a script, which creates the custom GUI on startup.
Is there an easier way, I could start groovy scripts from within my code, or do I have to follow the method calls in 'DefaultScriptEditor.java’s ‘executeScript()’ ?

Would having alternating setName positions be a feature, I could have a go at? Is it correct, that this label drawing happens in ‘HierarchyOverlay.java’ @ line 329 - 336?

I’d assume there are other ways to call Groovy scripts from Groovy, but it really depends what you need. executeScript does more work in setting the ‘current’ image/project, default imports etc.

I don’t understand well enough how precisely the feature is defined, and what is the case for including it. Everything that is added is also a bit more complexity (another user preference, another thing that needs to be maintained & possibly updated across versions, another reason why one person’s screenshots don’t look like someone else’s…). With thousands of users who all want something different, I’m apprehensive about making core changes quickly without a clear idea of the wider benefits.

In this case, I don’t know what ‘top left’ would mean exactly. It would be easy to use the bounding box, but then is it the inner or outer part (or both)?

I can also imagine shapes (e.g. a reflected L shape) where the bounding box corner is very far from the actual shape being named… and, indeed, having a different shape position can make things extremely confusing whenever objects are nearby since the label may be much closer to/within another object.

The ability to display names on the viewer at all was only added very recently. I thought about different positionings at the time, and decided the centroid was the least confusing. What is the problem that adding an option to change the position would solve? There might be another way to get the desired outcome.

2 Likes

Hello Pete,
sorry for the late answer.
For my analysis, I have a bounding box, where inside I predict two different parts of the tissue. As one of the parts to be detected is contained in the other, the centroids of both annotations are practically at the same position. This makes the labels being placed practically on top of each other.

I understand your points about additional complexity, I for sure can live without the placement.

1 Like

Coming back to this, one way around the described problem would be to un-name any given annotation and place a new, tiny annotation in the top left or other position of the annotation that used to have a given name. Shifting the name to the “dummy” annotation should let you reposition the name.

I would recommend classifying these as something specific so that you can easily get rid of them, as having additional annotations lying around could be problematic if you did any downstream processing or Measurement Exports.