Can't use SubcellularDetection.ImageWrapper

Hi everyone,

I have a practical problem with QuPath 0.2 script as described below

  • I want to automate the cell detection on Fluorescence image (multiple channel)
    First I found this script to create a channelMap
def server = QPEx.getCurrentImageData().getServer()
def cells = QPEx.getCellObjects()

// If true, just take the channel name before the first space
boolean splitAtSpace = true

// Get a map of channel names
// Here we take the channel name before the first space
def channelMap = [:]
for (int c = 0; c < server.nChannels(); c++) {
    def channelName = server.getChannelName(c)
    if (splitAtSpace)
        channelName = channelName.split(' ')[0]
    channelMap['Channel ' + (c+1)] = channelName

It turned out that version 0.2 is no longer support this def server = QPEx.getCurrentImageData().getServer() function

Then I found a way around is to create a new ImageWrapper as below:

import qupath.imagej.detect.cells.SubcellularDetection

def image_data = QPEx.getCurrentImageData()
def server = SubcellularDetection.ImageWrapper(image_data).getServer()

The problem is ImageWrapper takes the ImageData object as input, I input an ImageData object, but it still doesn’t work, the error is No signature of method: static qupath.imagej.detect.cells.SubcellularDetection.ImageWrapper() is applicable for argument types: (qupath.lib.images.ImageData) values: [ImageData: Fluorescence, BCC_no2_4.czi] .
The links for reference is below:

Not really able to help much with the ImageWrapper stuff, but QPEx isn’t really used anymore, which could make things more difficult in your script. For example,

server = getCurrentImageData().getServer()

should work just fine. You may want to check out:

If you are just automating cell detection, why not use the cell detection command? Or are you trying to shape the cytoplasms using subcellular detection? By default, cell detection runs just fine on images with many channels:

It is still used! But I do prefer to use the static import statement

import static qupath.lib.gui.scripting.QPEx.*

so that it doesn’t need to be mentioned explicitly every time. And this is included by default, so generally you don’t need to type it yourself.

It does still support this. You might just need to change the import statement to

import static qupath.lib.gui.scripting.QPEx

Otherwise, if you have problems please include the specific error message you see - and also specify which specific milestone version you’re using.

1 Like

Thank you for your comment. I can get it work for now. the problem is

for (int c = 0; c < server.nChannels(); c++) {
    def channelName = server.getChannelName(c)

For Groovy, it recognizes c as Integer object, while the function only accepts primitive int type. So I was thinking that was the problem with a version incompatible since I could import the package

Groovy should handle that fine, although subtle difference between how Groovy and Java handle numbers can cause a little bit of trouble sometimes:

The biggest problem I’ve had was not specifying the type of the number in Groovy within a loop, so it was a BigDecimal. While accurate for calculations, performance was pretty terrible…