Positive cell detection wrong

693 views
Skip to first unread message

Phil

unread,
Jul 14, 2018, 5:49:58 AM7/14/18
to QuPath users

Hello  ,

I'm a new QuPath user and I have a problem with positive cell detection. In particular when i detect the positive cells, I perform the following steps:

1) drawing an area of ​​interest;

2) Estimate stain vectors;

3) Positive cell detection.

at the end of the activities I have the result of the attached image in which only Qupath detect all values with unique color and not it make the difference between cell positive and negative.Can someone give me some indication? 

Best regards

detection sith optical density sum.jpg
parameters of cell detection for optical density sum.jpg
parameters of detection.jpg
rilevate_1.jpg

Caleb Grenko

unread,
Jul 14, 2018, 8:11:35 AM7/14/18
to QuPath users
Hi Phil,

It looks like the issue is arising from your stain vectors. Instead of having your stains labeled 'Positive, Negative, Residual', try having them named 'DAB, Hematoxylin, Residual' in their respective channels. This should allow QuPath to pick up on the appropriate color channels.

To change them, look under the image tab on the left, and double click the word 'positive' in the same row it says 'stain 1'. This will let you manually change the names of the stains.

Let me know if that helps!

Phil

unread,
Jul 15, 2018, 3:32:55 AM7/15/18
to QuPath users
Hi Caleb,
thank you for the immediate answer. In the previous case, changing the values ​​of the stain vectors the detection was accurate. Unfortunately, now I remake a new survey with a another photo and I have the same  problem despite having the correct stain vectors. 
Thanks for your time
parameters not detected values_2.png
results not detected values_2.png

Caleb Grenko

unread,
Jul 15, 2018, 8:46:09 AM7/15/18
to QuPath users
Glad to hear it helped!

It looks like your image type is off in this set of pictures. In the same way you set the names of the stains, double click 'Brightfield H&E' next to where it says 'Image type' under the Image tab. Set it to H-DAB, then make sure your stains have the appropriate labels (blue = Hematoxylin, etc.) Let me know if that works!

Pete

unread,
Jul 16, 2018, 4:24:11 AM7/16/18
to QuPath users
I can confirm that it should be the 'Image type' issue... QuPath makes its best guess of the image type when you open the image (albeit with a fairly unsophisticated calculation based on an average color), and unfortunately in your case it seems to be guessing H&E rather than H-DAB.  In the future, I'd like QuPath to be a bit more explicit that it is making this calculation (and ideally make the calculation more accurate too...).

Anyhow, you can change the image type as Caleb describes.  H-DAB is necessary for the positive cell detection to actually find any positive cells.  It's also necessary to make DAB measurements, so it's best to check/set the image type as the first thing you do on opening an image.

Once you've detected cells, you can also assign them as positive or negative later through a simple script - which can also be a fast way to experiment with different 'positivity' cutoff thresholds.  There is more information at https://petebankhead.github.io/qupath/tips/2018/03/22/setting-positive.html

Abhishek Rawat

unread,
Jul 16, 2018, 11:24:30 AM7/16/18
to QuPath users
Hi Pete,
On the related note of using the one line script.

setCellIntensityClassifications('Nucleus: DAB OD mean', 0.4)

When I execute the same, the positive cells do NOT light up in brown color as they do when I use the GUI.
The script works otherwise as it generates the correct number statistics etc in the bottom left table, just that the cells do not get highlighted.
Is this normal?
Thanks,
abhi.

Caleb Grenko

unread,
Jul 16, 2018, 11:33:54 AM7/16/18
to QuPath users
Hi Abhishek,

Using setCellIntensityClassifications takes cell objects and classifies them by the threshold at the end of the parameters. In this case, it is a single threshold, so it is a binary output. With both the GUI and the script, it makes negative tumor cells blue and positive tumor cells red. The only time they will be brown is when they get categorized as 2+ when using multiple thresholds. To do that with the script, just add more decimal parameters, like so:
setCellIntensityClassifications('Nucleus: DAB OD mean', 0.2, 0.4, 0.6)

The ones with a DAB OD mean between 0.4 - 0.6 will show up brown. Hope that helps, if not, would you mind uploading a screenshot of what each method looks like for you?

Thanks!
Caleb

Pete

unread,
Jul 16, 2018, 11:46:23 AM7/16/18
to QuPath users
Hi Abhi and Caleb,

There is one other distinction: the 'Positive cell detection' command assigns the classifications 'Positive' and 'Negative' only (which by default are red and blue - but you can override these colors if you add 'Positive' and 'Negative' as possible classifications under the 'Annotations' tab and customize them to have a different color).

However, the setCellIntensityClassifications scripting command only assigns classifications 'Positive' and 'Negative' if the objects don't have a classification already (other than Positive/Negative).

If the objects do already have any non-intensity-based classification (e.g. 'Tumor' and 'Stroma'), then the script will actually set the sub-classification.  Therefore you would end up with 'Tumor: Positive', 'Tumor: Negative', 'Stroma: Positive' and 'Stroma: Negative'.

The same colors red and blue are applied 'Tumor' sub-classifications only.  For others, lighter or darker shades of the original classification color is used instead (e.g. by default green for 'Stroma', purple for 'Immune cells') to avoid confusion - although the distinction can be fairly subtle.

The above assumes one threshold, but the same idea applies if you have up to 3 thresholds, but rather than 'Positive'/'Negative' it would be '3+', '2+', '1+' and 'Negative'.

The overcomes the limitation that when you're training a detection classifier and set intensity classifications, these are applied only to the 'Tumor' class... but maybe it's necessary to sub-classify other cells according to intensity as well.

I hope that makes some sense...

Pete

micros...@gmail.com

unread,
Jul 16, 2018, 11:48:28 AM7/16/18
to QuPath users
One side note to that.. if you have created a class called Positive and changed the color of that class, you will no longer get the blue/red colors that are the default.  I have tripped myself up a couple of times when using large numbers of classes where I was already using a red and a blue, but forgotten that I altered positive/negative colors for testing purposes.

micros...@gmail.com

unread,
Jul 16, 2018, 11:48:58 AM7/16/18
to QuPath users
Whoops, beat me to it :)

micros...@gmail.com

unread,
Jul 16, 2018, 11:51:01 AM7/16/18
to QuPath users
If needed, you can add: resetDetectionClassifications() to your script before any classifying.

Abhishek Rawat

unread,
Jul 16, 2018, 1:20:56 PM7/16/18
to QuPath users
Thanks for the clarification Pete. It clears things up.
Upon closer inspection I find that the :Positive sub-classification of the Base Class is indeed painted a brighter shade of the original color. However, this is so subtle so as to be missed.
This is also kind of a bummer for my work as I am looking for DAB uptake (immune cells) in both Tumor as well as Stroma separately and I need them to show up as conspicuous brown/red color so I can run a visual check to the correctness of the threshold. 
I guess I will go back to setting a threshold manually.
cheers!
abhi.

Pete

unread,
Jul 16, 2018, 1:29:25 PM7/16/18
to QuPath users
I don't find it too subtle if I press f to fill in the cells... and there are enough positive and negative examples actually there to let me calibrate my eye.  It may depend a bit on the 'darkness' of the original classification though.

It's hard to find enough colors to deal with potentially any number of classifications being subclassified by intensity, and I can't think of a better general way to do it than by adjusting the brightness.

But if you want a visual check, you can still do this to turn 'Stroma: Positive' red:

// Access the 'Stroma: Positive' sub-classification
stroma
= getPathClass('Stroma')
stromaPositive
= getDerivedPathClass(stroma, 'Positive')

// Set the color, using a packed RGB value
color
= getColorRGB(200, 0, 0)
stromaPositive
.setColor(color)

// Update the GUI
fireHierarchyUpdate
()

I haven't checked if the colors survive reopening the image/restarting QuPath.

Abhishek Rawat

unread,
Jul 16, 2018, 1:49:03 PM7/16/18
to QuPath users
Thanks Pete for the script for updating the colors.
It really helps me while running a quick manual QC when deciding on a threshold.
cheers!
abhi.



Phil

unread,
Jul 18, 2018, 4:22:09 AM7/18/18
to QuPath users
Thank you for your continued support.
Reply all
Reply to author
Forward
0 new messages