Cell detection not working prob because

Hi everybody,

I have IHC images (Ki-67 staining) to analyze, and I have hard time counting cells on it.

Probably because of the DAB background staining, ‘Cell detection’ function does not work at all to detect any cells in the image even after changing the parameters.

Could anybody help on how to train Qupath to detect cells in these samples?

I attach my script below and an original image as well. Thanks!

setColorDeconvolutionStains('{"Name" : "H-DAB modified", "Stain 1" : "Hematoxylin", "Values 1" : "0.71124 0.61052 0.34843 ", "Stain 2" : "DAB", "Values 2" : "0.10193 0.39945 0.91107 ", "Background" : " 225 175 148 "}');
runPlugin('qupath.imagej.detect.cells.WatershedCellDetection', '{
    "detectionImageBrightfield": "Hematoxylin OD",
    "requestedPixelSizeMicrons": 0.5,
    "backgroundRadiusMicrons": 8.0,
    "medianRadiusMicrons": 0.0,
    "sigmaMicrons": 1.5,
    "minAreaMicrons": 10.0,
    "maxAreaMicrons": 400.0,
    "threshold": 0.1,
    "maxBackground": 2.0,
    "watershedPostProcess": true,
    "excludeDAB": false,
    "cellExpansionMicrons": 5.0,
    "includeNuclei": true,
    "smoothBoundaries": true,
    "makeMeasurements": true

I see the question was also posted here (please don’t do this!) so I’m reposting my answer below:

I looked at the image and there are two main problems:

  • The pixel size is completely off (169.3 μm). It looks like it was converted from a ‘dots per inch’ value used for printing resolution, but doesn’t relate to the actual size of anything in the image.
  • The background is values in your script are much too low. Draw a rectangle in one of the small ‘white’ areas and double-click on the ‘Background’ values under the ‘Image’ tab to set them.

The first of these is the bigger problem. I don’t know the source of your image, but ideally you’d be able to go back to it and save the file in a format that preserves the pixel size information properly.

1 Like

Thanks for responding. The image was taken at 16 bit BF and saved as .zvi file.

Then I converted it to 8bit .TIF to be able to use it in QuPath.

Do you have any suggestion that I could convert 16bit .zvi files to 8 bit image that does not distort pixel sizes?

TIFF doesn’t necessarily change the pixel sizes - it will depend on which software wrote the TIFF (and possibly which options were set).

If you open the .zvi in Fiji, convert to RGB and save as .tif ‘the normal way’ there it should be ok… although any bit-depth conversion is likely to result in pixel values changing.

I’m not sure how common it is to have non-8-bit, brightfield RGB images. I’d generally say a higher bit-depth is better for fluorescence, but not really for brightfield.

Thanks for valuable advice. I did not know that higher-bit depth does not improve BF image that much.

I will convert my image as you advised.

Have a wonderful day,



1 Like

The next milestone release should allow you to set the pixel sizes from within QuPath manually if they are wrong (changes here) but for now they need to be stored correctly within the image file, before reading it in QuPath.

Throwing in a copy of the response from the linked issue here in case someone is looking for value ranges that might work for something like this:
I think the main problem is that your TIFF file was saved with incorrect pixel size information. Without that information it is very difficult to find settings that will work, though it is possible. Note that each one of your pixels is expected to be 163 um in size. Your entire image is about 0.2 meters in size.

If you are using the ImageJ server, everything needs to be in pixels instead, though since you have a requestedPixelSize entry, I am guessing that is not the case here.

If you are using a BioFormats server (see Image tab), you can get started with these settings, though I have not optimized them at all.

setColorDeconvolutionStains('{"Name" : "H-DAB", "Stain 1" : "Hematoxylin", "Values 1" : "0.81041 0.56974 0.13652 ", "Stain 2" : "DAB", "Values 2" : "0.26524 0.50132 0.8236 ", "Background" : " 254 190 154 "}');
runPlugin('qupath.imagej.detect.cells.WatershedCellDetection', '{"detectionImageBrightfield": "Optical density sum",  "requestedPixelSizeMicrons": 300.0,  "backgroundRadiusMicrons": 0.0,  "medianRadiusMicrons": 0.0,  "sigmaMicrons": 600.0,  "minAreaMicrons": 10000.0,  "maxAreaMicrons": 8.0E7,  "threshold": 0.1,  "maxBackground": 2.0,  "watershedPostProcess": true,  "excludeDAB": false,  "cellExpansionMicrons": 1000.0,  "includeNuclei": true,  "smoothBoundaries": true,  "makeMeasurements": true}');

Note the extremely large values in most measurements. It would be better to fix the pixel sizes in ImageJ, though.