Fluorescent image: manually set class to a detected cell?

Dear members of the community,

Here are the problems I encounter:
I have fluorescent images of liver stained with immunological relevant marker CD3, IL-18Ra, and TCR.
I trained the machine to get object classifiers for the three channels. Detections of CD3+ and IL-18Ra+ cells are pretty accurate with QuPath and I played a little with the different parameters of the Positive Cell Detection so I have coherent splitting of nucleus etc.
However, concerning the TCR staining, I have autofluorescence in the same channel (part of fibrosis) inducing the software to give me false positive.

I then would like to be able to use the auto-detection of CD3 and IL-18Ra and to manually assign the TCR positive (usually, the CD3 and TCR should perfectly superposed around the membrane of the cell). I am able to assign a class to a new created object but not an a cell detected by the nucleus.

Also, bonus question, I do not find (yet?) a way to sort my results in the hierarchy so I can explore them easily or reassign them (if possible? see previous concern…) to a proper class. Is it possible to sort them?

Thanks a lot in advance for those of you able to help me.

It is a little hard to help without either an image or a version of QuPath, but guessing a bit wildly:

One option might be to place Point objects in each cell you want to make positive for TCR and then use a script to convert cell’s class. Unfortunately, I am not sure what you are using to classify your two other markers since you mentioned Positive cell detection but not your other classifier.

You could also select the cells and then click Set class in the Annotation tab.

You can sort cell detections using whatever variable you might want (including class or name) in the Show detection measurements list, grid icon next to the opacity slider. Alternatively, @smcardle wrote an amazing script to cycle through cells based on their class and mark them with annotations (for the ones you want to change), which can dramatically speed up using machine learning classifiers.

Dear @Research_Associate, thanks a lot for your input. I’ll closely have a look to your suggestions and to the script from smcardle.
In the meantime and to have a proper explanation of my problem, here is an example picture of what I have as an example:

I am using the latest version of QuPath (0.2.3).
I use the train object classifier and tried to teach the machine how to separately detect CD3+, IL-18Ra+, and TCRVa7.2+ cells on duplicated images (I followed the Multiplexed Analysis tutorial). Then, I applied the 3 different object classifiers back to my primary image.

But, as you can see on the image, if I have a little bit of fibrosis/autofluorescence for one my channel (in the image, the cell in the middle-top of my annotation, above the cursor, is supposed to be CD3+ IL-18Ra+ but TCR-. However, QuPath considers it triple +). So, here, my goal would have been to apply only CD3 and IL-18Ra classifiers and manually attribute the positivity for TCR.
Problem is (see next image), I can’t change the class when I select the cell:
Screen Shot 2020-11-16 at 17.01.11

Hope this is clearer and I apologize if the script you suggested already solved my problem and I did not try it yet.
As soon as I try I’ll give a feedback.

Thanks again!

The most straightforward method will be recreating the composite classifier with only the two classes that work, and then finding some way to add in the third positive class. The “Set class” will only work if you have a list of complex classes to set, I think. So you would have to choose from triple, two different double positive classes, or single positive, when manually assigning the class. Kind of awkward, but doable as long as you have created those classes in your Annotation tab. You could do this now, before creating the new Composite classifier by right clicking and adding existing classes. Then click on a cell you want to change, choose the correct class, and Set class.
I don’t think there is a key binding for set class, so this will likely be slow.
Depending on the staining, you might want to consider creating other measurements or changing the size of your cell expansion.

@melvingelbard @petebankhead do you have any easy way to tag on an extra class to an already complex class… or single class, or null, as the case may be? Otherwise, it will likely be scripting.

Not really without scripting.

I didn’t understand your description about setting classes :slight_smile: but you can right-click on the list of classes and add a new one that corresponds to what the composite classifier would do. The main thing you need to remember is to split the different classifications with a colon and space, e.g.

Screenshot 2020-11-17 at 16.49.47

Once the classification is in the list, you can double-click on it and change the color if you like.

That would be equivalent to the composite classifier setting a cell as positive for CD3, IL-18Ra and TCR. You can then manually select cells and press the Set button under the classification list to assign that specific combination to any selected cells.

There’s also ‘Selection mode’ (the S button on the toolbar) that might be helpful as an advanced trick. Try playing around with it with/without the ‘Auto set’ button pressed to see what it does, or check out this YouTube video to see it in action:


Yeah, I was thinking that, since they had already run a complex classifier with all 3 classes, they could load all of those classes into the annotation list through the context menu. Then, after running the complex classifier with 2 classes, they could apply the correct classes as needed.

Or they could add all four needed classes manually, either way works.

Thanks a lot for your advices and comments. This is really helpful.
What put me off was the fact that when I right click on a cell after applying my classifier, the “set class” option was not in the list (see the 2nd image I sent on my previous post).
As I was in the “Hierarchy” list, I did not see the possibility of changing the class that way. So thanks, this finally looks really easy and simple but it solved the problem! :sunglasses::+1:t2: Even if I would have loved to be able to use the “Set class” when I right click instead of going back and forth from “Hierarchy” to “Annotations.” (but hey, it’s free, far from me the idea of complaining in any way!! :wink:)

Then new question: in the hierarchy, is there a possibility to sort the results obtained via “classes”? Like, seeing the CD3+ first, then CD3+ IL-18Ra+… etc.? With a list of 23’400 objects, this can be tricky to scroll down that much… But I guess there are probably scripting options there as well.

By the way:

I simply followed the multiplexed analysis tutorial. Sorry if my explanations were bad…:man_shrugging:t2::man_facepalming:t2:

Thanks for the “Select” mode + “Auto set” combination. This might be useful as well for huge clusters of CD3+ cells.

Thanks again for your time and energy thinking about and solving my problem. If you have any idea why the “set class” disappears, I stay tuned!

1 Like

Oh no, your explanations were fine – it was @Research_Associate’s that I didn’t follow :wink:
But then I didn’t express that very clearly myself, so…

Set class just appears if you right-click for annotations, not detections like cells. I didn’t want to make it too easy to change classifications for individual cells, since it is usually better to rely on a classifier for reproducibility… in fact, setting classifications for cells wasn’t possible at all in v0.1.2.

But then I decided that wasn’t really up to me, and in v0.2 it is possible to classify cells manually… it’s just marginally more awkward so as not to encourage it too much :slight_smile:

Not in the hierarchy, but if you use Measure → Show detection measurements you can sort the table by clicking on column headings. You can also right-click on the table and show only objects with specific classes. And you can use the table to select cells*.

*-There’s a bug in JavaFX that means selecting lots of entries in very large tables becomes unusably slow… when this is fixed in JavaFX, it will work better in QuPath too. In the meantime, just be a bit careful when using that approach. Selecting small numbers of cells should be fine, so you might not be affected by this.


Ahaha! Ok, then we’re good now! :sweat_smile:

Ok, so thanks for that update, this is really helpful to me. Even if it is reproducible, this is good to be able to give the choice to the user. For my images, I think determining the positivity is tricky for the software so I’ll have to double check most of the TCR+ cells.

Until now, I was counting and finding my cells using FIJI but I have to say the “Channel viewer” on QuPath is just AMAZING and make my life easier! Problem is, all the little pop-up windows (Brightness/Contrast, Channel Viewer, Detection results… etc.) go in the middle of my screen every time I right-click on a cell (or anywhere actually). That is probably a problem coming from my Mac though, as it does not do that on the one from my colleague. This is annoying but manageable.

Exactly what I wanted to find! Thanks!

1 Like

Strange, I haven’t seen this & I’ve been using QuPath on both an iMac and MacBook Pro. Do you have multiple monitors? I don’t so haven’t checked if that matters.

Actually I do. but with or without, it seems to be the same. :man_shrugging:t2:

Not sure if this is what you are talking about, but might be worth a look.


Yes, exactly my problem!.. Sorry, I should have had a look at the forum before asking… I am never on forums, I always forget the basics… :man_facepalming:t2:
Solution 1 works but I’ll have to get used to the new system (an app in full screen turn the secondary screen to black…). I guess I won’t use the full screen mode anymore!

Thanks a lot!