Analyze->Cell Analysis->Cell detection
Positive cell detection and cell detection are the two main workhorses for counting and classifying cells in QuPath. They are nearly identical, with Positive cell detection having a few extra options that are specific to DAB measurements. Note: that does not mean that they can only be used with DAB, just that they only work with a second color vector called DAB. I suggest keeping your Image type as Brightfield (H-DAB) regardless of your actual stains if you want to use Positive Cell Detection.
Each method functions by finding a “nucleus” object from a modified version of the image that, hopefully, isolates nuclei. For example, only the hematoxylin stain within a brightfield image. Once that object is found, it will attempt to expand a cytoplasm around it. This cytoplasmic expansion is blind, and so the cytoplasm will always have the same shape as the nucleus, unless it runs into another cytoplasmic expansion. If there is another nucleus within cytoplasmic expansion range, the two cytoplasms will stop halfway between the two nuclei.
Options and measurements
The command interface
Choose detection image: The default QuPath options are limited to Hematoxylin, or OD sum. Hematoxylin refers to whatever is in the Hematoxylin color vector (Image tab), and so it is, essentially, the “one color channel” option. You can adjust it to whatever color you want. OD sum is the total optical density of the image, and can be seen using the 5 key, or selecting Optical density sum in the Brightness and contrast dialog. Generally, use Hematoxylin when you have an effective nuclear stain that exists exclusively in 100% of your cells, and use OD sum when you have some sort of marker that may exist in your nucleus and obscure the hematoxylin (eg. KI67).
Requested pixel size: Downsampling. Snaps to the closest multiple of the pixel size (I believe). Higher values will run faster, lower values should give more precise outlines. Going below your pixel width/height is not useful.
Background radius and Max background intensity: These two options are linked, and are useful for preventing masses of cells from showing up in high background areas like black marker, smudges, and tissue folds. The first thing I tend to change if I am having difficulties is to remove the background radius measurement.
Standard settings over a tissue fold.
Reducing the Max background intensity prevents many of the cells around the fold from being generated.
Mean filter radius and Sigma: If your cells are being split too often, increase these. If your cells are being merged together incorrectly, lower these. They are two slightly different ways of achieving roughly the same thing, but it may require some trial and error to establish the best results for your particular experiment. In general, Median filter radius is slower, so I tend to use it less. Increasing either or both of these too much will result in an empty halo of “extra nucleus” around any detected nuclei.
Minimum area: Minimum allowed area for the nucleus. Note that this is prior to the application of Smooth boundaries, so you will occasionally see nuclear areas below your threshold if that option is selected.
Maximum area: Same as minimum, with the same caveat.
Threshold: This is the big one! It determines how “high” the pixel values have to be to be considered a potential nucleus. Anything below this is ignored. To get an idea of what the detection algorithm is looking at, use the “2” key for Hematoxylin, or the “5” key for Optical density sum, and then mouse over the values in the resulting image. The lower right corner of the viewer will show the values of the pixel the cursor is currently over (in addition to the coordinates above it). In general, you will need a lower threshold than the positive pixels you find, due to the blur mixing the positive signal with whitespace.
Cursor, sadly, not shown.
Split by shape: Default checked, I have never found any need to uncheck this, but give it a shot if you have very oddly shaped nuclei that are being split into multiple cells. Doing so generally has a very negative effect on separating any tightly clustered nuclei.
Cell Expansion: This determines how far the nucleus (base object) will expand. Pixels within this cell expansion will contribute to the “Cytoplasm” measurements in the detection object. If this is set to zero, the resulting object will be a nucleus, and not a cell object. That prevents certain other methods from being run on it, like Subcellular detection or setCellIntensityClassifications(). I would recommend always using at least 1 pixel expansion. See this thread for other concerns when using Cytoplasm based measurements.
Include cell nucleus: Unchecking removes the cell nucleus. This can reduce video lag and the number of measurements for a cell. Cytoplasmic measurements are still included despite the lack of a nucleus.
Smooth boundaries: Generates smoother cell and nuclear edges. It appears that cell measurements are based off of these lines, so this is not simply a visual change.
Make measurements: You want these, right? No check, no data. This has been useful only in situations where I have a multiplex brightfield image, and the terrible, horrible, things I had to do to get appropriate cell segmentation made the initial measurements not terribly useful.
Once you have cell objects, you might want to classify them.
Positive cell detection only
Information specific to the positive version of the command
Score compartment: a selection of 6 measurements to use for your threshold(s). I would recommend not using Max. Ever. Positive cell detection now works for Fluorescent images as well, and behaves as a built in Classify->Object classification->Create single measurement classifier, though it allows for three different thresholds.
Choosing a threshold: As noted several other places on the forums, there is no such thing as a correct, objective threshold for positivity. Ideally, there would be some ground truth, but that frequently comes from our interpretation, the amount of background generated by a given antibody, and other biological concerns (PDL1 being strongly expressed on muscle cells that are not of interest to someone studying cancer). One possible way to choose is to have a good negative control. Another would be having a pathologist or someone familiar with your marker explaining what background is expected, and what constitutes positive in regards to your study. In the end, you will have to make some decision, and there are a couple of tools in QuPath to help with this.
Choosing thresholds for positivity
Measure->Measurement maps: By adjusting the lower slider on the color scale for a given measurement, you can find a good threshold where all of your positive cells show up as red. Below is an example showing the lower (Maximum) threshold has been reduced to 0.09 for Cytopasmic Eosin staining, and the resulting cells that would be positive for such a measurement.
As of 0.2.0 there are new color map options that are better suited to visualizing data sets fairly, and making them useful for people with colorblindness.
Combining these options with the filter on the measurement list should allow you to quickly visualize your measurements of interest.
Measure->Show detection measurements->Show histograms: Sometimes, especially if you have a bimodal distribution, you can use the histogram for a particular measurement to help determine a particular cutoff. Alternatively, you can use this dialog to look at detection objects near your threshold in an already classified set of objects; this can help you decide if the “close calls” are being made correctly enough.
Note: don’t always require “nuclear” measurements to be nuclear (link to CD8 thread). As mentioned above, when using OD sum to generate your nuclei, you may also be picking up cytoplasm as part of the nucleus. That is okay, as long as you can still determine the positivity of your detection.
Sometimes you may need features that are not available by default, for example using other color deconvolution vectors, or measuring the angle of the cell. You can find additional information on adding features here.
If you still need a more complex classifier, check here, or go straight to converting this into a script you can run on the whole project.