Using annotations to create a cell detection classifier

I have created 20 annotations in an image in order to train QuPath to identify a certain type of cell. These 20 annotations are examples of the type of cell. I set them all to a class and now want to create a classifier so that I can apply it to other images so that QuPath can tell me how many of those cells are in the image. I am having trouble with creating the classifier.

Please specify the steps you are taking with the classifier, if they are not the same as described here:

It sounds like you want to train the classifier, and save it, and then use a script to run it for the whole project?

It is also best to include which version of QuPath you are using.


I am using the QuPath 0.1.2 version. Yes, I trained the classifier but am not sure how to apply it to all the images in the project?

Also, I wanted to know if QuPath works for toluidine blue stained images?

Thank you.


I’ve worked with up to 5 color brightfield images. The limitations tend to be how much time you are willing to put in to split the staining accurately, and the quality of the samples/staining. The more similar the colors, the more careful and consistent you will have to be during sample preparation. Pete has a section on setting color vectors in his YouTube series for H-DAB, but it will work for any two colors you want to separate. More than two colors requires multiple color vectors and a classifier.

oh ok, thank you for that information!
So, if i have toluidine blue images then I should set two colors. Then is it possible to make a classifier that will tell you how many cells of one of the colors is in the image?

Thank you!

Ideally, yes. If you can segment both the cell (accurate cell counts) and what you are interested (accurate sub-cellular localization, easy for nuclear stains) in appropriately. It is important to be aware of the cytoplasmic expansion and other options if you are interested in a cytoplasmic stain.

The classifier can only use measurements that you have created, and often the mean cytoplasmic intensity is misleading. YMMV based on cell size and shape.

Also, if you get it down to a single measurement, it’s easiest to use the one line classifier Pete describes in the first link in my first response.

setCellIntensityClassifications("Nucleus: DAB OD mean", 0.2)

I am not sure what you mean by “segment both the cell (accurate cell counts) and what you are interested (accurate sub-cellular localization”,
Is this done by setting the stain vectors? or are you referring to another thing in QuPath?

Thank you!

I mean that yes, you can do what you want, but you will have to be careful about how you do it if the stain is cytoplasmic.