Scripting RGB settings on QuPath projects

Hi all, I have QuPath 0.2.0-m9. I have run the code below to change RGB values for my Project (10 .ndpis images). Then I go to File-> Reload data and it seems to work. When I start checking the images one by one for some reason the program freezes and it goes back to the original RGB settings. Any thoughts?

Thanks,
Pasquale

// Get access to the display info for each channel
//This function changed between 0.1.2 and 0.2.0, in 0.2.0 use viewer.getImageDisplay().availableChannels()
def viewer = getCurrentViewer()
def channels = viewer.getImageDisplay().availableChannels()

// Set the LUT color for the first channel & repaint
channels[0].setLUTColor(0, 0, 255)
channels[1].setLUTColor(0, 255, 0)
channels[2].setLUTColor(255, 0, 255)
channels[3].setLUTColor(255, 0, 0)

// Ensure the updates are visible
viewer.repaintEntireImage()

// Usually a good idea to print something, so we know it finished
print 'Done!'

I don’t know the original source of the script (very possibly me, a long time ago) but it uses a bit of a hack to set the colors. There is a better/simpler way to do it now, e.g. something like this

setChannelColors(
    getColorRGB(0, 0, 255),
    getColorRGB(0, 255, 0),
    getColorRGB(255, 0, 255),
    getColorRGB(255, 0, 0)
)

I don’t recall if the required scripting method already existed in v0.2.0-m9, but the latest version is v0.2.2 – I’d recommend updating whenever you can, since many bugs have already been fixed.

Thanks a lot Pete! :blush:

1 Like