Colors - Channels
Adjusting the channel displays - mostly for fluroescence.
In addition to recoloring objects, channels and displays are also malleable by way of code.
The simplest change is to adjust the name of the channels, which can be incredibly useful in fluorescent images.
setChannelNames("PDL1", "CD8","FoxP3","CD68","PD1","CK","DAPI","AF")
Simplifying the channel names before generating cells will use the updated channel names for the cell measurements.
Some other methods of controlling channels can be found here.
Changing the first two channels of the LuCA image to white and green would look like this.
setChannelColors( getColorRGB(255, 255, 255), getColorRGB(0, 255, 0) )
.
The colors can be changed back to red and yellow by double clicking on the channel in the Brightness and Contrast menu and selecting the color you want - or you can figure out the RGB values to change the colors back by script. Alternatively, by swapping images and coming back without saving, the channels will return to normal. If you save the image with the channel colors changed, they will stay changed!
To alter the channel brightness, you can use the following, where the first value is the channel number (starting with 0 for the first channel), the second is the black limit, and the last is the max pixel intensity. All other pixel intensities will appear stretched between the last two values, although these changes will not alter your underlying data.
setChannelDisplayRange(1,0, 20)
Alternatively, the channel name can be used.
setChannelDisplayRange("CD8",0, 20)
Putting this all together, we can set channel names, change the colors of the first two (they are always in order, so if you do not want to change one, add in the current color), and then adjust the display range on the second channel.
setChannelNames("PDL1", "CD8","FoxP3","CD68","PD1","CK","DAPI","AF") setChannelColors( getColorRGB(255, 255, 255), getColorRGB(0, 255, 0) ) setChannelDisplayRange("CD8",0, 5)
For even more advanced uses of channels and manipulation of images, I recommend Peter Haub's guides on the forum:
https://forum.image.sc/t/qupath-scripting-2-using-clupath-and-ij-to-show-image-with-additional-local-threshold-channel/49962
https://forum.image.sc/t/qupath-scripting-3-apply-colorlut-or-invertedlut-to-channel/50368
https://forum.image.sc/t/qupath-scripting-6-customized-3-stain-color-deconvolution/50864
Among others, search them out!