Pulling list of channel names from qupath

Is there a way to pull a list of channel (biomarker) names from QuPath?

I’d like to make a script that is very flexible to measure mean and stdev of a whole-image annotation in all channels, and export per channel values to a .csv file.

//This script  calculates the whole image mean and stdev for 2 expected channels and writes them out to the project folder.

setImageType('FLUORESCENCE');
createSelectAllObject(true);
//Find way to get channels from image header//
runPlugin('qupath.lib.algorithms.IntensityFeaturesPlugin', '{"pixelSizeMicrons": 2.0,  "region": "ROI",  "tileSizeMicrons": 25.0,  "channel1": true,  "channel2": true,  "doMean": true,  "doStdDev": true,  "doMinMax": true,  "doHaralick": false,  "haralickMin": 0,  "haralickMax": 0,  "haralickDistance": 1,  "haralickBins": 32}');
def imagestats=getAnnotationObjects()[0]

def Channel =[]
def Mean =[]
def Stdev=[]

//Currently I have the ChannelNames hard-coded, but want to be able to get them from the file//

def imagestatsML=imagestats.getMeasurementList()
Channel << "ChannelName1"
Mean << imagestatsML.getMeasurementValue("ROI: 2.00 µm per pixel: ChannelName1: Mean")
Stdev << imagestatsML.getMeasurementValue("ROI: 2.00 µm per pixel: ChannelName1: Std.dev.")
Channel << "ChannelName2"
Mean << backgroundML.getMeasurementValue("ROI: 2.00 µm per pixel: ChannelName2: Mean")
Stdev << backgroundML.getMeasurementValue("ROI: 2.00 µm per pixel: ChannelName2: Std.dev.")


String[] imagename = getProjectEntry().getImageName().split(" .")

header = "Channel, Mean, Std.dev."

def outputpath = buildFilePath(PROJECT_BASE_DIR, getProjectEntry().getImageName()+'.imagestats.csv')

File csvFile = new File(outputpath)

csvFile.createNewFile()

new File(outputpath).withWriter { fw ->
    fw.writeLine(header)
    for (int i=0; i<Channel.size; i++) {
        String line = Channel[i]+","+Mean[i]+","+Stdev[i];
        fw.writeLine(line);
    }
}
print "whole slide measurements complete"

This should get the channel names as a list:

def channelNames = getCurrentServer().getMetadata().getChannels().collect { c -> c.name }
println channelNames
3 Likes

Great! Thanks, that works. Is there a resource where I can find class descriptions for things like getCurrentServer, etc?

1 Like

If you want a list of functions that can be used with a particular “thing” you can use a short script with describe().

Try:

server = getCurrentServer()
describe(server)