QuPath Script: UI for class visibility selection

One more script for today, this one gives the user a GUI where all classes can be turned off or on individually, or en mass, even if they are not listed on the Annotation tab.
When run, it defaults to turning off all classes, so that single classes can be selected in turn.


Clicking All will turn them all back on, if only certain classes need to be made invisible.

Here, I can quickly turn off the Negative and CK positive cells to get a better look at my more interesting cells.

With over 20 classes, this has been much easier to handle the output of the multiplex classifier. It also pairs up with with some of the other cluster analysis scripts I have been working on, as I can now look at heatmaps of distance to CK positive cells… without all of the annoying CK cells getting in the way.

Or I can quickly turn on only the CK positive cells, and look at the distance to the nearest CD8 positive cells with the channels turned back on.

Though I’ll need to invert a colormap for some of this nearest neighbor stuff (this one changes to pink when below the low threshold)!

Script is here.
I recommend copying via the Raw button on the right!

1 Like

Quick update with V2. Support for groups of classes added, as defined by substrings with the same characters.
This version of the script does have a few unexpected results due to my inability to code in JavaFX, so if anyone better at JavaFX wants to take a swing at fixing it, let me know if you have any questions or need any clarification!

Using the same example from above…


I can now visualize all CD8 positive cells by clicking a single button.

or all PD1 or CD8 positive.

Note that because almost all of my class names have “positive” in them, there is one super class named “positive” which has almost no real meaning, but will override almost all classes if checked!
If I wanted to turn off several of the classes after selecting PD1 and CD8, I can do that (note the top 3 individual classes that had been checked)…

However, any time I make a change to the “groups of classes” side, it will overwrite any individual class changes that were made. I also don’t have a way to ask something like “All CD8 positive classes, but no PDL1 classes.” This dialog is currently only for selecting groups. If there is enough interest or utility, I might expand another column for “Nots.”

Other notes:
At the top of the script there is a section where you can add other “splitters” in case your particular classes are separated by a character not currently listed:
separatorsForBaseClass = "[.-_,]+" //add an extra symbol between the brackets if you need to split on a different character
Also, the script is currently written to work for all detections, making it work for things like SLICs or other tile objects, which means that by default it would include classes for all subcellular detections as well. If that is not desired, you can change the def classifications line from getDetectionObjects() to getCellObjects() around line 30.

Script version 2.